Class TreeVisitor
java.lang.Object
com.github.javaparser.ast.visitor.TreeVisitor
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
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
Process the given node.void
visitBreadthFirst(Node node)
https://en.wikipedia.org/wiki/Breadth-first_searchvoid
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.
-
Constructor Details
-
TreeVisitor
public TreeVisitor()
-
-
Method Details
-
visitLeavesFirst
-
visitPreOrder
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
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
https://en.wikipedia.org/wiki/Breadth-first_search- Parameters:
node
- the start node, and the first one that is passed to process(node).
-
process
Process the given node.- Parameters:
node
- The current node to process.
-
visitDirectChildren
Performs a simple traversal over all nodes that have the passed node as their parent.
-