Fix parsing of unnamed patterns#1579
Open
mrjameshamilton wants to merge 2 commits intopalantir:developfrom
Open
Fix parsing of unnamed patterns#1579mrjameshamilton wants to merge 2 commits intopalantir:developfrom
mrjameshamilton wants to merge 2 commits intopalantir:developfrom
Conversation
Member
|
Thanks for your interest in palantir/palantir-java-format, @mrjameshamilton! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request. |
Generate changelog in
|
28bb365 to
d046436
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this PR
I came across FormatException of the form
error: expected token: '_'; generated ) insteadwhen using unnamed patterns, like the following (from the JEP):I resolved this by overriding
visitAnyPattern(AnyPatternTree node, Void unused)in the existingJava21InputAstVisitor.However,
AnyPatternTreeis annotated as a preview feature in Java 21 so I changed Java versions from 21 to 23.Before changing the version, I tried adding
--enable-previewbut then I got an error message that--enable-previewis not compatible with Java 11 source.I also noticed Java 23 mentioned in the root
build.gradleso I changed it to 23 rather than 22, 24, 25.One thing I found in this change was that
getImports()now returns aJCImportBase, so to ensure backwards compatibility I added aninstanceofcheck that (and module imports support would need to be implemented in the future).After this PR
==COMMIT_MSG==
Fix parsing of unnamed patterns
==COMMIT_MSG==
Possible downsides?
I'm not sure if changing Java versions from 21 to 23 (runtime in root build.gradle, target in
palantir-java-format-spi/build.gradleand target inpalantir-java-format/build.gradle) will have any negative effect? And if another solution should be found to resolve the issue.