Skip to content

Have UAnyOf#accept invoke TreeVisitor#visitOther#4899

Merged
copybara-service[bot] merged 1 commit intomasterfrom
test_736564508
Mar 17, 2025
Merged

Have UAnyOf#accept invoke TreeVisitor#visitOther#4899
copybara-service[bot] merged 1 commit intomasterfrom
test_736564508

Conversation

@copybara-service
Copy link
Copy Markdown
Contributor

Have UAnyOf#accept invoke TreeVisitor#visitOther

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 @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 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 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

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
@copybara-service copybara-service Bot merged commit aee5101 into master Mar 17, 2025
@copybara-service copybara-service Bot deleted the test_736564508 branch March 17, 2025 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant