IDEA-148214 After expanding indents restore only alignments which can be moved in the middle of line (isAllowBackwardShift == true)

This commit is contained in:
Yaroslav Lepenkin
2015-12-02 18:46:53 +03:00
parent ee83a5c47e
commit caa3770f0d
2 changed files with 33 additions and 1 deletions
@@ -126,6 +126,35 @@ public class JavaFormatterMultilineMethodCallParamsTest extends AbstractJavaForm
");\n"
);
}
public void testMethodBracketsAlignment() {
getSettings().ALIGN_MULTILINE_METHOD_BRACKETS = true;
doTextTest(
"public class Foo {\n" +
" private IntPredicate example1() {\n" +
" return Boo.combine(Boo.p1(),\n" +
" Boo.p2());\n" +
" }\n" +
" \n" +
" private boolean example2() {\n" +
" return IntStream.range(0, 4).allMatch(Boo.combine(Boo.p1(),\n" +
" Boo.p2()));\n" +
" }\n" +
"}",
"public class Foo {\n" +
" private IntPredicate example1() {\n" +
" return Boo.combine(Boo.p1(),\n" +
" Boo.p2());\n" +
" }\n" +
"\n" +
" private boolean example2() {\n" +
" return IntStream.range(0, 4).allMatch(Boo.combine(Boo.p1(),\n" +
" Boo.p2()));\n" +
" }\n" +
"}"
);
}
}
@@ -1650,7 +1650,10 @@ public class FormatProcessor {
private void restoreAlignments(MultiMap<Alignment, LeafBlockWrapper> blocks) {
for (Alignment alignment : blocks.keySet()) {
Set<LeafBlockWrapper> toRealign = ((AlignmentImpl)alignment).getOffsetResponsibleBlocks();
AlignmentImpl alignmentImpl = (AlignmentImpl)alignment;
if (!alignmentImpl.isAllowBackwardShift()) continue;
Set<LeafBlockWrapper> toRealign = alignmentImpl.getOffsetResponsibleBlocks();
arrangeSpaces(toRealign);
LeafBlockWrapper rightMostBlock = getRightMostBlock(toRealign);