Skip to content

Commit

Permalink
Fix for #761: re-enable completion on annotation member name prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Nov 19, 2018
1 parent a744860 commit 976fa3f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '''\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public List<ICompletionProposal> generateProposals(IProgressMonitor monitor) {
List<ICompletionProposal> proposals = new ArrayList<>();
String memberName = getPerceivedCompletionMember();

if (memberName == null || isImplicitValueExpression()) {
if (memberName == null || isImplicitValueExpression() ||
getAnnotation().getClassNode().getMethods(memberName).isEmpty()) {
generateAnnotationMemberProposals(proposals);
}
monitor.worked(1);
Expand Down Expand Up @@ -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();
}
}
Expand Down

0 comments on commit 976fa3f

Please sign in to comment.