diff --git a/rewrite-java/src/main/java/org/openrewrite/java/tree/J.java b/rewrite-java/src/main/java/org/openrewrite/java/tree/J.java index 4aea20dc7b5..1047f0b84eb 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/tree/J.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/tree/J.java @@ -1528,11 +1528,9 @@ public JavaType visit(@Nullable JavaType javaType, AtomicInteger n) { }; @Override - public @Nullable J visit(@Nullable Tree tree, AtomicInteger n) { - if (tree != null) { - n.incrementAndGet(); - } - return super.visit(tree, n); + public @Nullable J preVisit(J tree, AtomicInteger n) { + n.incrementAndGet(); + return tree; } @Override