mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
disable trivial functional expression for body with returns (IDEA-173436)
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace method call on lambda with lambda body" "false"
|
||||
|
||||
class Test {
|
||||
void foo() {
|
||||
Runnable r = () -> {
|
||||
if (true) return;
|
||||
System.out.println("");
|
||||
};
|
||||
r.r<caret>un();
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
+11
-2
@@ -68,8 +68,17 @@ public class TrivialFunctionalExpressionUsageInspection extends BaseJavaBatchLoc
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!returnExpressions.isEmpty() && callParent instanceof PsiLocalVariable) {
|
||||
return true;
|
||||
if (!returnExpressions.isEmpty()) {
|
||||
if (callParent instanceof PsiLocalVariable) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
PsiReturnStatement[] returnStatements = PsiUtil.findReturnStatements((PsiCodeBlock)body);
|
||||
if (returnStatements.length > 0) {
|
||||
//accept redundant return which would be deleted
|
||||
return returnStatements.length == 1 && returnStatements[0] == statements[statements.length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
return (callParent instanceof PsiStatement && !(callParent instanceof PsiLoopStatement)) ||
|
||||
|
||||
Reference in New Issue
Block a user