Class TreeVisitingPrinter

java.lang.Object
org.openrewrite.TreeVisitor<org.openrewrite.Tree,org.openrewrite.ExecutionContext>
org.openrewrite.java.TreeVisitingPrinter

public class TreeVisitingPrinter extends org.openrewrite.TreeVisitor<org.openrewrite.Tree,org.openrewrite.ExecutionContext>
A visitor to print a tree visiting order and hierarchy in format like below.
 ----J.CompilationUnit
     |-------J.Import | "..."
     |       \---J.FieldAccess | "..."
     |           ...
     \---J.ClassDeclaration
         |---J.Identifier | "..."
         \---J.Block
              ...
 
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    TreeVisitingPrinter(boolean skipUnvisitedElement)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    printTree(org.openrewrite.Cursor cursor)
    print the entire LST tree with skip unvisited elements by given any cursor in this tree.
    static String
    printTree(org.openrewrite.Tree tree)
    print tree with skip unvisited elements
    static String
    printTreeAll(org.openrewrite.Cursor cursor)
    print entire tree including all unvisited elements by given any cursor in this tree.
    static String
    printTreeAll(org.openrewrite.Tree tree)
    print tree including all unvisited elements
    @Nullable org.openrewrite.Tree
    visit(@Nullable org.openrewrite.Tree tree, org.openrewrite.ExecutionContext ctx)
     

    Methods inherited from class org.openrewrite.TreeVisitor

    adapt, collect, collect, defaultValue, doAfterVisit, getAfterVisit, getCursor, getLanguage, isAcceptable, isAdaptableTo, noop, postVisit, preVisit, reduce, reduce, reduce, setCursor, stopAfterPreVisit, updateCursor, visit, visit, visitAndCast, visitAndCast, visitMarker, visitMarkers, visitNonNull, visitNonNull, visitorTreeType

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TreeVisitingPrinter

      protected TreeVisitingPrinter(boolean skipUnvisitedElement)
  • Method Details

    • printTree

      public static String printTree(org.openrewrite.Cursor cursor)
      print the entire LST tree with skip unvisited elements by given any cursor in this tree.
    • printTree

      public static String printTree(org.openrewrite.Tree tree)
      print tree with skip unvisited elements
    • printTreeAll

      public static String printTreeAll(org.openrewrite.Cursor cursor)
      print entire tree including all unvisited elements by given any cursor in this tree.
    • printTreeAll

      public static String printTreeAll(org.openrewrite.Tree tree)
      print tree including all unvisited elements
    • visit

      public @Nullable org.openrewrite.Tree visit(@Nullable org.openrewrite.Tree tree, org.openrewrite.ExecutionContext ctx)
      Overrides:
      visit in class org.openrewrite.TreeVisitor<org.openrewrite.Tree,org.openrewrite.ExecutionContext>