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. UseVoidfor visitors that do not need to return results.P- the type of the additional parameter to this visitor's methods. UseVoidfor 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
scanmethods. - 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, visitYieldModifier and TypeMethodDescriptionReduces two results into a combined result.Scans a sequence of nodes.visitAnnotatedType(AnnotatedTypeTree node, P p) Visits anAnnotatedTypeTreenode.visitAnnotation(AnnotationTree node, P p) Visits anAnnotatedTreenode.visitAnyPattern(AnyPatternTree node, P p) Visits aAnyPatternTreenode.visitArrayAccess(ArrayAccessTree node, P p) Visits anArrayAccessTreenode.visitArrayType(ArrayTypeTree node, P p) Visits anArrayTypeTreenode.visitAssert(AssertTree node, P p) Visits anAssertTreenode.visitAssignment(AssignmentTree node, P p) Visits anAssignmentTreenode.visitBinary(BinaryTree node, P p) Visits aBinaryTreenode.visitBindingPattern(BindingPatternTree node, P p) Visits aBindingPatternTreenode.visitBlock(BlockTree node, P p) Visits aBlockTreenode.visitBreak(BreakTree node, P p) Visits aBreakTreenode.Visits aCaseTreenode.visitCatch(CatchTree node, P p) Visits aCatchTreenode.visitClass(ClassTree node, P p) Visits aClassTreenode.visitCompilationUnit(CompilationUnitTree node, P p) Visits aCompilationUnitTreenode.Visits aCompoundAssignmentTreenode.Visits aConditionalExpressionTreenode.visitConstantCaseLabel(ConstantCaseLabelTree node, P p) Visits aConstantCaseLabelTreenode.visitContinue(ContinueTree node, P p) Visits aContinueTreenode.Visits aDeconstructionPatternTreenode.visitDefaultCaseLabel(DefaultCaseLabelTree node, P p) Visits aDefaultCaseLabelTreenode.visitDoWhileLoop(DoWhileLoopTree node, P p) Visits aDoWhileTreenode.visitEmptyStatement(EmptyStatementTree node, P p) Visits anEmptyStatementTreenode.visitEnhancedForLoop(EnhancedForLoopTree node, P p) Visits anEnhancedForLoopTreenode.visitErroneous(ErroneousTree node, P p) Visits anErroneousTreenode.visitExports(ExportsTree node, P p) Visits anExportsTreenode.Visits anExpressionStatementTreenode.visitForLoop(ForLoopTree node, P p) Visits aForLoopTreenode.visitIdentifier(IdentifierTree node, P p) Visits anIdentifierTreenode.Visits anIfTreenode.visitImport(ImportTree node, P p) Visits anImportTreenode.visitInstanceOf(InstanceOfTree node, P p) Visits anInstanceOfTreenode.visitIntersectionType(IntersectionTypeTree node, P p) Visits anIntersectionTypeTreenode.visitLabeledStatement(LabeledStatementTree node, P p) Visits aLabeledStatementTreenode.visitLambdaExpression(LambdaExpressionTree node, P p) Visits aLambdaExpressionTreenode.visitLiteral(LiteralTree node, P p) Visits aLiteralTreenode.visitMemberReference(MemberReferenceTree node, P p) Visits aMemberReferenceTreenode.visitMemberSelect(MemberSelectTree node, P p) Visits aMemberSelectTreenode.visitMethod(MethodTree node, P p) Visits aMethodTreenode.visitMethodInvocation(MethodInvocationTree node, P p) Visits aMethodInvocationTreenode.visitModifiers(ModifiersTree node, P p) Visits aModifiersTreenode.visitModule(ModuleTree node, P p) Visits aModuleTreenode.visitNewArray(NewArrayTree node, P p) Visits aNewArrayTreenode.visitNewClass(NewClassTree node, P p) Visits aNewClassTreenode.visitOpens(OpensTree node, P p) Visits anOpensTreenode.visitOther(Tree node, P p) Visits an unknown type ofTreenode.visitPackage(PackageTree node, P p) Visits aPackageTreenode.visitParameterizedType(ParameterizedTypeTree node, P p) Visits aParameterizedTypeTreenode.visitParenthesized(ParenthesizedTree node, P p) Visits aParenthesizedTreenode.visitPatternCaseLabel(PatternCaseLabelTree node, P p) Visits aPatternCaseLabelTreenode.visitPrimitiveType(PrimitiveTypeTree node, P p) Visits aPrimitiveTypeTreenode.visitProvides(ProvidesTree node, P p) Visits aProvidesTreenode.visitRequires(RequiresTree node, P p) Visits aRequiresTreenode.visitReturn(ReturnTree node, P p) Visits aReturnTreenode.visitSwitch(SwitchTree node, P p) Visits aSwitchTreenode.visitSwitchExpression(SwitchExpressionTree node, P p) Visits aSwitchExpressionTreenode.visitSynchronized(SynchronizedTree node, P p) Visits aSynchronizedTreenode.visitThrow(ThrowTree node, P p) Visits aThrowTreenode.Visits aTryTreenode.visitTypeCast(TypeCastTree node, P p) Visits aTypeCastTreenode.visitTypeParameter(TypeParameterTree node, P p) Visits aTypeParameterTreenode.visitUnary(UnaryTree node, P p) Visits aUnaryTreenode.visitUnionType(UnionTypeTree node, P p) Visits aUnionTypeTreenode.Visits aUsesTreenode.visitVariable(VariableTree node, P p) Visits aVariableTreenode.visitWhileLoop(WhileLoopTree node, P p) Visits aWhileLoopTreenode.visitWildcard(WildcardTree node, P p) Visits aWildcardTypeTreenode.visitYield(YieldTree node, P p) Visits aYieldTreenode.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Creates and returns a copy of this object.booleanIndicates whether some other object is "equal to" this one.protected voidfinalize()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.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(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 voidwait(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:
scanin classTreeScanner<R,P> - API Note:
- This method should normally only be called by the
scanner's
visitmethods, 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
-