mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
guess expected type like for completion if on the left side of assignment to functional expression which provides in this case no expected type (IDEA-169382)
This commit is contained in:
+4
-1
@@ -575,7 +575,10 @@ public class CreateFromUsageUtils {
|
||||
PsiElement parent = expr.getParent();
|
||||
|
||||
if (!(parent instanceof PsiReferenceExpression)) {
|
||||
ExpectedTypeInfo[] someExpectedTypes = ExpectedTypesProvider.getExpectedTypes(expr, PsiUtil.skipParenthesizedExprUp(parent) instanceof PsiExpressionList);
|
||||
boolean isAssignmentToFunctionalExpression = PsiUtil.isOnAssignmentLeftHand(expr) &&
|
||||
((PsiAssignmentExpression)PsiUtil.skipParenthesizedExprUp(parent)).getRExpression() instanceof PsiFunctionalExpression;
|
||||
boolean forCompletion = PsiUtil.skipParenthesizedExprUp(isAssignmentToFunctionalExpression ? parent.getParent() : parent) instanceof PsiExpressionList;
|
||||
ExpectedTypeInfo[] someExpectedTypes = ExpectedTypesProvider.getExpectedTypes(expr, forCompletion);
|
||||
if (someExpectedTypes.length > 0) {
|
||||
Arrays.sort(someExpectedTypes, (o1, o2) -> compareExpectedTypes(o1, o2, expression));
|
||||
types.add(someExpectedTypes);
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Create local variable 'lf'" "true"
|
||||
import java.util.function.Function;
|
||||
|
||||
class Main2 {
|
||||
void f(Function<String, String> g) {}
|
||||
{
|
||||
Function<String, String> lf;
|
||||
f(lf = c -> c);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Create local variable 'lf'" "true"
|
||||
import java.util.function.Function;
|
||||
|
||||
class Main2 {
|
||||
void f(Function<String, String> g) {}
|
||||
{
|
||||
f(l<caret>f = c -> c);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user