-
Notifications
You must be signed in to change notification settings - Fork 354
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
Don't remove referenced annotations from record parameters #4474
base: main
Are you sure you want to change the base?
Conversation
Currently, the test fails with:
|
Thanks for getting this reduced and started @mvitz ! Looks like an oversight in the parser after the addition of records, which would then cause the annotation to not be parsed as such, but as "whitespace". The fix is then likely in ReloadableJava17ParserVisitor. |
Thanks for the hint. |
Hmm; thanks for diving in! It looks like the annotation is still present at this point in the parsing: rewrite/rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17Parser.java Lines 193 to 194 in a98d83d
But it's gone when we exit that |
Sorry, my fault. I added a more accurate testcase where the annotation contains |
Note to myself, if I change Lines 411 to 415 into
The assertion failure is still there, but now marks another non-whitespace:
Within After thinking during the night and checking some examples today annotations on records opens a rabbit hole. All the following are valid annotations for a record component:
However, in the generated class (after compilation) they appear on different locations:
Therefore, the first initial example with |
Thanks for the detailed look! Problems sure have a way of looking deceptively simple don't they? 🙃 |
What's changed?
What's your motivation?
RemoveUnusedImports
removes used imports for annotated method parameters #4473Anything in particular you'd like reviewers to focus on?
Anyone you would like to review specifically?
Have you considered any alternatives or workarounds?
Any additional context
Checklist