create method from usage: treat polyadic expressions as for completion by containing expression (IDEA-151432)

This commit is contained in:
Anna Kozlova
2017-05-18 13:16:29 +03:00
parent 2740fe6831
commit e747d52bf5
3 changed files with 17 additions and 1 deletions

View File

@@ -581,7 +581,7 @@ public class CreateFromUsageUtils {
PsiExpressionList expressionList = ObjectUtils
.tryCast(PsiUtil.skipParenthesizedExprUp(isAssignmentToFunctionalExpression ? parent.getParent() : parent),
PsiExpressionList.class);
boolean forCompletion = expressionList != null;
boolean forCompletion = expressionList != null || parent.getParent() instanceof PsiPolyadicExpression;
ExpectedTypeInfo[] someExpectedTypes = ExpectedTypesProvider.getExpectedTypes(expr, forCompletion);
if (someExpectedTypes.length > 0) {
Comparator<ExpectedTypeInfo> comparator = expectedTypesComparator;

View File

@@ -0,0 +1,10 @@
// "Create method 'f'" "true"
class Test {
{
long l = f(1) + f(2);
}
private long f(int i) {
return 0;
}
}

View File

@@ -0,0 +1,6 @@
// "Create method 'f'" "true"
class Test {
{
long l = f(1) + <caret>f(2);
}
}