@@ -541,7 +541,8 @@ public boolean visitArrayInitializer(List<? extends ExpressionTree> expressions)
541541
542542 builder .open (ZERO , BreakBehaviour .breakThisLevel (), LastLevelBreakability .ACCEPT_INLINE_CHAIN );
543543 builder .open (plusTwo , BreakBehaviour .breakThisLevel (), LastLevelBreakability .ACCEPT_INLINE_CHAIN );
544- tokenBreakTrailingComment ("{" , plusTwo );
544+ // Same as visitBlock: the break is already inside the plusTwo level, and this branch has elements.
545+ tokenBreakTrailingComment ("{" , ZERO );
545546 boolean hasTrailingComma = hasTrailingToken (builder .getInput (), expressions , "," );
546547 builder .breakOp (hasTrailingComma ? FillMode .FORCED : FillMode .UNIFIED , "" , ZERO );
547548 if (allowFilledElementsOnOwnLine ) {
@@ -2154,7 +2155,11 @@ protected void visitBlock(
21542155 } else {
21552156 builder .open (ZERO );
21562157 builder .open (plusTwo );
2157- tokenBreakTrailingComment ("{" , plusTwo );
2158+ // OpsBuilder.build puts a comment that trails "{" right after the token, inside the plusTwo level, so a
2159+ // non-empty block adds no indent of its own: the comment lines up with the statements, and a second run
2160+ // leaves it there. An empty block closes the level right after "{", and build moves the comment past that
2161+ // close, so it keeps plusTwo to sit inside the braces.
2162+ tokenBreakTrailingComment ("{" , node .getStatements ().isEmpty () ? plusTwo : ZERO );
21582163 if (allowLeadingBlankLine == AllowLeadingBlankLine .NO ) {
21592164 builder .blankLineWanted (BlankLineWanted .NO );
21602165 } else {
0 commit comments