Do not expand indents for group of blocks with smart indent, if each one of them has no linefeed before, and block going right after group has linefeed and has smaller indent than any new line children of any block in the group. This will prevent from inserting double continuation indents when it is not needed (see tests)

This commit is contained in:
Yaroslav Lepenkin
2015-09-21 14:43:30 +03:00
parent 78f3b1c5b6
commit 6159e94bdf
2 changed files with 63 additions and 4 deletions
@@ -29,7 +29,7 @@ public class JavaFormatterMultilineMethodCallParamsTest extends AbstractJavaForm
);
}
public void IGNORED_testChainedMethodInsideCall_WithRParenOnNewLine() {
public void testChainedMethodInsideCall_WithRParenOnNewLine() {
doMethodTest(
"call(new StringBuilder()\n" +
".append(\"aaa\")\n" +
@@ -41,6 +41,31 @@ public class JavaFormatterMultilineMethodCallParamsTest extends AbstractJavaForm
");"
);
}
public void testLambdas() {
doTextTest(
"public class Main {\n" +
" public static void main(String... args) throws Exception {\n" +
" RatpackServer.start(server -> server\n" +
" .handlers(chain -> chain\n" +
" .get(ctx -> ctx.render(\"Hello World!\"))\n" +
" .get(\":name\", ctx -> ctx.render(\"Hello \" + ctx.getPathTokens().get(\"name\") + \"!\"))\n" +
" )\n" +
" );\n" +
" }\n" +
"}",
"public class Main {\n" +
" public static void main(String... args) throws Exception {\n" +
" RatpackServer.start(server -> server\n" +
" .handlers(chain -> chain\n" +
" .get(ctx -> ctx.render(\"Hello World!\"))\n" +
" .get(\":name\", ctx -> ctx.render(\"Hello \" + ctx.getPathTokens().get(\"name\") + \"!\"))\n" +
" )\n" +
" );\n" +
" }\n" +
"}"
);
}
public void testChainedMethodInsideCall_Shifted() {
doMethodTest(