Skip to content

Commit

Permalink
Don't explicitly instantiate AutoFormatVisitor
Browse files Browse the repository at this point in the history
Instead use `autoFormat()` or `maybeAutoFormat()` which will delegate to the appropriate implementation (e.g. for Kotlin).
  • Loading branch information
knutwannheden committed Oct 18, 2023
1 parent 2e11d90 commit 212f9a1
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.openrewrite.java.JavaVisitor;
import org.openrewrite.java.MethodMatcher;
import org.openrewrite.java.UnwrapParentheses;
import org.openrewrite.java.format.AutoFormatVisitor;
import org.openrewrite.java.tree.*;

import java.util.Collections;
Expand Down Expand Up @@ -125,8 +124,8 @@ public J visitBinary(J.Binary binary, ExecutionContext ctx) {
@Override
public J postVisit(J tree, ExecutionContext ctx) {
J j = super.postVisit(tree, ctx);
if (getCursor().pollMessage(MAYBE_AUTO_FORMAT_ME) != null) {
j = new AutoFormatVisitor<>().visit(j, ctx, getCursor().getParentOrThrow());
if (j != null && getCursor().pollMessage(MAYBE_AUTO_FORMAT_ME) != null) {
j = autoFormat(j, ctx);
}
return j;
}
Expand Down

0 comments on commit 212f9a1

Please sign in to comment.