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
Make SuggestedFixes.updateAnnotationArgumentValues
JDK 17-compatible
#2820
Conversation
When running Java 17, `AnnotationTree#toString()` omits parentheses if the annotation tree does not contain any arguments. With this change `#updateAnnotationArgumentValues` no longer relies on the unconditional presence of such parentheses.
'@' | ||
+ annotation.getAnnotationType().toString() |
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.
More correct would be to do state.getSourceForNode(annotation.getAnnotationType())
, but this method currently does not accept a VisitorState
. Let me know if you'd like me to make this change; it appears that all callers do have a VisitorState
in scope. (Well, in the open source repository, at least.)
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 for the fix!
Adding passing in the VisitorState
as a parameter and using state.getSourceForNode(annotation.getAnnotationType())
SGTM if you want to make that change, but this is a clear improvement as-is, so either way is OK with me.
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.
Alright, I added one more commit, though arguably the improvement is minimal. (But I can imagine that at some point TreeToString
is extended to cover non-BugChecker
classes, in which case this change would have to be made anyway.)
Tests indicate that this issue applies to JDK 12+. |
'@' | ||
+ annotation.getAnnotationType().toString() |
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 for the fix!
Adding passing in the VisitorState
as a parameter and using state.getSourceForNode(annotation.getAnnotationType())
SGTM if you want to make that change, but this is a clear improvement as-is, so either way is OK with me.
Sorry, I started merging the PR before your last commit, I'll import that separately |
When running Java 17,
AnnotationTree#toString()
omits parentheses ifthe annotation tree does not contain any arguments. With this change
#updateAnnotationArgumentValues
no longer relies on the unconditionalpresence of such parentheses.