Skip to content

Commit

Permalink
Fix for #960: set source range of method call redirect for trait
Browse files Browse the repository at this point in the history
property
  • Loading branch information
eric-milles committed Sep 23, 2019
1 parent dc9f757 commit 2afed9d
Show file tree
Hide file tree
Showing 8 changed files with 1,491 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void testProperty1() {
assertExprType(source, "number", "java.lang.Number");
}

@Test @Ignore
@Test
public void testProperty2() {
String source =
"trait T {\n" +
Expand All @@ -60,7 +60,7 @@ public void testProperty2() {
assertExprType(source, "number", "java.lang.Number");
}

@Test @Ignore
@Test
public void testProperty3() {
String source =
"trait T {\n" +
Expand All @@ -74,7 +74,7 @@ public void testProperty3() {
assertExprType(source, "number", "java.lang.Number");
}

@Test @Ignore
@Test
public void testProperty4() {
String source =
"trait T {\n" +
Expand Down
1 change: 1 addition & 0 deletions base/org.codehaus.groovy24/.checkstyle
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<file-match-pattern match-pattern="groovy/transform/trait/SuperCallTraitTransformer.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/trait/TraitASTTransformation.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/trait/TraitComposer.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/trait/TraitReceiverTransformer.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/vmplugin/v5/Java5.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/vmplugin/v8/Java8.java" include-pattern="false" />
</fileset>
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions base/org.codehaus.groovy25/.checkstyle
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<file-match-pattern match-pattern="groovy/transform/trait/SuperCallTraitTransformer.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/trait/TraitASTTransformation.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/trait/TraitComposer.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/trait/TraitReceiverTransformer.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/vmplugin/v5/Java5.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/vmplugin/v8/Java8.java" include-pattern="false" />
</fileset>
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions base/org.codehaus.groovy30/.checkstyle
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<file-match-pattern match-pattern="groovy/transform/trait/SuperCallTraitTransformer.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/trait/TraitASTTransformation.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/trait/TraitComposer.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/trait/TraitReceiverTransformer.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/vmplugin/v5/Java5.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/vmplugin/v8/Java8.java" include-pattern="false" />
</fileset>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3235,6 +3235,101 @@ final class SemanticHighlightingTests extends GroovyEclipseTestSuite {

@Test
void testTraits3() {
String contents = '''\
|trait T {
| String string
| void method() {
| this.string
| }
|}
|'''.stripMargin()

assertHighlighting(contents,
new HighlightedTypedPosition(contents.indexOf('T'), 1, TRAIT),
new HighlightedTypedPosition(contents.indexOf('String'), 6, CLASS),
new HighlightedTypedPosition(contents.indexOf('string'), 6, FIELD),
new HighlightedTypedPosition(contents.indexOf('method'), 6, METHOD),
new HighlightedTypedPosition(contents.lastIndexOf('string'), 6, FIELD))
}

@Test
void testTraits4() {
String contents = '''\
|trait T {
| String string
| void method() {
| this.getString()
| }
|}
|'''.stripMargin()

assertHighlighting(contents,
new HighlightedTypedPosition(contents.indexOf('T'), 1, TRAIT),
new HighlightedTypedPosition(contents.indexOf('String'), 6, CLASS),
new HighlightedTypedPosition(contents.indexOf('string'), 6, FIELD),
new HighlightedTypedPosition(contents.indexOf('method'), 6, METHOD),
new HighlightedTypedPosition(contents.lastIndexOf('getString'), 9, METHOD_CALL))
}

@Test
void testTraits5() {
String contents = '''\
|trait T {
| String string
| void method() {
| string = ''
| }
|}
|'''.stripMargin()

assertHighlighting(contents,
new HighlightedTypedPosition(contents.indexOf('T'), 1, TRAIT),
new HighlightedTypedPosition(contents.indexOf('String'), 6, CLASS),
new HighlightedTypedPosition(contents.indexOf('string'), 6, FIELD),
new HighlightedTypedPosition(contents.indexOf('method'), 6, METHOD),
new HighlightedTypedPosition(contents.lastIndexOf('string'), 6, FIELD))
}

@Test
void testTraits6() {
String contents = '''\
|trait T {
| String string
| void method() {
| this.string = ''
| }
|}
|'''.stripMargin()

assertHighlighting(contents,
new HighlightedTypedPosition(contents.indexOf('T'), 1, TRAIT),
new HighlightedTypedPosition(contents.indexOf('String'), 6, CLASS),
new HighlightedTypedPosition(contents.indexOf('string'), 6, FIELD),
new HighlightedTypedPosition(contents.indexOf('method'), 6, METHOD),
new HighlightedTypedPosition(contents.lastIndexOf('string'), 6, FIELD))
}

@Test
void testTraits7() {
String contents = '''\
|trait T {
| String string
| void method() {
| this.setString('')
| }
|}
|'''.stripMargin()

assertHighlighting(contents,
new HighlightedTypedPosition(contents.indexOf('T'), 1, TRAIT),
new HighlightedTypedPosition(contents.indexOf('String'), 6, CLASS),
new HighlightedTypedPosition(contents.indexOf('string'), 6, FIELD),
new HighlightedTypedPosition(contents.indexOf('method'), 6, METHOD),
new HighlightedTypedPosition(contents.lastIndexOf('setString'), 9, METHOD_CALL))
}

@Test
void testTraits8() {
addGroovySource '''\
|trait T {
| String getFoo() { 'foo' }
Expand Down Expand Up @@ -3262,7 +3357,7 @@ final class SemanticHighlightingTests extends GroovyEclipseTestSuite {
}

@Test
void testTraits4() {
void testTraits9() {
String contents = '''\
|trait T {
| def whatever() {}
Expand All @@ -3286,7 +3381,7 @@ final class SemanticHighlightingTests extends GroovyEclipseTestSuite {
}

@Test
void testTraits5() {
void testTraits10() {
String contents = '''\
|trait T {
| def foo
Expand Down

0 comments on commit 2afed9d

Please sign in to comment.