Class AbstractJjtreeNode<B extends AbstractJjtreeNode<B,N>,N extends JjtreeNode<N>>
java.lang.Object
net.sourceforge.pmd.lang.ast.impl.AbstractNode<B,N>
net.sourceforge.pmd.lang.ast.impl.javacc.AbstractJjtreeNode<B,N>
- All Implemented Interfaces:
GenericNode<N>,JjtreeNode<N>,Node,TextAvailableNode,Reportable
public abstract class AbstractJjtreeNode<B extends AbstractJjtreeNode<B,N>,N extends JjtreeNode<N>>
extends AbstractNode<B,N>
implements JjtreeNode<N>
Base class for node produced by JJTree. JJTree specific functionality
present on the API of
Node and AbstractNode has been
moved here for 7.0.0 (e.g. jjtClose methods).-
Field Summary
FieldsFields inherited from interface net.sourceforge.pmd.lang.ast.Node
COORDS_COMPARATOR -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractJjtreeNode(int id) The id is an index in the constant names array generated by jjtree, it must be set to some value that depends on the node type, not some arbitrary "1" or "2", and not necessarily a unique value. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidSet the child at the given index to the given node.final intcompareLocation(Node other) Compare the coordinates of this node with the other one as if withNode.COORDS_COMPARATOR.protected voidenlargeLeft(JavaccToken childFst) protected voidfitTokensToChildren(int index) Ensures that the first (resp. last) token of this node is before (resp. after) the first (resp. last) token of the child at the given index.getImage()Returns a string token, usually filled-in by the parser, which describes some textual characteristic of this node.final TextRegionReturns a region of text delimiting the node in the underlying text document.protected voidinsertChild(B child, int index) Insert a child at the given index, shifting all the following children to the right.protected voidjjtClose()This method is called after all the child nodes have been added.protected voidjjtOpen()This method is called after the node has been made the current node.protected voidsetFirstToken(JavaccToken token) protected voidprotected voidsetLastToken(JavaccToken token) toString()This toString implementation is only meant for debugging purposes.Methods inherited from class net.sourceforge.pmd.lang.ast.impl.AbstractNode
children, firstChild, getChild, getIndexInParent, getNumChildren, getParent, getUserMap, remove, removeChildAtIndex, setChild, setParentMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.sourceforge.pmd.lang.ast.impl.GenericNode
ancestors, ancestorsOrSelf, asStream, children, descendants, descendantsOrSelf, getChild, getFirstChild, getLastChild, getNextSibling, getParent, getPreviousSiblingMethods inherited from interface net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeNode
tokensMethods inherited from interface net.sourceforge.pmd.lang.ast.Node
acceptVisitor, ancestors, children, descendants, firstChild, getAstInfo, getBeginColumn, getBeginLine, getEndColumn, getEndLine, getIndexInParent, getLanguageVersion, getNumChildren, getReportLocation, getRoot, getTextDocument, getUserMap, getXPathAttributesIterator, getXPathNodeName, hasImageEqualTo, isFindBoundaryMethods inherited from interface net.sourceforge.pmd.lang.ast.TextAvailableNode
getOriginalText, getText
-
Field Details
-
id
protected final int id
-
-
Constructor Details
-
AbstractJjtreeNode
protected AbstractJjtreeNode(int id) The id is an index in the constant names array generated by jjtree, it must be set to some value that depends on the node type, not some arbitrary "1" or "2", and not necessarily a unique value.
-
-
Method Details
-
getImage
Description copied from interface:NodeReturns a string token, usually filled-in by the parser, which describes some textual characteristic of this node. This is usually an identifier, but you should check that using the Designer. On most nodes though, this method returnsnull.Note: This method will be deprecated in the future (#4787). It will be replaced with methods that have more specific names in node classes. In some cases, there are already alternatives available that should be used.
-
setImage
-
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- Specified by:
getTextRegionin interfaceTextAvailableNode
-
compareLocation
Description copied from interface:NodeCompare the coordinates of this node with the other one as if withNode.COORDS_COMPARATOR. The result is useless if both nodes are not from the same tree.- Specified by:
compareLocationin interfaceNode- Parameters:
other- Other node- Returns:
- A positive integer if this node comes AFTER the other, 0 if they have the same position, a negative integer if this node comes BEFORE the other
-
jjtOpen
protected void jjtOpen()This method is called after the node has been made the current node. It indicates that child nodes can now be added to it. -
jjtClose
protected void jjtClose()This method is called after all the child nodes have been added. -
addChild
Description copied from class:AbstractNodeSet the child at the given index to the given node. This resizes the children array to be able to contain the given index. Implementations must take care that this does not leave any "holes" in the array. This method throws if there is already a child at the given index.Note that it is more efficient to add children in reverse (from right to left), because the array is resized only the first time.
This method also calls
AbstractNode.setParent(AbstractNode).- Overrides:
addChildin classAbstractNode<B extends AbstractJjtreeNode<B,N>, N extends JjtreeNode<N>> - Parameters:
child- The child to addindex- The index to which the child will be added
-
insertChild
Description copied from class:AbstractNodeInsert a child at the given index, shifting all the following children to the right.- Overrides:
insertChildin classAbstractNode<B extends AbstractJjtreeNode<B,N>, N extends JjtreeNode<N>> - Parameters:
child- New childindex- Index (must be0 <= index <= getNumChildren()), i.e. you cannot insert a node beyond the end, because that would leave holes in the array
-
fitTokensToChildren
protected void fitTokensToChildren(int index) Ensures that the first (resp. last) token of this node is before (resp. after) the first (resp. last) token of the child at the given index. The index -
enlargeLeft
-
getFirstToken
- Specified by:
getFirstTokenin interfaceJjtreeNode<B extends AbstractJjtreeNode<B,N>>
-
getLastToken
- Specified by:
getLastTokenin interfaceJjtreeNode<B extends AbstractJjtreeNode<B,N>>
-
setLastToken
-
setFirstToken
-
toString
This toString implementation is only meant for debugging purposes.- Overrides:
toStringin classAbstractNode<B extends AbstractJjtreeNode<B,N>, N extends JjtreeNode<N>>
-