mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-144146 Auto completion for 'else' inserts braces.
This commit is contained in:
@@ -227,7 +227,7 @@ public class JavaKeywordCompletion {
|
||||
|
||||
if (psiElement().withText(";").withSuperParent(2, PsiIfStatement.class).accepts(prevLeaf) ||
|
||||
psiElement().withText("}").withSuperParent(3, PsiIfStatement.class).accepts(prevLeaf)) {
|
||||
variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.ELSE), TailTypes.SYNCHRONIZED_LPARENTH));
|
||||
variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.ELSE), TailType.HUMBLE_SPACE_BEFORE_WORD));
|
||||
}
|
||||
|
||||
if (psiElement().withText("}").withParent(psiElement(PsiCodeBlock.class).withParent(or(psiElement(PsiTryStatement.class), psiElement(PsiCatchSection.class)))).accepts(prevLeaf)) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
public class A {
|
||||
public void method() {
|
||||
if (true) { foo(); }
|
||||
<caret>
|
||||
el<caret>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
public class A {
|
||||
public void method() {
|
||||
if (true) { foo(); }
|
||||
else <caret>
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -76,8 +76,8 @@ public class KeywordCompletionTest extends LightCompletionTestCase {
|
||||
public void testMethodScope3() throws Exception { doTest(1, "final", "public", "static", "volatile", "abstract", "throws", "instanceof"); }
|
||||
public void testMethodScope4() throws Exception { doTest(6, "final", "try", "for", "while", "return", "throw"); }
|
||||
public void testMethodScope5() throws Exception { doTest(false); }
|
||||
public void testElseAfterSemicolon() throws Exception { doTest(1, "else"); }
|
||||
public void testElseAfterRBrace() throws Exception { doTest(1, "else"); }
|
||||
public void testElseAfterSemicolon() { doTest(1, "else"); }
|
||||
public void testElseAfterRBrace() { doTest(false); }
|
||||
public void testExtraBracketAfterFinally1() throws Exception { doTest(false); }
|
||||
public void testExtraBracketAfterFinally2() throws Exception { doTest(false); }
|
||||
public void testExtendsInCastTypeParameters() throws Exception { doTest(false); }
|
||||
@@ -137,7 +137,7 @@ public class KeywordCompletionTest extends LightCompletionTestCase {
|
||||
assertEquals("this", myItems[1].getLookupString());
|
||||
}
|
||||
|
||||
private void doTest(boolean select) throws Exception {
|
||||
private void doTest(boolean select) {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(true) + ".java");
|
||||
if (select) {
|
||||
selectItem(myItems[0]);
|
||||
|
||||
Reference in New Issue
Block a user