mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
completion: take into account provided type arguments (IDEA-169478)
This commit is contained in:
@@ -985,8 +985,8 @@ public class ExpectedTypesProvider {
|
||||
PsiSubstitutor substitutor;
|
||||
if (candidateInfo instanceof MethodCandidateInfo) {
|
||||
final MethodCandidateInfo info = (MethodCandidateInfo)candidateInfo;
|
||||
substitutor = MethodCandidateInfo.ourOverloadGuard
|
||||
.doPreventingRecursion(argumentList, false, () -> info.inferTypeArguments(policy, args, true));
|
||||
substitutor = MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(argumentList, false,
|
||||
() -> info.inferSubstitutorFromArgs(policy, args));
|
||||
if (!info.isStaticsScopeCorrect() && !method.hasModifierProperty(PsiModifier.STATIC)) continue;
|
||||
}
|
||||
else {
|
||||
@@ -999,8 +999,7 @@ public class ExpectedTypesProvider {
|
||||
|
||||
if (leftArgs != null && candidateInfo instanceof MethodCandidateInfo) {
|
||||
substitutor = MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(argumentList, false,
|
||||
() -> ((MethodCandidateInfo)candidateInfo)
|
||||
.inferTypeArguments(policy, leftArgs, true));
|
||||
() -> ((MethodCandidateInfo)candidateInfo).inferSubstitutorFromArgs(policy, leftArgs));
|
||||
if (substitutor != null) {
|
||||
inferMethodCallArgumentTypes(argument, forCompletion, leftArgs, index, method, substitutor, array);
|
||||
}
|
||||
|
||||
@@ -806,7 +806,8 @@ public class JavaCompletionUtil {
|
||||
PsiElement composite = leaf == null ? null : leaf.getParent();
|
||||
if (composite instanceof PsiMethodReferenceExpression && LambdaHighlightingUtil.insertSemicolon(composite.getParent())) {
|
||||
insertAdditionalSemicolon = false;
|
||||
} else if (composite instanceof PsiReferenceExpression) {
|
||||
}
|
||||
else if (composite instanceof PsiReferenceExpression) {
|
||||
PsiElement parent = composite.getParent();
|
||||
if (parent instanceof PsiMethodCallExpression) {
|
||||
parent = parent.getParent();
|
||||
@@ -814,6 +815,9 @@ public class JavaCompletionUtil {
|
||||
if (parent instanceof PsiLambdaExpression && !LambdaHighlightingUtil.insertSemicolonAfter((PsiLambdaExpression)parent)) {
|
||||
insertAdditionalSemicolon = false;
|
||||
}
|
||||
if (parent instanceof PsiMethodReferenceExpression && LambdaHighlightingUtil.insertSemicolon(parent.getParent())) {
|
||||
insertAdditionalSemicolon = false;
|
||||
}
|
||||
}
|
||||
if (insertAdditionalSemicolon) {
|
||||
toInsert = TailType.SEMICOLON;
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
class Test {
|
||||
private static <T> void _f(Consumer<T> c) {}
|
||||
|
||||
private static void bar(final String s) {}
|
||||
|
||||
public static void main(String[] argArr) {
|
||||
Test.<String>_f(Test::bar);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
class Test {
|
||||
private static <T> void _f(Consumer<T> c) {}
|
||||
|
||||
private static void bar(final String s) {}
|
||||
|
||||
public static void main(String[] argArr) {
|
||||
Test.<String>_f(b<caret>);
|
||||
}
|
||||
}
|
||||
+4
@@ -156,6 +156,10 @@ public class SmartType18CompletionTest extends LightFixtureCompletionTestCase {
|
||||
}
|
||||
|
||||
public void testStaticMethodReference() { doTest(false); }
|
||||
public void testStaticMethodReferenceInContextWithTypeArgs() {
|
||||
configureByTestName();
|
||||
checkResultByFile("/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
public void testOuterMethodReference() { doTest(true); }
|
||||
public void testNoAnonymousOuterMethodReference() { doAntiTest(); }
|
||||
|
||||
Reference in New Issue
Block a user