Class ProxyParseTreeListener

java.lang.Object
io.github.douira.glsl_transformer.traversal.ProxyParseTreeListener
All Implemented Interfaces:
PartialParseTreeListener, ParseTreeListener

public class ProxyParseTreeListener extends Object implements PartialParseTreeListener
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 Details

    • ProxyParseTreeListener

      public ProxyParseTreeListener()
  • Method Details

    • add

      public void add(PartialParseTreeListener listener)
      Adds the given listener to the list of event notification recipients.
      Parameters:
      listener - A listener to begin receiving events.
    • needsWalk

      public boolean needsWalk()
      Returns if this listener even needs a tree walk. This is false if there are no listeners
      Returns:
      true if there are listeners
    • 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

      public boolean isDeepEnough(ExtendedContext node)
      Description copied from interface: PartialParseTreeListener
      Returns if this parse tree listener wants to continue to walk the tree but not go any deeper into the current (given) rule.
      Specified by:
      isDeepEnough in interface PartialParseTreeListener
      Parameters:
      node - The current node in which to maybe not visit the children
      Returns:
      true if the parse tree walker
    • isFinished

      public boolean isFinished()
      Description copied from interface: PartialParseTreeListener
      Returns if this parse tree listener is no longer interested in walking the tree.
      Specified by:
      isFinished in interface PartialParseTreeListener
      Returns:
      true if the parse tree walker should stop walking the tree entirely.
    • enterEveryRule

      public void enterEveryRule(ParserRuleContext ctx)
      Specified by:
      enterEveryRule in interface ParseTreeListener
    • exitEveryRule

      public void exitEveryRule(ParserRuleContext ctx)
      Specified by:
      exitEveryRule in interface ParseTreeListener
    • visitErrorNode

      public void visitErrorNode(ErrorNode node)
      Specified by:
      visitErrorNode in interface ParseTreeListener
    • visitTerminal

      public void visitTerminal(TerminalNode node)
      Specified by:
      visitTerminal in interface ParseTreeListener