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 distinguishesParserRuleContextfor inner nodes,TerminalNodefor 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,BaseAntlrTerminalNodeandBaseAntlrErrorNode. 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 interfaceBaseAntlrNode.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 protectedBaseAntlrNode()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected abstract AasAntlrNode()intgetBeginColumn()Gets the column offset from the start of the begin line where the token's region beginsintgetBeginLine()Gets the line where the token's region beginsintgetEndColumn()Gets the column offset from the start of the end line where the token's region endsintgetEndLine()Gets the line where the token's region endsabstract org.antlr.v4.runtime.TokengetFirstAntlrToken()intgetIndexInParent()Returns the index of this node in its parent's children.abstract org.antlr.v4.runtime.TokengetLastAntlrToken()NgetParent()Returns the parent of this node, or null if this is the root of the tree.TextRegiongetTextRegion()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.StringjoinTokenText()Deprecated.Some rules depend on it and have not been rewritten-
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, getNthParent, getPreviousSibling
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.Node
acceptVisitor, ancestors, children, compareLocation, descendants, findChildNodesWithXPath, findChildrenOfType, findDescendantsOfType, findDescendantsOfType, firstChild, getAstInfo, getFirstChildOfType, getFirstDescendantOfType, getFirstParentOfType, getImage, getLanguageVersion, getNumChildren, getParentsOfType, getReportLocation, getRoot, getTextDocument, getXPathAttributesIterator, getXPathNodeName, hasDescendantOfType, hasImageEqualTo, isFindBoundary
-
-
-
-
Method Detail
-
joinTokenText
@Deprecated public String joinTokenText()
Deprecated.Some rules depend on it and have not been rewrittenRecurses 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: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
public N 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()
Description copied from interface:ReportableGets the line where the token's region begins- Specified by:
getBeginLinein interfaceNode- Specified by:
getBeginLinein interfaceReportable
-
getEndLine
public int getEndLine()
Description copied from interface:ReportableGets the line where the token's region ends- Specified by:
getEndLinein interfaceNode- Specified by:
getEndLinein interfaceReportable
-
getBeginColumn
public int getBeginColumn()
Description copied from interface:ReportableGets the column offset from the start of the begin line where the token's region begins- Specified by:
getBeginColumnin interfaceNode- Specified by:
getBeginColumnin interfaceReportable
-
getEndColumn
public int getEndColumn()
Description copied from interface:ReportableGets the column offset from the start of the end line where the token's region ends- Specified by:
getEndColumnin interfaceNode- Specified by:
getEndColumnin interfaceReportable
-
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
public DataMap<DataMap.DataKey<?,?>> 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
protected abstract A asAntlrNode()
-
-