src/share/classes/com/sun/source/util/TreePath.java

Print this page




  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.source.util;
  27 
  28 import java.util.Iterator;
  29 
  30 import com.sun.source.tree.*;
  31 
  32 /**
  33  * A path of tree nodes, typically used to represent the sequence of ancestor
  34  * nodes of a tree node up to the top level CompilationUnitTree node.
  35  *
  36  * @author Jonathan Gibbons
  37  * @since 1.6
  38  */
  39 @jdk.Supported
  40 public class TreePath implements Iterable<Tree> {
  41     /**
  42      * Gets a tree path for a tree node within a compilation unit.
  43      * @return null if the node is not found
  44      */
  45     public static TreePath getPath(CompilationUnitTree unit, Tree target) {
  46         return getPath(new TreePath(unit), target);
  47     }
  48 
  49     /**
  50      * Gets a tree path for a tree node within a subtree identified by a TreePath object.
  51      * @return null if the node is not found
  52      */
  53     public static TreePath getPath(TreePath path, Tree target) {
  54         path.getClass();
  55         target.getClass();
  56 
  57         class Result extends Error {
  58             static final long serialVersionUID = -5942088234594905625L;
  59             TreePath path;




  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.source.util;
  27 
  28 import java.util.Iterator;
  29 
  30 import com.sun.source.tree.*;
  31 
  32 /**
  33  * A path of tree nodes, typically used to represent the sequence of ancestor
  34  * nodes of a tree node up to the top level CompilationUnitTree node.
  35  *
  36  * @author Jonathan Gibbons
  37  * @since 1.6
  38  */
  39 @jdk.Exported
  40 public class TreePath implements Iterable<Tree> {
  41     /**
  42      * Gets a tree path for a tree node within a compilation unit.
  43      * @return null if the node is not found
  44      */
  45     public static TreePath getPath(CompilationUnitTree unit, Tree target) {
  46         return getPath(new TreePath(unit), target);
  47     }
  48 
  49     /**
  50      * Gets a tree path for a tree node within a subtree identified by a TreePath object.
  51      * @return null if the node is not found
  52      */
  53     public static TreePath getPath(TreePath path, Tree target) {
  54         path.getClass();
  55         target.getClass();
  56 
  57         class Result extends Error {
  58             static final long serialVersionUID = -5942088234594905625L;
  59             TreePath path;