Class TreePathScanner<R,​P>

All Implemented Interfaces:
TreeVisitor<R,​P>
public class TreePathScanner<R,P>
extends TreeScanner<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

Constructors

Constructor Description
TreePathScanner()

Methods

Modifier and Type Method Description
TreePath getCurrentPath()

Returns the current path for the node, as built up by the currently active set of scan calls.

R scan​(Tree tree, P p)

Scans a single node.

R scan​(TreePath path, P p)

Scans a tree from a position identified by a TreePath.

Methods declared in class com.sun.source.util.TreeScanner

reduce, scan, visitAnnotatedType, visitAnnotation, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBinary, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitEnhancedForLoop, visitErroneous, visitExpressionStatement, visitForLoop, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitIntersectionType, visitLabeledStatement, visitLambdaExpression, visitLiteral, visitMemberReference, visitMemberSelect, visitMethod, visitMethodInvocation, visitModifiers, visitNewArray, visitNewClass, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitPrimitiveType, visitReturn, visitSwitch, visitSynchronized, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitUnionType, visitVariable, visitWhileLoop, visitWildcard

Methods declared in class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods declared in interface com.sun.source.tree.TreeVisitor

visitExports, visitModule, visitOpens, visitProvides, visitRequires, visitUses

Constructors

TreePathScanner

public TreePathScanner()

Methods

scan

public R scan(TreePath path,
              P p)

Scans a tree from a position identified by a TreePath.

Parameters:
path - the path identifying the node to be scanned
p - a parameter value passed to visit methods
Returns:
the result value from the visit method

scan

public R scan(Tree tree,
              P p)

Scans a single node. The current path is updated for the duration of the scan.

Overrides:
scan in class TreeScanner<R,​P>
API Note:
This method should normally only be called by the scanner's visit methods, as part of an ongoing scan initiated by scan(TreePath, P). The one exception is that it may also be called to initiate a full scan of a CompilationUnitTree.
Parameters:
tree - the node to be scanned
p - a parameter value passed to the visit method
Returns:
the result value from the visit method

getCurrentPath

public TreePath getCurrentPath()

Returns the current path for the node, as built up by the currently active set of scan calls.

Returns:
the current path

© 1993, 2020, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/11/docs/api/jdk.compiler/com/sun/source/util/TreePathScanner.html