Skip to content

Commit

Permalink
Fix for #1004: drop legacy check for synthetic enum methods
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Dec 12, 2019
1 parent 620a3fb commit d7d53ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,24 @@ final class SemanticHighlightingTests extends GroovyEclipseTestSuite {
new HighlightedTypedPosition(contents.lastIndexOf('meth'), 4, METHOD))
}

@Test // https://github.com/groovy/groovy-eclipse/issues/1004
void testEnumMethod() {
String contents = '''\
|enum X {
| Y
|}
|X.Y.next().name()
|'''.stripMargin()

assertHighlighting(contents,
new HighlightedTypedPosition(contents.indexOf('X'), 1, ENUMERATION),
new HighlightedTypedPosition(contents.indexOf('Y'), 1, STATIC_VALUE),
new HighlightedTypedPosition(contents.lastIndexOf('X'), 1, ENUMERATION),
new HighlightedTypedPosition(contents.lastIndexOf('Y'), 1, STATIC_VALUE),
new HighlightedTypedPosition(contents.lastIndexOf('next'), 4, METHOD_CALL),
new HighlightedTypedPosition(contents.lastIndexOf('name'), 4, METHOD_CALL))
}

@Test // https://github.com/groovy/groovy-eclipse/issues/938
void testEnumValues() {
setJavaPreference(CompilerOptions.OPTION_AnnotationBasedNullAnalysis, CompilerOptions.ENABLED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,6 @@ private HighlightedTypedPosition handleMethodReference(MethodPointerExpression e
}

private HighlightedTypedPosition handleMethodReference(Expression expr, TypeLookupResult result, boolean isStaticImport) {
if (((MethodNode) result.declaration).isSynthetic() && result.declaringType.isEnum()) return null;

HighlightKind kind = HighlightKind.METHOD_CALL;
if (result.isGroovy) {
kind = HighlightKind.GROOVY_CALL;
Expand Down

0 comments on commit d7d53ec

Please sign in to comment.