mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
IDEA-55147 Provide new formatting option - 'align subsequent variable declarations in columns'
Corresponding test is added
This commit is contained in:
@@ -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" +
|
||||
"}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user