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, Reportable
    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()
      • getTextRegion

        public TextRegion getTextRegion()
        Description copied from interface: Node
        Returns a region of text delimiting the node in the underlying text document. This does not necessarily match the report location.
        Specified by:
        getTextRegion in interface Node
      • getEndLine

        public int getEndLine()
        Description copied from interface: Reportable
        Gets the line where the token's region ends
        Specified by:
        getEndLine in interface Node
        Specified by:
        getEndLine in interface Reportable
      • getBeginColumn

        public int getBeginColumn()
        Description copied from interface: Reportable
        Gets the column offset from the start of the begin line where the token's region begins
        Specified by:
        getBeginColumn in interface Node
        Specified by:
        getBeginColumn in interface Reportable
      • getEndColumn

        public int getEndColumn()
        Description copied from interface: Reportable
        Gets the column offset from the start of the end line where the token's region ends
        Specified by:
        getEndColumn in interface Node
        Specified by:
        getEndColumn in interface Reportable
      • 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()