Skip to content

Commit 6816c17

Browse files
authored
Fix relevance for completion of receiver of varargs method invocation (eclipse-jdt#4248)
Fixes eclipse-jdt#4247 Signed-off-by: David Thompson <davthomp@redhat.com>
1 parent c0b574f commit 6816c17

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26145,11 +26145,11 @@ public void testBug574982() throws JavaModelException {
2614526145
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2614626146
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2614726147
assertResults(
26148-
"ABC[TYPE_REF]{p1.ABC, p1, Lp1.ABC;, null, null, 69}\n" +
26149-
"ABC[TYPE_REF]{p2.ABC, p2, Lp2.ABC;, null, null, 69}\n" +
26150-
"A3[TYPE_REF]{A3, , LA3;, null, null, 72}\n" +
26151-
"ArrayTest[TYPE_REF]{ArrayTest, , LArrayTest;, null, null, 72}\n" +
26152-
"A[TYPE_REF]{A, , LA;, null, null, 76}",
26148+
"ABC[TYPE_REF]{p1.ABC, p1, Lp1.ABC;, null, null, 49}\n" +
26149+
"ABC[TYPE_REF]{p2.ABC, p2, Lp2.ABC;, null, null, 49}\n" +
26150+
"A3[TYPE_REF]{A3, , LA3;, null, null, 52}\n" +
26151+
"ArrayTest[TYPE_REF]{ArrayTest, , LArrayTest;, null, null, 52}\n" +
26152+
"A[TYPE_REF]{A, , LA;, null, null, 56}",
2615326153
requestor.getResults());
2615426154
}
2615526155
/**

org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3887,7 +3887,7 @@ private void completionOnSingleNameReference(ASTNode astNode, ASTNode astNodePar
38873887
checkCancel();
38883888

38893889
// see if we can find argument type at position in case if we are at a vararg.
3890-
checkForVarargExpectedTypes(astNodeParent, scope);
3890+
checkForVarargExpectedTypes(astNodeParent, astNode, scope);
38913891
findVariablesAndMethods(this.completionToken, scope, singleNameReference, scope, insideTypeAnnotation,
38923892
singleNameReference.isInsideAnnotationAttribute, true, new ObjectVector());
38933893

@@ -3923,8 +3923,11 @@ private void completionOnSingleNameReference(ASTNode astNode, ASTNode astNodePar
39233923
}
39243924
}
39253925

3926-
private void checkForVarargExpectedTypes(ASTNode astNodeParent, Scope scope) {
3927-
if (astNodeParent instanceof MessageSend m && this.expectedTypesPtr == -1) {
3926+
private void checkForVarargExpectedTypes(ASTNode astNodeParent, ASTNode astNode, Scope scope) {
3927+
if (astNodeParent instanceof MessageSend m
3928+
&& m.arguments() != null
3929+
&& Stream.of(m.arguments()).anyMatch(astNode::equals)
3930+
&& this.expectedTypesPtr == -1) {
39283931
final ObjectVector methodsToSearchOn = new ObjectVector();
39293932
final CompletionRequestor actual = this.requestor;
39303933
this.requestor = new CompletionRequestor(true) {

0 commit comments

Comments
 (0)