@@ -2385,6 +2385,12 @@ protected void visitFormals(Optional<VariableTree> receiver, List<? extends Vari
23852385 if (!receiver .isPresent () && parameters .isEmpty ()) {
23862386 return ;
23872387 }
2388+ boolean isRecordParams = false ;
2389+ if (!parameters .isEmpty () && parameters .get (0 ) instanceof JCTree .JCVariableDecl ) {
2390+ JCTree .JCVariableDecl param = (JCTree .JCVariableDecl ) parameters .get (0 );
2391+ isRecordParams = (param .mods .flags & RECORD ) == RECORD ;
2392+ }
2393+
23882394 builder .open (ZERO );
23892395 boolean first = true ;
23902396 if (receiver .isPresent ()) {
@@ -2408,13 +2414,25 @@ protected void visitFormals(Optional<VariableTree> receiver, List<? extends Vari
24082414 if (!first ) {
24092415 builder .breakOp (" " );
24102416 }
2417+ BreakTag declarationAnnotationBreak = new BreakTag ();
2418+
2419+ if (isRecordParams && !first ) {
2420+ builder .blankLineWanted (BlankLineWanted .conditional (declarationAnnotationBreak ));
2421+ }
2422+
24112423 visitToDeclare (
24122424 DeclarationKind .PARAMETER ,
24132425 Direction .HORIZONTAL ,
24142426 parameter ,
24152427 /* initializer= */ Optional .empty (),
24162428 "=" ,
2417- i < parameters .size () - 1 ? Optional .of ("," ) : /* a= */ Optional .empty ());
2429+ i < parameters .size () - 1 ? Optional .of ("," ) : /* a= */ Optional .empty (),
2430+ Optional .of (declarationAnnotationBreak ));
2431+
2432+ // If this is a record parameter and not the last one, add a conditional blank line after
2433+ if (isRecordParams && i < parameters .size () - 1 ) {
2434+ builder .blankLineWanted (BlankLineWanted .conditional (declarationAnnotationBreak ));
2435+ }
24182436 first = false ;
24192437 }
24202438 builder .close ();
@@ -2584,6 +2602,17 @@ private void visitToDeclare(
25842602 Optional <ExpressionTree > initializer ,
25852603 String equals ,
25862604 Optional <String > trailing ) {
2605+ visitToDeclare (kind , annotationsDirection , node , initializer , equals , trailing , Optional .empty ());
2606+ }
2607+
2608+ private void visitToDeclare (
2609+ DeclarationKind kind ,
2610+ Direction annotationsDirection ,
2611+ VariableTree node ,
2612+ Optional <ExpressionTree > initializer ,
2613+ String equals ,
2614+ Optional <String > trailing ,
2615+ Optional <BreakTag > annotationBreakForRecords ) {
25872616 sync (node );
25882617 declareOne (
25892618 kind ,
@@ -2596,7 +2625,8 @@ private void visitToDeclare(
25962625 initializer ,
25972626 trailing ,
25982627 /* receiverExpression= */ Optional .empty (),
2599- /* typeWithDims= */ Optional .empty ());
2628+ /* typeWithDims= */ Optional .empty (),
2629+ annotationBreakForRecords );
26002630 }
26012631
26022632 /** Does not omit the leading '<', which should be associated with the type name. */
@@ -3400,9 +3430,39 @@ int declareOne(
34003430 Optional <String > trailing ,
34013431 Optional <ExpressionTree > receiverExpression ,
34023432 Optional <TypeWithDims > typeWithDims ) {
3433+ return declareOne (
3434+ kind ,
3435+ annotationsDirection ,
3436+ modifiers ,
3437+ type ,
3438+ name ,
3439+ op ,
3440+ equals ,
3441+ initializer ,
3442+ trailing ,
3443+ receiverExpression ,
3444+ typeWithDims ,
3445+ Optional .empty ());
3446+ }
3447+
3448+ /** Declare one variable or variable-like thing. */
3449+ @ SuppressWarnings ("TooManyArguments" )
3450+ int declareOne (
3451+ DeclarationKind kind ,
3452+ Direction annotationsDirection ,
3453+ Optional <ModifiersTree > modifiers ,
3454+ Tree type ,
3455+ Name name ,
3456+ String op ,
3457+ String equals ,
3458+ Optional <ExpressionTree > initializer ,
3459+ Optional <String > trailing ,
3460+ Optional <ExpressionTree > receiverExpression ,
3461+ Optional <TypeWithDims > typeWithDims ,
3462+ Optional <BreakTag > verticalAnnotationBreakForRecords ) {
34033463
34043464 BreakTag typeBreak = new BreakTag ();
3405- BreakTag verticalAnnotationBreak = new BreakTag ( );
3465+ BreakTag verticalAnnotationBreak = verticalAnnotationBreakForRecords . orElseGet ( BreakTag :: new );
34063466
34073467 // If the node is a field declaration, try to output any declaration
34083468 // annotations in-line. If the entire declaration doesn't fit on a single
0 commit comments