Class BaseAntlrNode<A extends BaseAntlrNode.AntlrToPmdParseTreeAdapter<N>,​N extends AntlrNode<N>>

  • Type Parameters:
    A - Type of the underlying antlr node
    N - Public interface (eg SwiftNode)
    All Implemented Interfaces:
    AntlrNode<N>, GenericNode<N>, Node
    Direct Known Subclasses:
    BaseAntlrInnerNode, BaseAntlrTerminalNode

    public abstract class BaseAntlrNode<A extends BaseAntlrNode.AntlrToPmdParseTreeAdapter<N>,​N extends AntlrNode<N>>
    extends Object
    implements AntlrNode<N>
    Base class for an antlr node. This implements the PMD interfaces only, not the antlr ones. It wraps an antlr node (they are linked both ways). Antlr primarily distinguishes ParserRuleContext for inner nodes, TerminalNode for nodes that wrap tokens (and can have no children), and ErrorNode, a subtype of TerminalNode. These each have a base class here, which refines the type of the underlying antlr node: BaseAntlrInnerNode, BaseAntlrTerminalNode and BaseAntlrErrorNode. These must be implemented in each language module with a class that also implements <N>.

    During tree construction, the antlr runtime does its thing with the underlying antlr nodes. The PMD nodes are just wrappers around those, that respect the contract of GenericNode.

    • Constructor Detail

      • BaseAntlrNode

        protected BaseAntlrNode()
    • Method Detail

      • joinTokenText

        @Deprecated
        public String joinTokenText()
        Deprecated.
        Some rules depend on it and have not been rewritten
        Recurses over the text of all terminal descendants to build the text of this node (without spaces). This is extremely inefficient and should not be used to write rules. The antlr impl doesn't even use a single stringbuilder.
      • getFirstAntlrToken

        public abstract org.antlr.v4.runtime.Token getFirstAntlrToken()
      • getLastAntlrToken

        public abstract org.antlr.v4.runtime.Token getLastAntlrToken()
      • getBeginLine

        public int getBeginLine()
        Specified by:
        getBeginLine in interface Node
      • getEndLine

        public int getEndLine()
        Specified by:
        getEndLine in interface Node
      • getBeginColumn

        public int getBeginColumn()
        Specified by:
        getBeginColumn in interface Node
      • getEndColumn

        public int getEndColumn()
        Specified by:
        getEndColumn in interface Node
      • getIndexInParent

        public int getIndexInParent()
        Description copied from interface: Node
        Returns the index of this node in its parent's children. If this node is a root node, returns -1.
        Specified by:
        getIndexInParent in interface Node
        Returns:
        The index of this node in its parent's children
      • getUserMap

        public DataMap<DataMap.DataKey<?,​?>> getUserMap()
        Description copied from interface: Node
        Returns a data map used to store additional information on this node.
        Specified by:
        getUserMap in interface Node
        Returns:
        The user data map of this node
      • asAntlrNode

        protected abstract A asAntlrNode()