-
-
Notifications
You must be signed in to change notification settings - Fork 355
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
refactor: introduce ModifierTarget for better dealing with modifiers #4177
Conversation
Thanks a lot, that's super interesting. The overall concept LGTM and explicit metadata in enums is good. We need to javadoc and maybe better name What's the meaning of |
I agree, I'm not super happy with the name. Another idea for a name was As for now, only the AccTransient and AccVarArgs overlapped, so it was enough to distinguish between methods and everything else. The set of allowed modifiers for such target/conext is currently only used for the tests but it would be possible to add validation of which modifiers are accepted to the different implementations (e.g. throw an exception or just ignore it if someone tries to add the |
b735534
to
b3dc472
Compare
I rebased and resolved the conflicts. As I was surprised by #4205 myself, it might be even easier to support sealed classes correctly. I think this PR is the only blocker then for now. |
LGTM. I cannot find a better name. Let's javadoc |
I added some javadoc. The enum is currently package private and only used for the JDTTreeBuilder to avoid more boolean flags on the getModifiers method. We can make it public in future, probably making it a property of |
thanks, we fix the conflict and merge. |
Thanks a lot @SirYwell |
Previously, the getModifiers method had a
isMethod
boolean that was used to indicate that the modifiers are targetting a constructor or a method. Besides the vague naming, Java 17 introduces two new modifiers:sealed
andnon-sealed
. Both of them require more context because their bits are used in different contexts too:(this information was extracted with the
ModifierConstantsCollector
tool included in this PR).One way to deal with that would be to add another boolean flag
isType
to check against, but I think it's a little bit clearer to use an enum. That makes it more readable and more expressive (and also more future proof).I also added tests that help with implementing support for new modifiers.