Top Description Fields Constructors Methods
com.sun.source.util

public Class TreePathScanner<R, P>

extends TreeScanner<R, P>
Class Inheritance
Type Parameters
<R>
the return type of this visitor's methods. Use Void for visitors that do not need to return results.
<P>
the type of the additional parameter to this visitor's methods. Use Void for visitors that do not need an additional parameter.
Imports
com.sun.source.tree.*

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.

Author
Jonathan Gibbons
Since
1.6

Field Summary

Modifier and TypeField and Description
private TreePath

Constructor Summary

AccessConstructor and Description
public
TreePathScanner()

Constructs a TreePathScanner.

Method Summary

Modifier and TypeMethod and Description
public TreePath

Returns:

the current path
getCurrentPath
()

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

public R

Returns:

the result value from the visit method
scan
(TreePath
the path identifying the node to be scanned
path
,
P
a parameter value passed to visit methods
p
)

Scans a tree from a position identified by a TreePath.

public R

Returns:

the result value from the visit method
scan
(Tree
the node to be scanned
tree
,
P
a parameter value passed to the visit method
p
)

Overrides com.sun.source.util.TreeScanner.scan.

Scans a single node.
Inherited from com.sun.source.util.TreeScanner:
reducescanvisitAnnotatedTypevisitAnnotationvisitAnyPatternvisitArrayAccessvisitArrayTypevisitAssertvisitAssignmentvisitBinaryvisitBindingPatternvisitBlockvisitBreakvisitCasevisitCatchvisitClassvisitCompilationUnitvisitCompoundAssignmentvisitConditionalExpressionvisitConstantCaseLabelvisitContinuevisitDeconstructionPatternvisitDefaultCaseLabelvisitDoWhileLoopvisitEmptyStatementvisitEnhancedForLoopvisitErroneousvisitExportsvisitExpressionStatementvisitForLoopvisitIdentifiervisitIfvisitImportvisitInstanceOfvisitIntersectionTypevisitLabeledStatementvisitLambdaExpressionvisitLiteralvisitMemberReferencevisitMemberSelectvisitMethodvisitMethodInvocationvisitModifiersvisitModulevisitNewArrayvisitNewClassvisitOpensvisitOthervisitPackagevisitParameterizedTypevisitParenthesizedvisitPatternCaseLabelvisitPrimitiveTypevisitProvidesvisitRequiresvisitReturnvisitStringTemplatevisitSwitchvisitSwitchExpressionvisitSynchronizedvisitThrowvisitTryvisitTypeCastvisitTypeParametervisitUnaryvisitUnionTypevisitUsesvisitVariablevisitWhileLoopvisitWildcardvisitYield

Field Detail

pathback to summary
private TreePath path

Constructor Detail

TreePathScannerback to summary
public TreePathScanner()

Constructs a TreePathScanner.

Method Detail

getCurrentPathback to summary
public TreePath getCurrentPath()

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

Returns:TreePath

the current path

scanback to summary
public R scan(TreePath path, P p)

Scans a tree from a position identified by a TreePath.

Parameters
path:TreePath

the path identifying the node to be scanned

p:P

a parameter value passed to visit methods

Returns:R

the result value from the visit method

scanback to summary
public R scan(Tree tree, P p)

Overrides com.sun.source.util.TreeScanner.scan.

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

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:Tree

Doc from com.sun.source.util.TreeScanner.scan.

the node to be scanned

p:P

Doc from com.sun.source.util.TreeScanner.scan.

a parameter value passed to the visit method

Returns:R

the result value from the visit method

Annotations
@Override