IDEA-25139: Proper caret placement for methods, if "next line" brace style is in use.

This commit is contained in:
Maxim Shafirov
2011-01-24 16:10:12 +03:00
parent f8e2733643
commit 1d80476b46
4 changed files with 26 additions and 1 deletions

View File

@@ -71,6 +71,10 @@ public class PlainEnterProcessor implements EnterProcessor {
else if (element instanceof PsiDoWhileStatement) {
body = ((PsiDoWhileStatement)element).getBody();
}
else if (element instanceof PsiMethod) {
PsiCodeBlock methodBody = ((PsiMethod)element).getBody();
if (methodBody != null) return methodBody;
}
return body instanceof PsiBlockStatement ? ((PsiBlockStatement)body).getCodeBlock() : null;
}

View File

@@ -0,0 +1,5 @@
class Foo {
@Test
public void testValueOf(<caret>)
}

View File

@@ -0,0 +1,8 @@
class Foo {
@Test
public void testValueOf()
{
<caret>
}
}

View File

@@ -184,7 +184,15 @@ public class CompleteStatementTest extends EditorActionTestCase {
public void testIDEADEV40479() throws Exception { doTest(); }
public void testIDEADEV13019() throws Exception {
public void testIDEADEV13019() throws Exception {
doTestBracesNextLineStyle();
}
public void testIDEA25139() throws Exception {
doTestBracesNextLineStyle();
}
private void doTestBracesNextLineStyle() throws Exception {
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
settings.BRACE_STYLE = CodeStyleSettings.NEXT_LINE;
settings.METHOD_BRACE_STYLE = CodeStyleSettings.NEXT_LINE;