Have UAnyOf#accept invoke TreeVisitor#visitOther#4899
Merged
copybara-service[bot] merged 1 commit intomasterfrom Mar 17, 2025
Merged
Have UAnyOf#accept invoke TreeVisitor#visitOther#4899copybara-service[bot] merged 1 commit intomasterfrom
UAnyOf#accept invoke TreeVisitor#visitOther#4899copybara-service[bot] merged 1 commit intomasterfrom
Conversation
c2e6efe to
06d64f2
Compare
In PicnicSupermarket/error-prone-support#261 we're developing an approach to speed up Refaster. The idea is to first index all identifiers referenced by Refaster `@BeforeTemplate`s and then use the identifiers found in a compilation unit under consideration to select the subset of Refaster rules that have a nonzero probability of matching. While working on this, we noticed that `UAnyOf#accept(TreeVisitor, Object)` descends only into the first expression passed to `Refaster#anyOf`. This PR proposes that `TreeVisitor#visitOther` is invoked instead. This allows the visitor to implement proper support for `UAnyOf` if desired. With this change, all public Error Prone unit tests still pass. We hope that this change is also compatible with Google-internal code. Naturally, we are open to alternatives that would allow visiting all `UAnyOf` subtrees. In the context of this same project, we have another question regarding some non-public types and methods of the Refaster implementation. Currently, we're using [reflection](https://github.com/PicnicSupermarket/error-prone-support/blob/9673572114e6d2652334877dabcc32e87da5e152/refaster-runner/src/main/java/tech/picnic/errorprone/refaster/runner/RefasterRuleSelector.java#L247) to access some of these. Ideally, we avoid this approach. Would you be open to increasing the visibility of certain types and methods? Fixes #4891 COPYBARA_INTEGRATE_REVIEW=#4891 from PicnicSupermarket:rossendrijver/refaster_uanyof ed2b5c7 PiperOrigin-RevId: 737594491
06d64f2 to
aee5101
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.
Have
UAnyOf#acceptinvokeTreeVisitor#visitOtherIn PicnicSupermarket/error-prone-support#261 we're developing an approach to speed up Refaster. The idea is to first index all identifiers referenced by Refaster
@BeforeTemplates and then use the identifiers found in a compilation unit under consideration to select the subset of Refaster rules that have a nonzero probability of matching.While working on this, we noticed that
UAnyOf#accept(TreeVisitor, Object)descends only into the first expression passed toRefaster#anyOf. This PR proposes thatTreeVisitor#visitOtheris invoked instead. This allows the visitor to implement proper support forUAnyOfif desired. With this change, all public Error Prone unit tests still pass. We hope that this change is also compatible with Google-internal code. Naturally, we are open to alternatives that would allow visiting allUAnyOfsubtrees.In the context of this same project, we have another question regarding some non-public types and methods of the Refaster implementation. Currently, we're using reflection to access some of these. Ideally, we avoid this approach. Would you be open to increasing the visibility of certain types and methods?
Fixes #4891
FUTURE_COPYBARA_INTEGRATE_REVIEW=#4891 from PicnicSupermarket:rossendrijver/refaster_uanyof ed2b5c7