-
Notifications
You must be signed in to change notification settings - Fork 461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
formatAnnotations merges type and non-type annotations in records #2336
Comments
I think this can be fixed simply by only stripping newlines from type-annotations. I will work on a patch for this. |
This is a breaking change that makes me nervous. If you can gate it behind a flag, then I can easily merge. If you can't, we need to consider the impact to existing users a bit. @mernst any thoughts? |
Sounds reasonable. |
I have had another look, and the code actually does the right thing. That is, assuming the input does not mix non-type and type annotations on the same line: record FormatAnnotationsTest(
@JsonbProperty("r0")
@Valid
@Nullable
Object r0,
@JsonbProperty("r1") @Valid
@Nullable
Object r1,
@JsonbProperty("r2") @Valid @Nullable Object r2,
@Valid
@Nullable
String r3) {
} The r0+r3 are formatted correctly with the current implementation. r1+r2 is what I want to fix. The existing code handles (explicitly) annotations split with newlines (and whitespace). The above problems (r1+r2) are of another type; there is not the nice EOL/whitespace markers to guide changes. So I expect to run into problems with formatting of method arguments. I will add some more tests and see where it leads me. |
I find that FormatAnnotationsStep works OK with annotations on fields/getters that follow the form mentioned in this note.
But I have started using records in my project and have code like this:
The above is the formatAnnotations() output.
But it should (if I understand things correctly) be:
But since there is no protection keyword (public/private) to separate the non-type annotations from the type-annotations, they all get merged into the same line by FormatAnnotationsStep.
This is observed with version Gradle Plugin v7.0.0.BETA4
The text was updated successfully, but these errors were encountered: