public class WalkListener extends java.lang.Object implements AstWalkListener
Modifier and Type | Field and Description |
---|---|
private BaseState |
base
State shared by all callbacks (across multiple different trees).
|
private Resolver |
resolver
Provides basic services to assist tree walkers (specific to the tree).
|
private TreeWalker |
walker
Walker to notify of events.
|
Constructor and Description |
---|
WalkListener(BaseState base,
Resolver resolver,
TreeWalker walker)
Construct an instance with the given state which is common for a single
tree walk.
|
Modifier and Type | Method and Description |
---|---|
void |
ascent(Aast ast)
Called whenever a transition from a child node to its parent takes
place during an AST walk.
|
void |
descent(Aast ast)
Called whenever a transition from a parent node to its first child
takes place during an AST walk.
|
void |
nextChild(Aast ast,
int index)
Called whenever a transition from a child node to its next right
sibling takes place during an AST walk.
|
private WalkState |
prepareState(Aast here)
Setup the resolver and walk state for an event callback for a specific
node of the tree.
|
private final BaseState base
private final Resolver resolver
private final TreeWalker walker
public WalkListener(BaseState base, Resolver resolver, TreeWalker walker)
base
- State shared by all callbacks (across multiple different trees).resolver
- Provides basic services to assist tree walkers (specific to the
tree).walker
- Walker to notify of events.public void descent(Aast ast)
descent
in interface AstWalkListener
ast
- Source AST node which represents the parent in the parent to
child transition of the current AST walk.public void ascent(Aast ast)
ascent
in interface AstWalkListener
ast
- Source AST node which represents the parent in the child to
parent transition of the current AST walk.public void nextChild(Aast ast, int index)
This method is not invoked after the last child is visited,
as this is the purpose of the ascent(com.goldencode.ast.Aast)
method.
nextChild
in interface AstWalkListener
ast
- Source AST node which represents the parent of the children
between which the lateral transition is taking place in the
current AST walk.index
- The 0-based index of the child which is about to be processed.