net.sourceforge.pmd.lang.ast
Interface Node
- All Known Subinterfaces:
- AccessNode, DFAGraphMethod, EcmascriptNode<T>, ExecutableCode, JavaNode, JspNode, OracleObject, PLSQLNode, ScopedNode, TypeNode, VmNode, XmlNode
- All Known Implementing Classes:
- AbstractEcmascriptNode, AbstractInfixEcmascriptNode, AbstractJavaAccessNode, AbstractJavaAccessTypeNode, AbstractJavaNode, AbstractJavaTypeNode, AbstractJspNode, AbstractNode, AbstractPLSQLNode, AbstractVmNode, ASTAccessibleByClause, ASTAdditiveExpression, ASTAdditiveExpression, ASTAddNode, ASTAllocationExpression, ASTAlterTrigger, ASTAlterTypeSpec, ASTAndExpression, ASTAndNode, ASTAnnotation, ASTAnnotationMethodDeclaration, ASTAnnotationTypeBody, ASTAnnotationTypeDeclaration, ASTAnnotationTypeMemberDeclaration, ASTArgument, ASTArgumentList, ASTArgumentList, ASTArguments, ASTArguments, ASTArrayComprehension, ASTArrayComprehensionLoop, ASTArrayDimsAndInits, ASTArrayInitializer, ASTArrayLiteral, ASTAssertStatement, ASTAssignment, ASTAssignment, ASTAssignment, ASTAssignmentOperator, ASTAstRoot, ASTAttribute, ASTAttribute, ASTAttributeDeclaration, ASTAttributeValue, ASTBlock, ASTBlock, ASTBlock, ASTBlock, ASTBlockStatement, ASTBooleanLiteral, ASTBooleanLiteral, ASTBreakStatement, ASTBreakStatement, ASTCallSpecTail, ASTCaseExpression, ASTCaseStatement, ASTCaseWhenClause, ASTCastExpression, ASTCatchClause, ASTCatchStatement, ASTCData, ASTClassOrInterfaceBody, ASTClassOrInterfaceBodyDeclaration, ASTClassOrInterfaceDeclaration, ASTClassOrInterfaceType, ASTCloseStatement, ASTCollectionDeclaration, ASTCollectionTypeDefinition, ASTCollectionTypeName, ASTComment, ASTComment, ASTComment, ASTCommentTag, ASTCompilationDataType, ASTCompilationDeclarationFragment, ASTCompilationExpression, ASTCompilationUnit, ASTCompilationUnit, ASTCompoundTriggerBlock, ASTConditionalAndExpression, ASTConditionalAndExpression, ASTConditionalCompilationStatement, ASTConditionalExpression, ASTConditionalExpression, ASTConditionalOrExpression, ASTConditionalOrExpression, ASTConstructorDeclaration, ASTContent, ASTContinueStatement, ASTContinueStatement, ASTContinueStatement, ASTCursorBody, ASTCursorSpecification, ASTCursorUnit, ASTDatabaseEvent, ASTDatabaseLink, ASTDatatype, ASTDatatypeDeclaration, ASTDateTimeLiteral, ASTDDLCommand, ASTDDLEvent, ASTDeclaration, ASTDeclarativeSection, ASTDeclarativeUnit, ASTDefaultValue, ASTDirective, ASTDirectory, ASTDivNode, ASTDoctypeDeclaration, ASTDoctypeExternalId, ASTDoLoop, ASTDoStatement, ASTElement, ASTElementGet, ASTElExpression, ASTElseClause, ASTElseIfStatement, ASTElseStatement, ASTElsifClause, ASTEmbeddedSqlStatement, ASTEmptyExpression, ASTEmptyStatement, ASTEmptyStatement, ASTEnumBody, ASTEnumConstant, ASTEnumDeclaration, ASTEQNode, ASTEqualityExpression, ASTEqualityExpression, ASTEqualsOldIDNewID, ASTEscape, ASTEscapedDirective, ASTExceptionDeclaration, ASTExceptionHandler, ASTExclusiveOrExpression, ASTExitStatement, ASTExplicitConstructorInvocation, ASTExpression, ASTExpression, ASTExpression, ASTExpressionStatement, ASTExtendsList, ASTFalse, ASTFetchStatement, ASTFieldDeclaration, ASTFieldDeclaration, ASTFinallyStatement, ASTFloatingPointLiteral, ASTForAllIndex, ASTForAllStatement, ASTForeachStatement, ASTForIndex, ASTForInit, ASTForInLoop, ASTForLoop, ASTFormalParameter, ASTFormalParameter, ASTFormalParameters, ASTFormalParameters, ASTForStatement, ASTForStatement, ASTForUpdate, ASTFunctionCall, ASTFunctionNode, ASTGENode, ASTGlobal, ASTGotoStatement, ASTGTNode, ASTHtmlScript, ASTID, ASTIdentifier, ASTIfStatement, ASTIfStatement, ASTIfStatement, ASTIfStatement, ASTImplementsList, ASTImportDeclaration, ASTInclusiveOrExpression, ASTIndex, ASTInfixExpression, ASTInitializer, ASTInlinePragma, ASTInput, ASTInstanceOfExpression, ASTIntegerLiteral, ASTIntegerRange, ASTJavaInterfaceClass, ASTJspComment, ASTJspDeclaration, ASTJspDeclarations, ASTJspDirective, ASTJspDirectiveAttribute, ASTJspDocument, ASTJspExpression, ASTJspExpressionInAttribute, ASTJspScriptlet, ASTKEYWORD_RESERVED, ASTKEYWORD_UNRESERVED, ASTKeywordLiteral, ASTLabel, ASTLabel, ASTLabeledStatement, ASTLabeledStatement, ASTLabelledStatement, ASTLambdaExpression, ASTLENode, ASTLetNode, ASTLikeExpression, ASTLiteral, ASTLiteral, ASTLocalVariableDeclaration, ASTLoopStatement, ASTLTNode, ASTMap, ASTMarkerAnnotation, ASTMathNode, ASTMemberSelector, ASTMemberValue, ASTMemberValueArrayInitializer, ASTMemberValuePair, ASTMemberValuePairs, ASTMethod, ASTMethodDeclaration, ASTMethodDeclaration, ASTMethodDeclarator, ASTMethodDeclarator, ASTMethodReference, ASTModNode, ASTMulNode, ASTMultiplicativeExpression, ASTMultiplicativeExpression, ASTMultiSetCondition, ASTName, ASTName, ASTName, ASTNameList, ASTNENode, ASTNewExpression, ASTNonDMLEvent, ASTNonDMLTrigger, ASTNormalAnnotation, ASTNotNode, ASTNullLiteral, ASTNullLiteral, ASTNumberLiteral, ASTNumericLiteral, ASTObjectArray, ASTObjectDeclaration, ASTObjectExpression, ASTObjectLiteral, ASTObjectNameDeclaration, ASTObjectProperty, ASTOpenStatement, ASTOrNode, ASTPackageBody, ASTPackageDeclaration, ASTPackageSpecification, ASTParallelClause, ASTParenthesizedExpression, ASTPipelineStatement, ASTPostfixExpression, ASTPragma, ASTPragmaClause, ASTPreDecrementExpression, ASTPreIncrementExpression, ASTPrimaryExpression, ASTPrimaryExpression, ASTPrimaryPrefix, ASTPrimaryPrefix, ASTPrimarySuffix, ASTPrimarySuffix, ASTPrimitiveType, ASTprocess, ASTProgramUnit, ASTPropertyGet, ASTQualifiedID, ASTQualifiedName, ASTRaiseStatement, ASTRead2NextOccurrence, ASTReadPastNextOccurrence, ASTReference, ASTReferenceType, ASTRegExpLiteral, ASTRelationalExpression, ASTRelationalExpression, ASTResource, ASTResources, ASTResourceSpecification, ASTResultType, ASTReturnStatement, ASTReturnStatement, ASTReturnStatement, ASTRSIGNEDSHIFT, ASTRUNSIGNEDSHIFT, ASTScalarDataTypeName, ASTScope, ASTSetDirective, ASTShiftExpression, ASTSingleMemberAnnotation, ASTSkip2NextOccurrence, ASTSkip2NextTerminator, ASTSkip2NextTokenOccurrence, ASTSkipPastNextOccurrence, ASTSkipPastNextTokenOccurrence, ASTSqlPlusCommand, ASTSqlStatement, ASTStatement, ASTStatement, ASTStatementExpression, ASTStatementExpressionList, ASTStringExpression, ASTStringLiteral, ASTStringLiteral, ASTStringLiteral, ASTSubtractNode, ASTSubTypeDefinition, ASTSwitchCase, ASTSwitchLabel, ASTSwitchStatement, ASTSwitchStatement, ASTSynchronizedStatement, ASTSynonym, ASTTable, ASTTableColumn, ASTText, ASTText, ASTTextblock, ASTThrowStatement, ASTThrowStatement, ASTTriggerTimingPointSection, ASTTriggerUnit, ASTTrimExpression, ASTTrue, ASTTryStatement, ASTTryStatement, ASTType, ASTTypeArgument, ASTTypeArguments, ASTTypeBound, ASTTypeDeclaration, ASTTypeKeyword, ASTTypeMethod, ASTTypeParameter, ASTTypeParameters, ASTTypeSpecification, ASTUnaryExpression, ASTUnaryExpression, ASTUnaryExpression, ASTUnaryExpressionNotPlusMinus, ASTUnaryExpressionNotPlusMinus, ASTUnlabelledStatement, ASTUnparsedText, ASTUnqualifiedID, ASTValueBinding, ASTVariableDeclaration, ASTVariableDeclarator, ASTVariableDeclaratorId, ASTVariableInitializer, ASTVariableInitializer, ASTVariableOrConstantDeclaration, ASTVariableOrConstantDeclarator, ASTVariableOrConstantDeclaratorId, ASTVariableOrConstantInitializer, ASTView, ASTViewColumn, ASTWhileLoop, ASTWhileStatement, ASTWhileStatement, ASTWildcardBounds, ASTWithStatement, ASTWord, ASTWrappedObject, ASTXmlDotQuery, ASTXmlExpression, ASTXmlMemberGet, ASTXmlString, Comment, DummyJavaNode, FormalComment, JavadocElement, MultiLineComment, SingleLineComment
public interface Node
jjtOpen
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
void jjtClose()
- This method is called after all the child nodes have been
added.
jjtSetParent
void jjtSetParent(Node parent)
- This pair of methods are used to inform the node of its
parent.
jjtGetParent
Node jjtGetParent()
jjtAddChild
void jjtAddChild(Node child,
int index)
- This method tells the node to add its argument to the node's
list of children.
jjtSetChildIndex
void jjtSetChildIndex(int index)
- Sets the index of this node from the perspective of its parent.
This means: this.jjtGetParent().jjtGetChild(index) == this.
- Parameters:
index
- the child index
jjtGetChildIndex
int jjtGetChildIndex()
jjtGetChild
Node jjtGetChild(int index)
- This method returns a child node. The children are numbered
from zero, left to right.
- Parameters:
index
- the child index. Must be nonnegative and less than
jjtGetNumChildren()
.
jjtGetNumChildren
int jjtGetNumChildren()
- Return the number of children the node has.
jjtGetId
int jjtGetId()
getImage
String getImage()
setImage
void setImage(String image)
hasImageEqualTo
boolean hasImageEqualTo(String image)
getBeginLine
int getBeginLine()
getBeginColumn
int getBeginColumn()
getEndLine
int getEndLine()
getEndColumn
int getEndColumn()
getDataFlowNode
DataFlowNode getDataFlowNode()
setDataFlowNode
void setDataFlowNode(DataFlowNode dataFlowNode)
isFindBoundary
boolean isFindBoundary()
getNthParent
Node getNthParent(int n)
getFirstParentOfType
<T> T getFirstParentOfType(Class<T> parentType)
getParentsOfType
<T> List<T> getParentsOfType(Class<T> parentType)
findChildrenOfType
<T> List<T> findChildrenOfType(Class<T> childType)
- Traverses the children to find all the instances of type childType.
- Parameters:
childType
- class which you want to find.
- Returns:
- List of all children of type childType. Returns an empty list if none found.
- See Also:
if traversal of the entire tree is needed.
findDescendantsOfType
<T> List<T> findDescendantsOfType(Class<T> targetType)
- Traverses down the tree to find all the descendant instances of type descendantType.
- Parameters:
targetType
- class which you want to find.
- Returns:
- List of all children of type targetType. Returns an empty list if none found.
findDescendantsOfType
<T> void findDescendantsOfType(Class<T> targetType,
List<T> results,
boolean crossFindBoundaries)
- Traverses down the tree to find all the descendant instances of type descendantType.
- Parameters:
targetType
- class which you want to find.results
- list to store the matching descendantscrossFindBoundaries
- if false
, recursion stops for nodes for which isFindBoundary()
is true
getFirstChildOfType
<T> T getFirstChildOfType(Class<T> childType)
- Traverses the children to find the first instance of type childType.
- Parameters:
childType
- class which you want to find.
- Returns:
- Node of type childType. Returns
null
if none found. - See Also:
if traversal of the entire tree is needed.
getFirstDescendantOfType
<T> T getFirstDescendantOfType(Class<T> descendantType)
- Traverses down the tree to find the first descendant instance of type descendantType.
- Parameters:
descendantType
- class which you want to find.
- Returns:
- Node of type descendantType. Returns
null
if none found.
hasDescendantOfType
<T> boolean hasDescendantOfType(Class<T> type)
- Finds if this node contains a descendant of the given type.
- Parameters:
type
- the node type to search
- Returns:
true
if there is at least one descendant of the given type
findChildNodesWithXPath
List<? extends Node> findChildNodesWithXPath(String xpathString)
throws org.jaxen.JaxenException
- Returns all the nodes matching the xpath expression.
- Parameters:
xpathString
- the expression to check
- Returns:
- List of all matching nodes. Returns an empty list if none found.
- Throws:
org.jaxen.JaxenException
hasDescendantMatchingXPath
boolean hasDescendantMatchingXPath(String xpathString)
- Checks whether at least one descendant matches the xpath expression.
- Parameters:
xpathString
- the expression to check
- Returns:
- true if there is a match
getAsDocument
Document getAsDocument()
- Get a DOM Document which contains Elements and Attributes representative
of this Node and it's children. Essentially a DOM tree representation of
the Node AST, thereby allowing tools which can operate upon DOM to
also indirectly operate on the AST.
getUserData
Object getUserData()
- Get the user data associated with this node. By default there is no data,
unless it has been set via
setUserData(Object)
.
- Returns:
- The user data set on this node.
setUserData
void setUserData(Object userData)
- Set the user data associated with this node.
PMD itself will never set user data onto a node. Nor should any Rule
implementation, as the AST nodes are shared between concurrently executing
Rules (i.e. it is not thread-safe).
This API is most useful for external applications looking to leverage
PMD's robust support for AST structures, in which case application
specific annotations on the AST nodes can be quite useful.
- Parameters:
userData
- The data to set on this node.
Copyright © 2002–2015 InfoEther. All rights reserved.