Class TreePathScanner<R,P>
java.lang.Object
com.sun.source.util.TreeScanner<R,P>
com.sun.source.util.TreePathScanner<R,P>
- Type Parameters:
R
- the return type of this visitor's methods. UseVoid
for visitors that do not need to return results.P
- the type of the additional parameter to this visitor's methods. UseVoid
for visitors that do not need an additional parameter.
- All Implemented Interfaces:
TreeVisitor<R,
P>
A TreeVisitor that visits all the child tree nodes, and provides
support for maintaining a path for the parent nodes.
To visit nodes of a particular type, just override the
corresponding visitorXYZ method.
Inside your method, call super.visitXYZ to visit descendant
nodes.
- API Note:
- In order to initialize the "current path", the scan must be
started by calling one of the
scan
methods. - Since:
- 1.6
-
Constructor Summary
Constructors -
Method Summary
Methods declared in class TreeScanner
reduce, scan, visitAnnotatedType, visitAnnotation, visitAnyPattern, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBinary, visitBindingPattern, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitConstantCaseLabel, visitContinue, visitDeconstructionPattern, visitDefaultCaseLabel, visitDoWhileLoop, visitEmptyStatement, visitEnhancedForLoop, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitIntersectionType, visitLabeledStatement, visitLambdaExpression, visitLiteral, visitMemberReference, visitMemberSelect, visitMethod, visitMethodInvocation, visitModifiers, visitModule, visitNewArray, visitNewClass, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitPatternCaseLabel, visitPrimitiveType, visitProvides, visitRequires, visitReturn, visitSwitch, visitSwitchExpression, visitSynchronized, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitUnionType, visitUses, visitVariable, visitWhileLoop, visitWildcard, visitYield
Modifier and TypeMethodDescriptionReduces two results into a combined result.Scans a sequence of nodes.visitAnnotatedType
(AnnotatedTypeTree node, P p) Visits anAnnotatedTypeTree
node.visitAnnotation
(AnnotationTree node, P p) Visits anAnnotatedTree
node.visitAnyPattern
(AnyPatternTree node, P p) Visits aAnyPatternTree
node.visitArrayAccess
(ArrayAccessTree node, P p) Visits anArrayAccessTree
node.visitArrayType
(ArrayTypeTree node, P p) Visits anArrayTypeTree
node.visitAssert
(AssertTree node, P p) Visits anAssertTree
node.visitAssignment
(AssignmentTree node, P p) Visits anAssignmentTree
node.visitBinary
(BinaryTree node, P p) Visits aBinaryTree
node.visitBindingPattern
(BindingPatternTree node, P p) Visits aBindingPatternTree
node.visitBlock
(BlockTree node, P p) Visits aBlockTree
node.visitBreak
(BreakTree node, P p) Visits aBreakTree
node.Visits aCaseTree
node.visitCatch
(CatchTree node, P p) Visits aCatchTree
node.visitClass
(ClassTree node, P p) Visits aClassTree
node.visitCompilationUnit
(CompilationUnitTree node, P p) Visits aCompilationUnitTree
node.Visits aCompoundAssignmentTree
node.Visits aConditionalExpressionTree
node.visitConstantCaseLabel
(ConstantCaseLabelTree node, P p) Visits aConstantCaseLabelTree
node.visitContinue
(ContinueTree node, P p) Visits aContinueTree
node.Visits aDeconstructionPatternTree
node.visitDefaultCaseLabel
(DefaultCaseLabelTree node, P p) Visits aDefaultCaseLabelTree
node.visitDoWhileLoop
(DoWhileLoopTree node, P p) Visits aDoWhileTree
node.visitEmptyStatement
(EmptyStatementTree node, P p) Visits anEmptyStatementTree
node.visitEnhancedForLoop
(EnhancedForLoopTree node, P p) Visits anEnhancedForLoopTree
node.visitErroneous
(ErroneousTree node, P p) Visits anErroneousTree
node.visitExports
(ExportsTree node, P p) Visits anExportsTree
node.Visits anExpressionStatementTree
node.visitForLoop
(ForLoopTree node, P p) Visits aForLoopTree
node.visitIdentifier
(IdentifierTree node, P p) Visits anIdentifierTree
node.Visits anIfTree
node.visitImport
(ImportTree node, P p) Visits anImportTree
node.visitInstanceOf
(InstanceOfTree node, P p) Visits anInstanceOfTree
node.visitIntersectionType
(IntersectionTypeTree node, P p) Visits anIntersectionTypeTree
node.visitLabeledStatement
(LabeledStatementTree node, P p) Visits aLabeledStatementTree
node.visitLambdaExpression
(LambdaExpressionTree node, P p) Visits aLambdaExpressionTree
node.visitLiteral
(LiteralTree node, P p) Visits aLiteralTree
node.visitMemberReference
(MemberReferenceTree node, P p) Visits aMemberReferenceTree
node.visitMemberSelect
(MemberSelectTree node, P p) Visits aMemberSelectTree
node.visitMethod
(MethodTree node, P p) Visits aMethodTree
node.visitMethodInvocation
(MethodInvocationTree node, P p) Visits aMethodInvocationTree
node.visitModifiers
(ModifiersTree node, P p) Visits aModifiersTree
node.visitModule
(ModuleTree node, P p) Visits aModuleTree
node.visitNewArray
(NewArrayTree node, P p) Visits aNewArrayTree
node.visitNewClass
(NewClassTree node, P p) Visits aNewClassTree
node.visitOpens
(OpensTree node, P p) Visits anOpensTree
node.visitOther
(Tree node, P p) Visits an unknown type ofTree
node.visitPackage
(PackageTree node, P p) Visits aPackageTree
node.visitParameterizedType
(ParameterizedTypeTree node, P p) Visits aParameterizedTypeTree
node.visitParenthesized
(ParenthesizedTree node, P p) Visits aParenthesizedTree
node.visitPatternCaseLabel
(PatternCaseLabelTree node, P p) Visits aPatternCaseLabelTree
node.visitPrimitiveType
(PrimitiveTypeTree node, P p) Visits aPrimitiveTypeTree
node.visitProvides
(ProvidesTree node, P p) Visits aProvidesTree
node.visitRequires
(RequiresTree node, P p) Visits aRequiresTree
node.visitReturn
(ReturnTree node, P p) Visits aReturnTree
node.visitSwitch
(SwitchTree node, P p) Visits aSwitchTree
node.visitSwitchExpression
(SwitchExpressionTree node, P p) Visits aSwitchExpressionTree
node.visitSynchronized
(SynchronizedTree node, P p) Visits aSynchronizedTree
node.visitThrow
(ThrowTree node, P p) Visits aThrowTree
node.Visits aTryTree
node.visitTypeCast
(TypeCastTree node, P p) Visits aTypeCastTree
node.visitTypeParameter
(TypeParameterTree node, P p) Visits aTypeParameterTree
node.visitUnary
(UnaryTree node, P p) Visits aUnaryTree
node.visitUnionType
(UnionTypeTree node, P p) Visits aUnionTypeTree
node.Visits aUsesTree
node.visitVariable
(VariableTree node, P p) Visits aVariableTree
node.visitWhileLoop
(WhileLoopTree node, P p) Visits aWhileLoopTree
node.visitWildcard
(WildcardTree node, P p) Visits aWildcardTypeTree
node.visitYield
(YieldTree node, P p) Visits aYieldTree
node.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Modifier and TypeMethodDescriptionprotected Object
clone()
Creates and returns a copy of this object.boolean
Indicates whether some other object is "equal to" this one.protected void
finalize()
Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class
<?> getClass()
Returns the runtime class of thisObject
.int
hashCode()
Returns a hash code value for this object.final void
notify()
Wakes up a single thread that is waiting on this object's monitor.final void
Wakes up all threads that are waiting on this object's monitor.toString()
Returns a string representation of the object.final void
wait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final void
wait
(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final void
wait
(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Constructor Details
-
TreePathScanner
public TreePathScanner()Constructs aTreePathScanner
.
-
-
Method Details
-
scan
-
scan
Scans a single node. The current path is updated for the duration of the scan.- Overrides:
scan
in classTreeScanner<R,
P> - API Note:
- This method should normally only be called by the
scanner's
visit
methods, as part of an ongoing scan initiated byscan(TreePath, P)
. The one exception is that it may also be called to initiate a full scan of aCompilationUnitTree
. - Parameters:
tree
- the node to be scannedp
- a parameter value passed to the visit method- Returns:
- the result value from the visit method
-
getCurrentPath
Returns the current path for the node, as built up by the currently active set of scan calls.- Returns:
- the current path
-