-
Notifications
You must be signed in to change notification settings - Fork 363
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
Map trailing commas as TrailingComma
Marker
, to fix J.Erroneous
issues seen
#4869
Conversation
Add an overload for `ReloadableJava17ParserVisitor#convert()` which allows supplying a `Markers` function, so that we can capture trailing commas using a `TrailingComma` marker and then also avoid the issue with the `J.Erroneous` getting constructed.
The last enum constant should only be right-padded if it has a trailing comma or semicolon. This is important because the whitespace after it belongs to the prefix of the next statement or the `J.Block#end`.
rewrite-test/src/main/java/org/openrewrite/test/TypeValidation.java
Outdated
Show resolved
Hide resolved
rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17ParserVisitor.java
Show resolved
Hide resolved
if (t != lastConstant) { | ||
return whitespace(); | ||
} |
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 if-block is actually not necessary, as we are here inside the suffix
function which is only ever applied to the last element.
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.
I agree but on the other hand it also guarantees that we don't accidentally do harm when it is called on an element that is not the last one
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.
Thanks a lot for the help here guys! Great to have this sorted before the release.
TrailingComma
Marker
, to fix J.Erroneous
issues seen
Fixes Trailing comma in an array end up in white-space #3997
Fixes Parsing issue: Trailing comma on enums is parsed into whitespace #3879
Related to Gradle parser fails with a trailing comma in method call #4614