mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
[java-intentions] IDEA-312732 Invert 'if' doesn't work if branches have 'yield'
GitOrigin-RevId: 500a77bff4f250dbcd4779293e678d262227014f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ca3fa43d58
commit
06dfb15bc0
@@ -419,7 +419,10 @@ 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) && !(controlFlow.getElement(endOffset) instanceof PsiContinueStatement)) {
|
||||
!((GoToInstruction) instructions.get(endOffset)).isReturn &&
|
||||
!(controlFlow.getElement(endOffset) instanceof PsiYieldStatement) &&
|
||||
!(controlFlow.getElement(endOffset) instanceof PsiBreakStatement) &&
|
||||
!(controlFlow.getElement(endOffset) instanceof PsiContinueStatement)) {
|
||||
endOffset = ((BranchingInstruction)instructions.get(endOffset)).offset;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Invert 'if' condition" "true-preview"
|
||||
class A {
|
||||
int test(int x, int y) {
|
||||
return switch (y) {
|
||||
default -> {
|
||||
if (x <= 10) {
|
||||
yield 21;
|
||||
}
|
||||
else {
|
||||
yield 11;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Invert 'if' condition" "true-preview"
|
||||
class A {
|
||||
int test(int x, int y) {
|
||||
return switch (y) {
|
||||
default -> {
|
||||
if (<caret>x > 10) {
|
||||
yield 11;
|
||||
}
|
||||
yield 21;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user