Do not reformat parent code block on "complete current statement" action (IDEA-102479)

This commit is contained in:
Yaroslav Lepenkin
2015-08-11 14:31:30 +03:00
parent 29b0da3452
commit 8eea8eb13f
7 changed files with 23 additions and 12 deletions

View File

@@ -189,13 +189,7 @@ public class JavaSmartEnterProcessor extends SmartEnterProcessor {
return;
}
PsiElement parent = atCaret.getParent();
if (parent instanceof PsiCodeBlock) {
final PsiCodeBlock block = (PsiCodeBlock) parent;
if (block.getStatements().length > 0 && block.getStatements()[0] == atCaret) {
atCaret = block;
}
}
else if (parent instanceof PsiForStatement) {
if (parent instanceof PsiForStatement) {
atCaret = parent;
}

View File

@@ -1,8 +1,7 @@
class Foo {
abstract void a();
{
a();<caret>
a();
}
}

View File

@@ -1,8 +1,7 @@
class Foo {
abstract void a();
{
a();<caret>
a();
}
}

View File

@@ -1,6 +1,5 @@
class Foo {
boolean a;
{
if (a) {
} else {

View File

@@ -0,0 +1,9 @@
public class Test {
public void foo(int x) {
int a = 2<caret>
System.out.println("");
System.out.println("");
System.out.println("");
}
}

View File

@@ -0,0 +1,9 @@
public class Test {
public void foo(int x) {
int a = 2;
System.out.println("");
System.out.println("");
System.out.println("");
}
}

View File

@@ -67,6 +67,8 @@ public class CompleteStatementTest extends EditorActionTestCase {
}
}
public void testNoBlockReformat() { doTest(); }
public void testCompleteCatchWithExpression() throws Exception { doTest(); }
public void testCompleteCatchBody() throws Exception { doTest(); }