Top Description Constructors Methods
com.github.javaparser.ast.visitor

public abstract Class TreeVisitor

extends Object
Class Inheritance
Imports
com.github.javaparser.ast.Node, java.util.ArrayList, .LinkedList, .Queue

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

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract void
process(Node
The current node to process.
node
)

Process the given node.

public void
visitBreadthFirst(Node
the start node, and the first one that is passed to process(node).
node
)

https://en.wikipedia.org/wiki/Breadth-first_search

public void
visitDirectChildren(Node node)

Performs a simple traversal over all nodes that have the passed node as their parent.

public void
public void
visitPostOrder(Node
The node at which the traversal begins.
node
)

Performs a post-order node traversal starting with a given node.

public void
visitPreOrder(Node
The node at which the traversal begins.
node
)

Performs a pre-order node traversal starting with a given node.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

TreeVisitorback to summary
public TreeVisitor()

Method Detail

processback to summary
public abstract void process(Node node)

Process the given node.

Parameters
node:Node

The current node to process.

visitBreadthFirstback to summary
public void visitBreadthFirst(Node node)

https://en.wikipedia.org/wiki/Breadth-first_search

Parameters
node:Node

the start node, and the first one that is passed to process(node).

visitDirectChildrenback to summary
public void visitDirectChildren(Node node)

Performs a simple traversal over all nodes that have the passed node as their parent.

visitLeavesFirstback to summary
public void visitLeavesFirst(Node node)
visitPostOrderback to summary
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:Node

The node at which the traversal begins.

See Also
Post-order traversal
visitPreOrderback to summary
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:Node

The node at which the traversal begins.

See Also
Pre-order traversal