palantir / palantir-java-format

A modern, lambda-friendly, 120 character Java formatter.
Apache License 2.0
427 stars 46 forks source link

Put annotations on record fields on their own lines #922

Open spartanhooah opened 1 year ago

spartanhooah commented 1 year ago

What happened?

Annotations on a record's fields are put on the same line as the field declaration (assuming there's room horizontally):

@Schema(description = "A request for a quote")
public record QuoteRequest(
        @Schema(description = "US state of the product being quoted", example = "TX")
                RegulatoryState regulatoryState,
        @Schema(description = "Reason for a quote", example = "New Business") String amendmentReason,
        @Schema(description = "Type of quote being requested", example = "NEW_BUSINESS") QuoteType quoteType,
        @Schema(description = "Date the quoted changes become active", example = "2023-06-25")
                LocalDate quoteEffectiveDate,
)

What did you want to happen?

Annotations go on their own lines as they would for POJO fields:

@Schema(description = "A request for a quote")
public record QuoteRequest(
        @Schema(description = "US state of the product being quoted", example = "TX")
        RegulatoryState regulatoryState,

        @Schema(description = "Reason for a quote", example = "New Business")
        String amendmentReason,

        @Schema(description = "Type of quote being requested", example = "NEW_BUSINESS")
        QuoteType quoteType,

        @Schema(description = "Date the quoted changes become active", example = "2023-06-25")
        LocalDate quoteEffectiveDate,
)
fuesec commented 8 months ago

imho a useful feature