Class TreeVisitor

java.lang.Object
com.github.javaparser.ast.visitor.TreeVisitor

public abstract class TreeVisitor extends Object
Iterate over all the nodes in (a part of) the AST. In contrast to the visit methods in Node, these methods are implemented in a simple recursive way which should be more efficient. A disadvantage is that they cannot be quit in the middle of their traversal.
  • Constructor Details

    • TreeVisitor

      public TreeVisitor()
  • Method Details

    • visitLeavesFirst

      public void visitLeavesFirst(Node node)
    • visitPreOrder

      public void visitPreOrder(Node node)
      Performs a pre-order node traversal starting with a given node. When each node is visited, process(Node) is called for further processing.
      Parameters:
      node - The node at which the traversal begins.
      See Also:
      Pre-order traversal
    • visitPostOrder

      public void visitPostOrder(Node node)
      Performs a post-order node traversal starting with a given node. When each node is visited, process(Node) is called for further processing.
      Parameters:
      node - The node at which the traversal begins.
      See Also:
      Post-order traversal
    • visitBreadthFirst

      public void visitBreadthFirst(Node node)
      https://en.wikipedia.org/wiki/Breadth-first_search
      Parameters:
      node - the start node, and the first one that is passed to process(node).
    • process

      public abstract void process(Node node)
      Process the given node.
      Parameters:
      node - The current node to process.
    • visitDirectChildren

      public void visitDirectChildren(Node node)
      Performs a simple traversal over all nodes that have the passed node as their parent.