Skip to content

Commit

Permalink
Fix for #769: don't propose types when completing annotation member name
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Nov 25, 2018
1 parent bf6c456 commit 4566617
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,35 @@ final class AnnotationCompletionTests extends CompletionTestSuite {
assertThat(proposals).excludes('one', 'three').includes('two')
}

@Test // https://github.com/groovy/groovy-eclipse/issues/769
void testAnnoAttr12() {
addJavaSource '''\
package p;
import java.lang.annotation.*;
@Target(ElementType.METHOD)
public @interface A {
boolean one();
String two();
}
''', 'A', 'p'

addJavaSource '''\
package p;
public class Three {
}
''', 'Three', 'p'

String contents = '''\
import p.*
@A(one=false, t)
class Something {
}
'''.stripIndent()
def proposals = getProposals(contents, ', t')

assertThat(proposals).excludes('one', 'Three').includes('two')
}

@Test
void testAnnoAttrPacks() {
String contents = '''\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ public List<ICompletionProposal> generateProposals(IProgressMonitor monitor) {
try {
List<ICompletionProposal> proposals = new ArrayList<>();
String memberName = getPerceivedCompletionMember();
boolean memberFound = !getAnnotation().getClassNode().getMethods(memberName).isEmpty();

if (memberName == null || isImplicitValueExpression() ||
getAnnotation().getClassNode().getMethods(memberName).isEmpty()) {
if (!memberFound || isImplicitValueExpression()) {
generateAnnotationMemberProposals(proposals);
}
monitor.worked(1);

if (memberName != null || (getAnnotation().getMembers().isEmpty() && isImplicitValueSupported())) {
if (memberFound || (isImplicitValueSupported() && getAnnotation().getMembers().isEmpty())) {
generateAnnotationMemberValueProposals(proposals, memberName != null ? memberName : "value", monitor);
}
monitor.worked(1);
Expand Down

0 comments on commit 4566617

Please sign in to comment.