Skip to content
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

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

thecoop
Copy link
Member

@thecoop thecoop commented Jan 18, 2024

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

@thecoop thecoop added >non-issue :Core/Infra/Core Core issues without another label :Delivery/Tooling Developer tooliing and automation labels Jan 18, 2024
@thecoop thecoop requested a review from a team as a code owner January 18, 2024 11:58
@elasticsearchmachine elasticsearchmachine added Team:Core/Infra Meta label for core/infra team v8.13.0 Team:Delivery Meta label for Delivery team labels Jan 18, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-delivery (Team:Delivery)

Copy link
Contributor

@mark-vieira mark-vieira left a 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?

@thecoop
Copy link
Member Author

thecoop commented Jan 18, 2024

Yeah, spotless doesn't care if there's one or two lines between class members.

@thecoop thecoop requested a review from rjernst January 23, 2024 15:07
Copy link
Member

@rjernst rjernst left a 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.

@thecoop
Copy link
Member Author

thecoop commented Jan 23, 2024

Yeah, this is really hacky, but it's the only way I could find to do it, and the initialization is covered by tests

@thecoop thecoop added the auto-backport Automatically create backport pull requests when merged label Jan 24, 2024
@thecoop thecoop merged commit fcffc0b into elastic:main Jan 24, 2024
@thecoop thecoop deleted the update-versions-newlines branch January 24, 2024 10:54
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.12 Commit could not be cherrypicked due to conflicts
7.17 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 104519

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged :Core/Infra/Core Core issues without another label :Delivery/Tooling Developer tooliing and automation >non-issue Team:Core/Infra Meta label for core/infra team Team:Delivery Meta label for Delivery team v7.17.18 v8.12.1 v8.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants