Skip to content

Commit aee5101

Browse files
rickieError Prone Team
authored and
Error Prone Team
committed
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 `@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
1 parent 8c476e7 commit aee5101

File tree

1 file changed

+1
-1
lines changed
  • core/src/main/java/com/google/errorprone/refaster

1 file changed

+1
-1
lines changed

core/src/main/java/com/google/errorprone/refaster/UAnyOf.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public JCExpression inline(Inliner inliner) throws CouldNotResolveImportExceptio
6464

6565
@Override
6666
public <R, D> R accept(TreeVisitor<R, D> visitor, D data) {
67-
return expressions().get(0).accept(visitor, data);
67+
return visitor.visitOther(this, data);
6868
}
6969

7070
@Override

0 commit comments

Comments
 (0)