Formatting: wrapping and alignment in resource list

This commit is contained in:
Roman Shevchenko
2011-03-14 20:00:36 +01:00
parent 633395c95e
commit 11edb7829f
10 changed files with 88 additions and 33 deletions
@@ -273,4 +273,20 @@ public class JavaFormatterAlignmentTest extends AbstractJavaFormatterTest {
"}"
);
}
public void testAlignResourceList() throws Exception {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().ALIGN_MULTILINE_RESOURCES = true;
doMethodTest("try (MyResource r1 = null;\n" +
"MyResource r2 = null) { }",
"try (MyResource r1 = null;\n" +
" MyResource r2 = null) { }");
getSettings().ALIGN_MULTILINE_RESOURCES = false;
doMethodTest("try (MyResource r1 = null;\n" +
"MyResource r2 = null) { }",
"try (MyResource r1 = null;\n" +
" MyResource r2 = null) { }");
}
}
@@ -337,7 +337,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
getSettings().SPACE_BEFORE_SEMICOLON = false;
getSettings().SPACE_AFTER_SEMICOLON = true;
doMethodTest("try (R r1 = null ; R r2 = null;) { }",
"try (R r1 = null; R r2 = null; ) { }");
"try (R r1 = null; R r2 = null;) { }");
getSettings().SPACE_BEFORE_SEMICOLON = true;
getSettings().SPACE_AFTER_SEMICOLON = false;
@@ -266,4 +266,21 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
"@NotNull Comparable<String>"
);
}
public void testResourceListWrap() throws Exception {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().RIGHT_MARGIN = 40;
getSettings().RESOURCE_LIST_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
doMethodTest("try (MyResource r1 = null; MyResource r2 = null) { }",
"try (MyResource r1 = null;\n" +
" MyResource r2 = null) { }");
getSettings().RESOURCE_LIST_LPAREN_ON_NEXT_LINE = true;
getSettings().RESOURCE_LIST_RPAREN_ON_NEXT_LINE = true;
doMethodTest("try (MyResource r1 = null; MyResource r2 = null) { }",
"try (\n" +
" MyResource r1 = null;\n" +
" MyResource r2 = null\n" +
") { }");
}
}