java invert if: ignore redundant return stmts (IDEA-258495)

GitOrigin-RevId: 4a1fc182d5e8e053dd60288b85764a511e72c08a
This commit is contained in:
Anna Kozlova
2020-12-29 14:14:16 +00:00
committed by intellij-monorepo-bot
parent 5ea63d85c7
commit 101ad553b7
3 changed files with 2 additions and 7 deletions
@@ -327,7 +327,8 @@ public class InvertIfConditionAction extends PsiElementBaseIntentionAction {
}
}
}
if (thenBranch instanceof PsiContinueStatement) {
if (thenBranch instanceof PsiContinueStatement ||
thenBranch instanceof PsiReturnStatement && ((PsiReturnStatement)thenBranch).getReturnValue() == null) {
PsiStatement elseBranch = ifStatement.getElseBranch();
if (elseBranch != null) {
elseBranch.delete();
@@ -12,8 +12,5 @@ class A {
});
}
else {
return;
}
}
}
@@ -4,8 +4,5 @@ class A {
<caret>if (c) {
foo();
}
else {
return;
}
}
}