IDEA-55147 Provide new formatting option - 'align subsequent variable declarations in columns'

Corresponding test is added
This commit is contained in:
Denis Zhdanov
2010-05-25 18:17:08 +04:00
parent f2df2991c6
commit 09077da76f

View File

@@ -99,11 +99,12 @@ public class JavaFormatterAlignmentTest extends AbstractJavaFormatterTest {
doTextTest(
"@SuppressWarnings({\"UseOfSystemOutOrSystemErr\", \"AssignmentToCollectionOrArrayFieldFromParameter\", \"ReturnOfCollectionOrArrayField\"})\n" +
"public class Some {\n" +
"}", "@SuppressWarnings({\"UseOfSystemOutOrSystemErr\",\n" +
" \"AssignmentToCollectionOrArrayFieldFromParameter\",\n" +
" \"ReturnOfCollectionOrArrayField\"})\n" +
"public class Some {\n" +
"}");
"}",
"@SuppressWarnings({\"UseOfSystemOutOrSystemErr\",\n" +
" \"AssignmentToCollectionOrArrayFieldFromParameter\",\n" +
" \"ReturnOfCollectionOrArrayField\"})\n" +
"public class Some {\n" +
"}");
}
public void testMethodBrackets() throws Exception {
@@ -136,4 +137,79 @@ public class JavaFormatterAlignmentTest extends AbstractJavaFormatterTest {
"}"
);
}
public void testVariableDeclarationAlignment() {
// Inspired by IDEA-55147
getSettings().ALIGN_MULTILINE_SUBSEQUENT_DECLARATIONS = true;
getSettings().FIELD_ANNOTATION_WRAP = CodeStyleSettings.DO_NOT_WRAP;
getSettings().VARIABLE_ANNOTATION_WRAP = CodeStyleSettings.DO_NOT_WRAP;
doTextTest(
"public class FormattingTest {\n" +
"\n" +
" int start = 1;\n" +
" double end = 2;\n" +
"\n" +
" int i2 = 1;\n" +
" double dd2,\n" +
" dd3 = 2;\n" +
"\n" +
" // asd\n" +
" char ccc3 = 'a';\n" +
" double ddd31, ddd32 = 1;\n" +
"\n" +
" private\n" +
" final String s4 = \"\";\n" +
" private\n" +
" transient int i4 = 1;\n" +
"\n" +
" private final String s5 = \"xxx\";\n" +
" private transient int iiii5 = 1;\n" +
" /*sdf*/\n" +
" @MyAnnotation(value = 1, text = 2) float f5 = 1;\n" +
"\n" +
" public void foo() {\n" +
" int start = 1;\n" +
" int start2 = 1;\n" +
" @NotNull int end = 2;\n" +
" @NotNull long longValue = 1;\n" +
" Serializable serializable;\n" +
" Object o;\n" +
" }\n" +
"}",
"public class FormattingTest {\n" +
"\n" +
" int start = 1;\n" +
" double end = 2;\n" +
"\n" +
" int i2 = 1;\n" +
" double dd2,\n" +
" dd3 = 2;\n" +
"\n" +
" // asd\n" +
" char ccc3 = 'a';\n" +
" double ddd31, ddd32 = 1;\n" +
"\n" +
" private\n" +
" final String s4 = \"\";\n" +
" private\n" +
" transient int i4 = 1;\n" +
"\n" +
" private final String s5 = \"xxx\";\n" +
" private transient int iiii5 = 1;\n" +
" /*sdf*/\n" +
" @MyAnnotation(value = 1, text = 2) float f5 = 1;\n" +
"\n" +
" public void foo() {\n" +
" int start = 1;\n" +
" int start2 = 1;\n" +
" @NotNull int end = 2;\n" +
" @NotNull long longValue = 1;\n" +
" Serializable serializable;\n" +
" Object o;\n" +
" }\n" +
"}"
);
}
}