mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
invert if: don't leave trailing continue stmts (IDEA-197986)
This commit is contained in:
+1
-1
@@ -411,7 +411,7 @@ public class InvertIfConditionAction extends PsiElementBaseIntentionAction {
|
||||
endOffset = controlFlow.getSize();
|
||||
}
|
||||
while (endOffset < instructions.size() && instructions.get(endOffset) instanceof GoToInstruction &&
|
||||
!((GoToInstruction) instructions.get(endOffset)).isReturn && !(controlFlow.getElement(endOffset) instanceof PsiBreakStatement)) {
|
||||
!((GoToInstruction) instructions.get(endOffset)).isReturn && !(controlFlow.getElement(endOffset) instanceof PsiBreakStatement) && !(controlFlow.getElement(endOffset) instanceof PsiContinueStatement)) {
|
||||
endOffset = ((BranchingInstruction)instructions.get(endOffset)).offset;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Invert 'if' condition" "true"
|
||||
public class C {
|
||||
public void test() {
|
||||
for (int i = 0; i < 42; i++) {
|
||||
if (i != 7) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Invert 'if' condition" "true"
|
||||
public class C {
|
||||
public void test() {
|
||||
for (int i = 0; i < 42; i++) {
|
||||
i<caret>f (i == 7) {
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user