diff --git a/ide-test/org.codehaus.groovy.eclipse.codeassist.completion.test/src/org/codehaus/groovy/eclipse/codeassist/tests/AnnotationCompletionTests.groovy b/ide-test/org.codehaus.groovy.eclipse.codeassist.completion.test/src/org/codehaus/groovy/eclipse/codeassist/tests/AnnotationCompletionTests.groovy index 5171527b63..205ae7bbd2 100644 --- a/ide-test/org.codehaus.groovy.eclipse.codeassist.completion.test/src/org/codehaus/groovy/eclipse/codeassist/tests/AnnotationCompletionTests.groovy +++ b/ide-test/org.codehaus.groovy.eclipse.codeassist.completion.test/src/org/codehaus/groovy/eclipse/codeassist/tests/AnnotationCompletionTests.groovy @@ -272,6 +272,55 @@ final class AnnotationCompletionTests extends CompletionTestSuite { assertThat(proposals).excludes('one', 'two') } + @Test // https://github.com/groovy/groovy-eclipse/issues/761 + void testAnnoAttr8() { + addJavaSource '''\ + package p; + import java.lang.annotation.*; + @Target(ElementType.TYPE) + public @interface A { + boolean one(); + String two(); + int three(); + } + ''', 'A', 'p' + + String contents = '''\ + import p.A + @A(one=false, t) + class Something { + } + '''.stripIndent() + def proposals = getProposals(contents, ', t') + + assertThat(proposals).excludes('one').includes('two', 'three') + } + + @Test // https://github.com/groovy/groovy-eclipse/issues/761 + void testAnnoAttr9() { + addJavaSource '''\ + package p; + import java.lang.annotation.*; + @Target(ElementType.METHOD) + public @interface A { + boolean one(); + String two(); + int three(); + } + ''', 'A', 'p' + + String contents = '''\ + import p.A + class Something { + @A(one=false, t) + void meth() {} + } + '''.stripIndent() + def proposals = getProposals(contents, ', t') + + assertThat(proposals).excludes('one').includes('two', 'three') + } + @Test void testAnnoAttrPacks() { String contents = '''\ diff --git a/ide/org.codehaus.groovy.eclipse.codeassist.completion/src/org/codehaus/groovy/eclipse/codeassist/factories/AnnotationMemberValueCompletionProcessorFactory.java b/ide/org.codehaus.groovy.eclipse.codeassist.completion/src/org/codehaus/groovy/eclipse/codeassist/factories/AnnotationMemberValueCompletionProcessorFactory.java index 2a0cbb4187..8c28bb42d4 100644 --- a/ide/org.codehaus.groovy.eclipse.codeassist.completion/src/org/codehaus/groovy/eclipse/codeassist/factories/AnnotationMemberValueCompletionProcessorFactory.java +++ b/ide/org.codehaus.groovy.eclipse.codeassist.completion/src/org/codehaus/groovy/eclipse/codeassist/factories/AnnotationMemberValueCompletionProcessorFactory.java @@ -74,7 +74,8 @@ public List generateProposals(IProgressMonitor monitor) { List proposals = new ArrayList<>(); String memberName = getPerceivedCompletionMember(); - if (memberName == null || isImplicitValueExpression()) { + if (memberName == null || isImplicitValueExpression() || + getAnnotation().getClassNode().getMethods(memberName).isEmpty()) { generateAnnotationMemberProposals(proposals); } monitor.worked(1); @@ -201,7 +202,7 @@ protected final String getPerceivedCompletionMember() { if (value.getStart() > context.completionLocation) { break; } - if (value.getLineNumber() == -1 && !member.getKey().equals("?")) { + if (value.getLineNumber() == -1) { maybe = member.getKey(); } }