-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
Description
We recently added a note to the docs about calling visitors from other visitors:
What problem are you trying to solve?
Avoid folks calling incorrect (more specific) visit methods on visitors from another visitor.
What precondition(s) should be checked before applying this recipe?
We're inside a visitor, calling another visit method.
Describe the situation before applying the recipe
class SomeJavaVisitor extends JavaVisitor<ExecutionContext> {
@Override
public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
J m = super.visitMethodInvocation(method, ctx);
m = new OtherJavaVisitor().visitMethodInvocation(m, ctx);
return m;
}
}Describe the situation after applying the recipe
class SomeJavaVisitor extends JavaVisitor<ExecutionContext> {
@Override
public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
J m = super.visitMethodInvocation(method, ctx);
m = new OtherJavaVisitor().visit(m, ctx, getCursor().getParentTreeCursor());
return m;
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Recipes Wanted