Compiler Tree API

com.sun.source.util
Class TreePath

java.lang.Object
  extended by com.sun.source.util.TreePath
All Implemented Interfaces:
Iterable<Tree>

public class TreePath
extends Object
implements Iterable<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.

Since:
1.6

Constructor Summary
TreePath(CompilationUnitTree t)
          Creates a TreePath for a root node.
TreePath(TreePath p, Tree t)
          Creates a TreePath for a child node.
 
Method Summary
 CompilationUnitTree getCompilationUnit()
          Get the compilation unit associated with this path.
 Tree getLeaf()
          Get the leaf node for this path.
 TreePath getParentPath()
          Get the path for the enclosing node, or null if there is no enclosing node.
static TreePath getPath(CompilationUnitTree unit, Tree target)
          Gets a tree path for a tree node within a compilation unit.
static TreePath getPath(TreePath path, Tree target)
          Gets a tree path for a tree node within a subtree identified by a TreePath object.
 Iterator<Tree> iterator()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreePath

public TreePath(CompilationUnitTree t)
Creates a TreePath for a root node.


TreePath

public TreePath(TreePath p,
                Tree t)
Creates a TreePath for a child node.

Method Detail

getPath

public static TreePath getPath(CompilationUnitTree unit,
                               Tree target)
Gets a tree path for a tree node within a compilation unit.

Returns:
null if the node is not found

getPath

public static TreePath getPath(TreePath path,
                               Tree target)
Gets a tree path for a tree node within a subtree identified by a TreePath object.

Returns:
null if the node is not found

getCompilationUnit

public CompilationUnitTree getCompilationUnit()
Get the compilation unit associated with this path.


getLeaf

public Tree getLeaf()
Get the leaf node for this path.


getParentPath

public TreePath getParentPath()
Get the path for the enclosing node, or null if there is no enclosing node.


iterator

public Iterator<Tree> iterator()
Specified by:
iterator in interface Iterable<Tree>

Compiler Tree API

Submit a bug or feature
Copyright © 2005, 2015, Oracle and/or its affiliates. All rights reserved.