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 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceBaseAntlrNode.AntlrToPmdParseTreeAdapter<N extends AntlrNode<N>> -
Field Summary
Fields inherited from interface net.sourceforge.pmd.lang.ast.Node
COORDS_COMPARATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Aintintintintabstract org.antlr.v4.runtime.TokenintReturns the index of this node in its parent's children.abstract org.antlr.v4.runtime.TokenReturns the parent of this node, or null if this is the root of the tree.Returns a region of text delimiting the node in the underlying text document.DataMap<DataMap.DataKey<?,?>> 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, waitMethods inherited from interface net.sourceforge.pmd.lang.ast.impl.GenericNode
ancestors, ancestorsOrSelf, asStream, children, descendants, descendantsOrSelf, getChild, getFirstChild, getLastChild, getNextSibling, getPreviousSiblingMethods 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
-
Constructor Details
-
BaseAntlrNode
protected BaseAntlrNode()
-
-
Method Details
-
getFirstAntlrToken
public abstract org.antlr.v4.runtime.Token getFirstAntlrToken() -
getLastAntlrToken
public abstract org.antlr.v4.runtime.Token getLastAntlrToken() -
getTextRegion
Description copied from interface:NodeReturns a region of text delimiting the node in the underlying text document. This does not necessarily match thereport location.- Specified by:
getTextRegionin interfaceNode
-
getParent
Description copied from interface:NodeReturns the parent of this node, or null if this is the root of the tree.- Specified by:
getParentin interfaceGenericNode<A extends BaseAntlrNode.AntlrToPmdParseTreeAdapter<N>>- Specified by:
getParentin interfaceNode- Returns:
- The parent of this node
-
getBeginLine
public int getBeginLine()- Specified by:
getBeginLinein interfaceNode
-
getEndLine
public int getEndLine()- Specified by:
getEndLinein interfaceNode
-
getBeginColumn
public int getBeginColumn()- Specified by:
getBeginColumnin interfaceNode
-
getEndColumn
public int getEndColumn()- Specified by:
getEndColumnin interfaceNode
-
getIndexInParent
public int getIndexInParent()Description copied from interface:NodeReturns the index of this node in its parent's children. If this node is a root node, returns -1.- Specified by:
getIndexInParentin interfaceNode- Returns:
- The index of this node in its parent's children
-
getUserMap
Description copied from interface:NodeReturns a data map used to store additional information on this node.- Specified by:
getUserMapin interfaceNode- Returns:
- The user data map of this node
-
asAntlrNode
-