mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
fix invert if followed by break bugs (IDEA-38798 & IDEA-112313)
This commit is contained in:
@@ -365,7 +365,8 @@ public class InvertIfConditionAction extends PsiElementBaseIntentionAction {
|
||||
if (endOffset == -1) {
|
||||
endOffset = controlFlow.getSize();
|
||||
}
|
||||
while (endOffset < instructions.size() && instructions.get(endOffset) instanceof GoToInstruction && !((GoToInstruction) instructions.get(endOffset)).isReturn) {
|
||||
while (endOffset < instructions.size() && instructions.get(endOffset) instanceof GoToInstruction &&
|
||||
!((GoToInstruction) instructions.get(endOffset)).isReturn && !(controlFlow.getElement(endOffset) instanceof PsiBreakStatement)) {
|
||||
endOffset = ((BranchingInstruction)instructions.get(endOffset)).offset;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// "Invert 'if' condition" "true"
|
||||
class A {
|
||||
public boolean accept() {
|
||||
boolean xx = true;
|
||||
switch (1) {
|
||||
case 0:
|
||||
if (!xx) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Invert 'if' condition" "true"
|
||||
class A {
|
||||
void m(boolean b) {
|
||||
while (true) {
|
||||
if (!b) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Invert 'if' condition" "true"
|
||||
class A {
|
||||
public boolean accept() {
|
||||
boolean xx = true;
|
||||
switch (1) {
|
||||
case 0:
|
||||
<caret>if (xx) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Invert 'if' condition" "true"
|
||||
class A {
|
||||
void m(boolean b) {
|
||||
while (true) {
|
||||
<caret>if (b) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user