mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
support captured types in incomplete overloaded lambda completion (IDEA-155188)
This commit is contained in:
@@ -270,16 +270,9 @@ public class JavaCompletionUtil {
|
||||
final int parameterIndex = lambdaExpression.getParameterList().getParameterIndex((PsiParameter)resolve);
|
||||
final Set<LookupElement> set = new LinkedHashSet<LookupElement>();
|
||||
final boolean overloadsFound = LambdaUtil.processParentOverloads(lambdaExpression, functionalInterfaceType -> {
|
||||
PsiType qualifierType = LambdaUtil.getLambdaParameterFromType(functionalInterfaceType, parameterIndex);
|
||||
PsiType qualifierType = removeTopLevelWildcards(LambdaUtil.getLambdaParameterFromType(functionalInterfaceType, parameterIndex));
|
||||
if (qualifierType == null) return;
|
||||
|
||||
if (qualifierType instanceof PsiWildcardType) {
|
||||
PsiType bound = ((PsiWildcardType)qualifierType).getBound();
|
||||
if (bound != null) {
|
||||
qualifierType = bound;
|
||||
}
|
||||
}
|
||||
|
||||
PsiReferenceExpression fakeRef = createReference("xxx.xxx", createContextWithXxxVariable(element, qualifierType));
|
||||
set.addAll(processJavaQualifiedReference(fakeRef.getReferenceNameElement(), fakeRef, elementFilter, options, matcher, parameters));
|
||||
});
|
||||
@@ -288,10 +281,21 @@ public class JavaCompletionUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return processJavaQualifiedReference(element, javaReference, elementFilter, options, matcher, parameters);
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
private static PsiType removeTopLevelWildcards(@Nullable PsiType qualifierType) {
|
||||
if (qualifierType instanceof PsiCapturedWildcardType) {
|
||||
return removeTopLevelWildcards(((PsiCapturedWildcardType)qualifierType).getWildcard());
|
||||
}
|
||||
if (qualifierType instanceof PsiWildcardType) {
|
||||
return removeTopLevelWildcards(((PsiWildcardType)qualifierType).getBound());
|
||||
}
|
||||
return qualifierType;
|
||||
}
|
||||
|
||||
private static Set<LookupElement> processJavaQualifiedReference(PsiElement element, PsiJavaReference javaReference, ElementFilter elementFilter,
|
||||
JavaCompletionProcessor.Options options,
|
||||
final PrefixMatcher matcher, CompletionParameters parameters) {
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import java.util.stream.*;
|
||||
import java.util.*;
|
||||
|
||||
class Foo {
|
||||
void main(Stream<? super String> stream) {
|
||||
stream.collect(Collectors.toMap(o -> o.sub<caret>))
|
||||
}
|
||||
}
|
||||
+4
@@ -244,6 +244,10 @@ class Test88 {
|
||||
configureByTestName()
|
||||
myFixture.assertPreferredCompletionItems(0, 'substring', 'substring', 'subSequence')
|
||||
}
|
||||
public void testLambdaWithCapturedSuperWildcardInAmbiguousCall() {
|
||||
configureByTestName()
|
||||
myFixture.assertPreferredCompletionItems(0, 'substring', 'substring', 'subSequence')
|
||||
}
|
||||
public void testUnexpectedLambdaInAmbiguousCall() { doAntiTest() }
|
||||
|
||||
public void testNoCollectorsInComment() { doAntiTest() }
|
||||
|
||||
Reference in New Issue
Block a user