mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
IDEA-169972 Smart Enter before else-if splits that else-if
This commit is contained in:
@@ -43,7 +43,7 @@ public class MissingIfBranchesFixer implements Fixer {
|
||||
}
|
||||
|
||||
private static void handleBranch(@NotNull Document doc, @NotNull PsiIfStatement ifStatement, @NotNull PsiElement beforeBranch, @Nullable PsiStatement branch) {
|
||||
if (branch instanceof PsiBlockStatement) return;
|
||||
if (branch instanceof PsiBlockStatement || beforeBranch.textMatches(PsiKeyword.ELSE) && branch instanceof PsiIfStatement) return;
|
||||
boolean transformingOneLiner = branch != null && (startLine(doc, beforeBranch) == startLine(doc, branch) ||
|
||||
startCol(doc, ifStatement) < startCol(doc, branch));
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class Foo {
|
||||
{
|
||||
if (a) <caret>
|
||||
else if (elsecond) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class Foo {
|
||||
{
|
||||
if (a) {
|
||||
<caret>
|
||||
} else if (elsecond) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,6 +123,8 @@ public class CompleteStatementTest extends EditorActionTestCase {
|
||||
|
||||
public void testElseIf() throws Exception { doTest(); }
|
||||
|
||||
public void testBlockBeforeElseIf() { doTest(); }
|
||||
|
||||
public void testIncompleteElseIf() throws Exception { doTest(); }
|
||||
|
||||
public void testField() throws Exception { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user