Class ProxyParseTreeListener
java.lang.Object
io.github.douira.glsl_transformer.traversal.ProxyParseTreeListener
- All Implemented Interfaces:
PartialParseTreeListener,ParseTreeListener
This class was taken from here
and was added to the public domain by the author DaveJarvis.
Instances of this class allow multiple listeners to receive events while
walking the parse tree. For example:
ProxyParseTreeListener proxy = new ProxyParseTreeListener(); ParseTreeListener listener1 = ... ; ParseTreeListener listener2 = ... ; proxy.add(listener1); proxy.add(listener2); ParseTreeWalker.DEFAULT.walk(proxy, ctx);
-
Constructor Summary
ConstructorsConstructorDescriptionProxyParseTreeListener(Collection<PartialParseTreeListener> listeners) Creates a new proxy with the given list of listeners. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(PartialParseTreeListener listener) Adds the given listener to the list of event notification recipients.voidvoidbooleanisDeepEnough(ExtendedContext node) Returns if this parse tree listener wants to continue to walk the tree but not go any deeper into the current (given) rule.booleanisEmpty()Checks if the list of listeners is empty.booleanReturns if this parse tree listener is no longer interested in walking the tree.booleanremove(PartialParseTreeListener listener) Removes the given listener to the list of event notification recipients.voidRemoves the listener last processed during iteration from the list of listeners.voidsetListeners(Collection<PartialParseTreeListener> listeners) Changes the list of listeners to receive events.voidvisitErrorNode(ErrorNode node) voidvisitTerminal(TerminalNode node)
-
Constructor Details
-
ProxyParseTreeListener
Creates a new proxy with the given list of listeners.- Parameters:
listeners- A list of listeners to receive events.
-
-
Method Details
-
add
Adds the given listener to the list of event notification recipients.- Parameters:
listener- A listener to begin receiving events.
-
remove
Removes the given listener to the list of event notification recipients.- Parameters:
listener- A listener to stop receiving events.- Returns:
- false The listener was not registered to receive events.
-
setListeners
Changes the list of listeners to receive events. If the given list of listeners is null, an empty list will be created.- Parameters:
listeners- A list of listeners to receive tree walking events.
-
isEmpty
public boolean isEmpty()Checks if the list of listeners is empty.- Returns:
trueif the list of listeners is empty
-
removeCurrentListener
public void removeCurrentListener()Removes the listener last processed during iteration from the list of listeners. This is used by the execution planner to remove nodes that are finished with walking. -
isDeepEnough
Description copied from interface:PartialParseTreeListenerReturns if this parse tree listener wants to continue to walk the tree but not go any deeper into the current (given) rule.- Specified by:
isDeepEnoughin interfacePartialParseTreeListener- Parameters:
node- The current node in which to maybe not visit the children- Returns:
trueif the parse tree walker
-
isFinished
public boolean isFinished()Description copied from interface:PartialParseTreeListenerReturns if this parse tree listener is no longer interested in walking the tree.- Specified by:
isFinishedin interfacePartialParseTreeListener- Returns:
trueif the parse tree walker should stop walking the tree entirely.
-
enterEveryRule
- Specified by:
enterEveryRulein interfaceParseTreeListener
-
exitEveryRule
- Specified by:
exitEveryRulein interfaceParseTreeListener
-
visitErrorNode
- Specified by:
visitErrorNodein interfaceParseTreeListener
-
visitTerminal
- Specified by:
visitTerminalin interfaceParseTreeListener
-