mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
[Java. Intention Actions] Fix invalid handling of statements with missing semicolon in Collapse into loop action
IDEA-357036 GitOrigin-RevId: 12972fe04b845c930f7aed33cdcd324d64d6c0c4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
dec45327f8
commit
29caccb845
@@ -273,6 +273,8 @@ public final class CollapseIntoLoopAction implements ModCommandAction {
|
||||
PsiElement parent = st.getParent();
|
||||
if (!(parent instanceof PsiCodeBlock)) return false;
|
||||
if (parent.getParent() instanceof PsiSwitchBlock) return false;
|
||||
PsiElement lastChild = st.getLastChild();
|
||||
if (lastChild instanceof PsiErrorElement) return false;
|
||||
return !ControlFlowUtils.statementContainsNakedBreak(st) && !ControlFlowUtils.statementContainsNakedContinue(st);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Collapse into loop" "true-preview"
|
||||
class A {
|
||||
String getPath() {
|
||||
Integer i = 0;
|
||||
for (int j = 1; j < 4; j++) {
|
||||
i = j;
|
||||
}
|
||||
i = ;
|
||||
return i.toString()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Collapse into loop" "false"
|
||||
class A {
|
||||
String getPath() {
|
||||
<caret>return "strange text getFixtureTestDataFolder() {
|
||||
return "/foo/bar";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Collapse into loop" "true-preview"
|
||||
class A {
|
||||
String getPath() {
|
||||
Integer i = 0;
|
||||
<caret>i = 1;
|
||||
i = 2;
|
||||
i = 3;
|
||||
i = ;
|
||||
return i.toString()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Collapse into loop" "false"
|
||||
class A {
|
||||
String getPath() {
|
||||
<selection>return "strange text getFixtureTestDataFolder() {
|
||||
return "/foo/bar";</selection>
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user