Class BaseAntlrNode<A extends BaseAntlrNode.AntlrToPmdParseTreeAdapter<N>,N extends AntlrNode<N>>
- java.lang.Object
-
- net.sourceforge.pmd.lang.ast.impl.antlr4.BaseAntlrNode<A,N>
-
- Type Parameters:
A
- Type of the underlying antlr nodeN
- 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 distinguishesParserRuleContext
for inner nodes,TerminalNode
for nodes that wrap tokens (and can have no children), andErrorNode
, a subtype ofTerminalNode
. These each have a base class here, which refines the type of the underlying antlr node:BaseAntlrInnerNode
,BaseAntlrTerminalNode
andBaseAntlrErrorNode
. 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
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
BaseAntlrNode.AntlrToPmdParseTreeAdapter<N extends AntlrNode<N>>
-
Field Summary
-
Fields inherited from interface net.sourceforge.pmd.lang.ast.Node
COORDS_COMPARATOR
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseAntlrNode()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract A
asAntlrNode()
int
getBeginColumn()
int
getBeginLine()
int
getEndColumn()
int
getEndLine()
abstract org.antlr.v4.runtime.Token
getFirstAntlrToken()
int
getIndexInParent()
Returns the index of this node in its parent's children.abstract org.antlr.v4.runtime.Token
getLastAntlrToken()
N
getParent()
Returns the parent of this node, or null if this is the root of the tree.TextRegion
getTextRegion()
Returns a region of text delimiting the node in the underlying text document.DataMap<DataMap.DataKey<?,?>>
getUserMap()
Returns a data map used to store additional information on this node.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.impl.GenericNode
ancestors, ancestorsOrSelf, asStream, children, descendants, descendantsOrSelf, getChild, getFirstChild, getLastChild, getNextSibling, getPreviousSibling
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.Node
acceptVisitor, ancestors, children, compareLocation, descendants, firstChild, getAstInfo, getImage, getLanguageVersion, getNumChildren, getReportLocation, getRoot, getTextDocument, getXPathAttributesIterator, getXPathNodeName, hasImageEqualTo, isFindBoundary
-
-
-
-
Method Detail
-
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 thereport location
.- Specified by:
getTextRegion
in interfaceNode
-
getParent
public N getParent()
Description copied from interface:Node
Returns the parent of this node, or null if this is the root of the tree.- Specified by:
getParent
in interfaceGenericNode<A extends BaseAntlrNode.AntlrToPmdParseTreeAdapter<N>>
- Specified by:
getParent
in interfaceNode
- Returns:
- The parent of this node
-
getBeginLine
public int getBeginLine()
- Specified by:
getBeginLine
in interfaceNode
-
getEndLine
public int getEndLine()
- Specified by:
getEndLine
in interfaceNode
-
getBeginColumn
public int getBeginColumn()
- Specified by:
getBeginColumn
in interfaceNode
-
getEndColumn
public int getEndColumn()
- Specified by:
getEndColumn
in interfaceNode
-
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 interfaceNode
- 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 interfaceNode
- Returns:
- The user data map of this node
-
asAntlrNode
protected abstract A asAntlrNode()
-
-