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

public Class TreePath

extends Object
implements Iterable<Tree>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable
Imports
java.util.Iterator, .NoSuchElementException, .Objects, com.sun.source.tree.*

A path of tree nodes, typically used to represent the sequence of ancestor nodes of a tree node up to the top-level CompilationUnitTree node.
Author
Jonathan Gibbons
Since
1.6

Field Summary

Modifier and TypeField and Description
private CompilationUnitTree
private Tree
private TreePath

Constructor Summary

AccessConstructor and Description
public
TreePath(CompilationUnitTree
the root node
node
)

Creates a TreePath for a root node.

public
TreePath(TreePath
the parent path
path
,
Tree
the child node
tree
)

Creates a TreePath for a child node.

Method Summary

Modifier and TypeMethod and Description
public CompilationUnitTree

Returns:

the compilation unit
getCompilationUnit
()

Returns the compilation unit associated with this path.

public Tree

Returns:

the leaf node
getLeaf
()

Returns the leaf node for this path.

public TreePath

Returns:

the path for the enclosing node
getParentPath
()

Returns the path for the enclosing node, or null if there is no enclosing node.

public static TreePath

Returns:

the tree path
getPath
(CompilationUnitTree
the compilation unit to search
unit
,
Tree
the node to locate
target
)

Returns a tree path for a tree node within a compilation unit, or null if the node is not found.

public static TreePath

Returns:

the tree path of the target node
getPath
(TreePath
the path in which to search
path
,
Tree
the node to locate
target
)

Returns a tree path for a tree node within a subtree identified by a TreePath object.

public Iterator<Tree>
iterator()

Implements java.lang.Iterable.iterator.

Iterates from leaves to root.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

compilationUnitback to summary
private CompilationUnitTree compilationUnit
leafback to summary
private Tree leaf
parentback to summary
private TreePath parent

Constructor Detail

TreePathback to summary
public TreePath(CompilationUnitTree node)

Creates a TreePath for a root node.

Parameters
node:CompilationUnitTree

the root node

TreePathback to summary
public TreePath(TreePath path, Tree tree)

Creates a TreePath for a child node.

Parameters
path:TreePath

the parent path

tree:Tree

the child node

Method Detail

getCompilationUnitback to summary
public CompilationUnitTree getCompilationUnit()

Returns the compilation unit associated with this path.

Returns:CompilationUnitTree

the compilation unit

getLeafback to summary
public Tree getLeaf()

Returns the leaf node for this path.

Returns:Tree

the leaf node

getParentPathback to summary
public TreePath getParentPath()

Returns the path for the enclosing node, or null if there is no enclosing node.

Returns:TreePath

the path for the enclosing node

getPathback to summary
public static TreePath getPath(CompilationUnitTree unit, Tree target)

Returns a tree path for a tree node within a compilation unit, or null if the node is not found.

Parameters
unit:CompilationUnitTree

the compilation unit to search

target:Tree

the node to locate

Returns:TreePath

the tree path

getPathback to summary
public static TreePath getPath(TreePath path, Tree target)

Returns a tree path for a tree node within a subtree identified by a TreePath object. Returns null if the node is not found.

Parameters
path:TreePath

the path in which to search

target:Tree

the node to locate

Returns:TreePath

the tree path of the target node

iteratorback to summary
public Iterator<Tree> iterator()

Implements java.lang.Iterable.iterator.

Iterates from leaves to root.

Returns:Iterator<Tree>

Doc from java.lang.Iterable.iterator.

an Iterator.

Annotations
@Override