-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Ensure there's only one newline added with new version declarations #104519
Conversation
Pinging @elastic/es-core-infra (Team:Core/Infra) |
Pinging @elastic/es-delivery (Team:Delivery) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I presume running spotlessApply
after isn't enough since it preserves newlines?
Yeah, spotless doesn't care if there's one or two lines between class members. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a little fragile (as anything using setAccessible is), but it is only in the build code so any update only needs to apply to future versions of javaparser we pull in. If Mark is happy, I'm ok with it.
Yeah, this is really hacky, but it's the only way I could find to do it, and the initialization is covered by tests |
💔 Backport failed
You can use sqren/backport to manually backport by running |
JavaParser by default adds two newlines to new member declarations, when lexical preserving printing is used. This is defined in the ConcreteSyntaxModel default formatting, within a (private) static map for each declaration type.
This replaces the default CSM format for class declarations with our own, that is virtually identical apart from having only one newline after each member declaration, rather than two. This ensures that JavaParser maintains our existing formatting style when adding new version members to Version.java