TrivialFunctionalExpressionUsageInspection: support parentheses for anonymous class

This commit is contained in:
Tagir Valeev
2019-04-19 11:55:23 +07:00
parent e13567df50
commit 179a83f60e
3 changed files with 19 additions and 1 deletions

View File

@@ -0,0 +1,9 @@
// "Replace call with method body" "true"
import java.util.function.IntSupplier;
public class Main {
public void call() {
switch((0)) {}
}
}

View File

@@ -0,0 +1,9 @@
// "Replace call with method body" "true"
import java.util.function.IntSupplier;
public class Main {
public void call() {
switch((new IntSupplier() {public int getAsInt() { return 0;}}.getA<caret>sInt())) {}
}
}

View File

@@ -101,7 +101,7 @@ public class TrivialFunctionalExpressionUsageInspection extends AbstractBaseJava
if (returnStatements.length > 1) {
return false;
}
final PsiElement callParent = call.getParent();
final PsiElement callParent = PsiUtil.skipParenthesizedExprUp(call.getParent());
return callParent instanceof PsiStatement ||
callParent instanceof PsiLocalVariable;
}, newExpression, aClass.getBaseClassType(), new ReplaceAnonymousWithLambdaBodyFix());