public class TreeContext
extends Object
Holds the current AST node together with its traversal context.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
afterVisit(TreeContextAction action)Registers a handler to invoke after the node is visited. |
|
public void |
afterVisit(Closure<?> action)Registers a closure to invoke after the node is visited. |
|
public TreeContext |
fork(ASTNode node)Creates a child context for the supplied node. |
|
public ASTNode |
getNode()Returns the AST node represented by this context. |
|
public List<TreeContextAction> |
getOnPopHandlers()Returns handlers invoked when this context is popped. |
|
public TreeContext |
getParent()Returns the parent traversal context. |
|
public Expression |
getReplacement()Returns the replacement expression for this context. |
|
public List<TreeContext> |
getSiblings()Returns the child contexts created from this node. |
|
public Map<Object, List<Object>> |
getUserdata()Returns the user data attached to this context. |
|
public List<Object> |
getUserdata(Object key)Returns user data for the supplied key, searching parent contexts by default. |
|
public List<Object> |
getUserdata(Object key, boolean searchParent)Returns user data for the supplied key. |
|
public boolean |
matches(ASTNodePredicate predicate)Tests the current node with the supplied predicate. |
|
public boolean |
matches(Closure<Boolean> predicate)Tests the current node with the supplied closure predicate. |
|
public void |
putUserdata(Object key, Object value)Appends a user data value for the supplied key. |
|
public void |
setReplacement(Expression replacement)Replaces the current expression node when this context is popped. |
|
public String |
toString()Returns a string form containing the current node and its parent path. |
Registers a handler to invoke after the node is visited.
action - the handler to registerRegisters a closure to invoke after the node is visited.
action - the handler to registerCreates a child context for the supplied node.
node - the child nodeReturns the AST node represented by this context.
Returns handlers invoked when this context is popped.
Returns the parent traversal context.
nullReturns the replacement expression for this context.
nullReturns the child contexts created from this node.
Returns the user data attached to this context.
Returns user data for the supplied key, searching parent contexts by default.
key - the user data keynullReturns user data for the supplied key.
key - the user data keysearchParent - whether to search parent contextsnullTests the current node with the supplied predicate.
predicate - the predicate to applytrue if the predicate matchesTests the current node with the supplied closure predicate.
predicate - the predicate to applytrue if the predicate matchesAppends a user data value for the supplied key.
key - the user data keyvalue - the value to addReplaces the current expression node when this context is popped.
replacement - the replacement expressionReturns a string form containing the current node and its parent path.