mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
MoveIntoIfBranchesAction: disable if if branch cannot complete normally
GitOrigin-RevId: 07c9d5a46c0ded0d1de27c0a0c4b372061b84917
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1829c3119a
commit
91092e2ef7
+7
-1
@@ -62,7 +62,13 @@ public class MoveIntoIfBranchesAction implements IntentionAction {
|
||||
afterLast.add(e);
|
||||
}
|
||||
}
|
||||
List<String> declaredInIf = StreamEx.of(ifStatement.getThenBranch(), ifStatement.getElseBranch()).flatArray(ControlFlowUtils::unwrapBlock)
|
||||
PsiStatement thenBranch = ifStatement.getThenBranch();
|
||||
PsiStatement elseBranch = ifStatement.getElseBranch();
|
||||
if (!ControlFlowUtils.statementMayCompleteNormally(thenBranch) ||
|
||||
!ControlFlowUtils.statementMayCompleteNormally(elseBranch)) {
|
||||
return true;
|
||||
}
|
||||
List<String> declaredInIf = StreamEx.of(thenBranch, elseBranch).flatArray(ControlFlowUtils::unwrapBlock)
|
||||
.select(PsiDeclarationStatement.class).flatArray(PsiDeclarationStatement::getDeclaredElements)
|
||||
.select(PsiNamedElement.class).map(PsiNamedElement::getName).nonNull().toList();
|
||||
if (afterLast.isEmpty() && declaredInIf.isEmpty()) return false;
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// "Move up into 'if' statement branches" "false"
|
||||
class Test {
|
||||
void test(int x) {
|
||||
if (x > 0) return;
|
||||
<caret>System.out.println(x);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user