IDEA-144146 Auto completion for 'else' inserts braces.

This commit is contained in:
peter
2015-08-20 12:19:09 +02:00
parent 80d9a26586
commit d9a4fe148c
4 changed files with 11 additions and 5 deletions
@@ -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>
}
}
@@ -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]);