@@ -2210,20 +2210,34 @@ protected List<Op> visitModifiers(
22102210 ModifiersTree modifiersTree ,
22112211 Direction annotationsDirection ,
22122212 Optional <BreakTag > declarationAnnotationBreak ) {
2213- return visitModifiers (modifiersTree .getAnnotations (), annotationsDirection , declarationAnnotationBreak );
2213+ boolean isRecordParameter = false ;
2214+ if (modifiersTree instanceof JCTree .JCModifiers ) {
2215+ isRecordParameter = (((JCTree .JCModifiers ) modifiersTree ).flags & RECORD ) == RECORD ;
2216+ }
2217+ return visitModifiers (
2218+ modifiersTree .getAnnotations (), annotationsDirection , declarationAnnotationBreak , isRecordParameter );
22142219 }
22152220
22162221 private List <Op > visitModifiers (
22172222 List <? extends AnnotationTree > annotationTrees ,
22182223 Direction annotationsDirection ,
22192224 Optional <BreakTag > declarationAnnotationBreak ) {
2225+ return visitModifiers (annotationTrees , annotationsDirection , declarationAnnotationBreak , false );
2226+ }
2227+
2228+ private List <Op > visitModifiers (
2229+ List <? extends AnnotationTree > annotationTrees ,
2230+ Direction annotationsDirection ,
2231+ Optional <BreakTag > declarationAnnotationBreak ,
2232+ boolean isRecordParameter ) {
22202233 if (annotationTrees .isEmpty () && !nextIsModifier ()) {
22212234 return EMPTY_LIST ;
22222235 }
22232236 Deque <AnnotationTree > annotations = new ArrayDeque <>(annotationTrees );
22242237 builder .open (ZERO );
22252238 boolean first = true ;
22262239 boolean lastWasAnnotation = false ;
2240+ boolean hasExplicitParameterizedAnnotation = false ;
22272241 while (!annotations .isEmpty ()) {
22282242 if (nextIsModifier ()) {
22292243 break ;
@@ -2234,14 +2248,22 @@ private List<Op> visitModifiers(
22342248 ? forceBreakList (declarationAnnotationBreak )
22352249 : breakList (declarationAnnotationBreak ));
22362250 }
2237- scan (annotations .removeFirst (), null );
2251+ AnnotationTree annotation = annotations .removeFirst ();
2252+ if (!annotation .getArguments ().isEmpty ()) {
2253+ ExpressionTree firstArg = annotation .getArguments ().get (0 );
2254+
2255+ // If it's an AssignmentTree, it's an explicit argument (name = value)
2256+ hasExplicitParameterizedAnnotation = firstArg instanceof AssignmentTree ;
2257+ }
2258+ scan (annotation , null );
22382259 first = false ;
22392260 lastWasAnnotation = true ;
22402261 }
22412262 builder .close ();
2242- ImmutableList <Op > trailingBreak = annotationsDirection .isVertical ()
2243- ? forceBreakList (declarationAnnotationBreak )
2244- : breakList (declarationAnnotationBreak );
2263+ ImmutableList <Op > trailingBreak =
2264+ annotationsDirection .isVertical () || (hasExplicitParameterizedAnnotation && isRecordParameter )
2265+ ? forceBreakList (declarationAnnotationBreak )
2266+ : breakList (declarationAnnotationBreak );
22452267 if (annotations .isEmpty () && !nextIsModifier ()) {
22462268 return trailingBreak ;
22472269 }
0 commit comments