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 Summary
Constructors Constructor Description TreeVisitor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract void
process(Node node)
Process the given node.void
visitBreadthFirst(Node node)
https://en.wikipedia.org/wiki/Breadth-first_searchvoid
visitDepthFirst(Node node)
Deprecated.As of release 3.1.0, replaced byvisitPreOrder(Node)
void
visitDirectChildren(Node node)
Performs a simple traversal over all nodes that have the passed node as their parent.void
visitLeavesFirst(Node node)
void
visitPostOrder(Node node)
Performs a post-order node traversal starting with a given node.void
visitPreOrder(Node node)
Performs a pre-order node traversal starting with a given node.
-
-
-
Method Detail
-
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
-
visitDepthFirst
@Deprecated public void visitDepthFirst(Node node)
Deprecated.As of release 3.1.0, replaced byvisitPreOrder(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
-
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.
-
-