mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SingleStatementInBlockFix: fixed main element determination
This commit is contained in:
+3
-3
@@ -172,12 +172,12 @@ public class SingleStatementInBlockInspection extends BaseInspection {
|
||||
if (startElement instanceof PsiLoopStatement) {
|
||||
body = ((PsiLoopStatement)startElement).getBody();
|
||||
}
|
||||
else if (startParent instanceof PsiLoopStatement) {
|
||||
body = ((PsiLoopStatement)startParent).getBody();
|
||||
}
|
||||
else if (startElement instanceof PsiIfStatement) {
|
||||
body = ((PsiIfStatement)startElement).getThenBranch();
|
||||
}
|
||||
else if (startParent instanceof PsiLoopStatement) {
|
||||
body = ((PsiLoopStatement)startParent).getBody();
|
||||
}
|
||||
else if (startElement instanceof PsiKeyword) {
|
||||
assert startParent instanceof PsiIfStatement;
|
||||
PsiIfStatement ifStatement = (PsiIfStatement)startParent;
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class X {
|
||||
void f(int[] a) {
|
||||
for(int aa : a)
|
||||
if(aa <caret>> 0) System.out.println(
|
||||
aa
|
||||
);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class X {
|
||||
void f(int[] a) {
|
||||
for(int aa : a)
|
||||
if(aa <caret>> 0) {
|
||||
System.out.println(
|
||||
aa
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -38,6 +38,7 @@ public class SingleStatementInBlockFixTest extends IGQuickFixesTestCase {
|
||||
public void testIfWithLoop() { doTest("if"); }
|
||||
public void testIfWithLoop2() { doTest("else"); }
|
||||
public void testIfWithLoop3() { assertQuickfixNotAvailable(getMessage("else")); }
|
||||
public void testIfWithLoop4() { doTest("if"); }
|
||||
public void testElseWithLoop() { doTest("else"); }
|
||||
public void testTwoComments() { doTest("if"); }
|
||||
public void testIncompleteIf() { assertQuickfixNotAvailable(getMessage("for")); }
|
||||
|
||||
Reference in New Issue
Block a user