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

update formatter to handle record closing braces correctly #8076

Closed
wants to merge 6 commits into from

Conversation

homberghp
Copy link

#7043 is still open, due to lacking tests.
Here is the test.

homberghp and others added 5 commits December 19, 2024 13:38
to show the effect of propery spaceswithinMethodDeclaration on record.
See issue apache#7043.

moved Sample spaces from bundle to text block.

To show effect of apache#7043.

added test RecordFormattingTest to show problem  \apache#7043

There are two tests in the test class, one that passws with the spaceWithinMethodDeclParens
set to false, and one that fails when this is set to true.
solves missing space before closing RPAREN in record.
Indetantion of the closing brace of a record was off and dependent of
preference spaceWithinMethodDeclParens.
fixed in
Java Source Base/org.netbeans.modules.java.source.save.Reformatter.
Tests added in file
org.netbeans.modules.java.source.save.RecordFormattingTest
@homberghp
Copy link
Author

Added solution to the problem.

This solves #7043

@mbien mbien added the Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) label Dec 27, 2024
@mbien mbien linked an issue Dec 27, 2024 that may be closed by this pull request
@mbien mbien added the ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) label Dec 27, 2024
Copy link
Member

@mbien mbien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @homberghp, first of all: thanks for working on this and contributing the fix for the bug you found.

If I see this correctly, the changeset (outside of the tests) are about 2 lines, rest are whitespace changes. We usually try to avoid making unrelated changes when fixing bugs.

Please update the changes to only those lines which matter for the fix - feel free to squash and force push into this PR.

Comment on lines +339 to +340
// copied from Bundle.properties for easier maintanance
static String sampleSpaces ="""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't inline message bundle values, I suppose this was only done for debugging purposes? Changes to this file should be dropped IMO.

Comment on lines +134 to +135
System.err.println("golden length = " + golden.trim().length());
System.err.println("content length = " + content.trim().length());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no println in tests please. We have hours of tests and have to keep the output manageable

@mbien mbien changed the title Added test for #7043 update formatter to handle record closing braces correctly Dec 27, 2024
@homberghp
Copy link
Author

@mbien: thank you for the time spent reviewing my pull request.

I will close this pull request and create a new one, based on your suggestions.
That is easier than applying all kinds of git magic.

@homberghp homberghp closed this Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reformat of record wrongly indents closing brace
2 participants