模块 jdk.compiler

类 TreePath

java.lang.Object
com.sun.source.util.TreePath
所有已实现的接口:
Iterable<Tree>

public class TreePath extends Object implements Iterable <Tree >
树节点的路径,通常用于表示树节点的祖先节点序列,直到顶级 CompilationUnitTree 节点。
自从:
1.6
  • 构造方法详细信息

    • TreePath

      public TreePath(CompilationUnitTree  node)
      为根节点创建 TreePath。
      参数:
      node - 根节点
    • TreePath

      public TreePath(TreePath  path, Tree  tree)
      为子节点创建 TreePath。
      参数:
      path - 父路径
      tree - 子节点
  • 方法详情

    • getPath

      public static TreePath  getPath(CompilationUnitTree  unit, Tree  target)
      返回编译单元内树节点的树路径,如果未找到该节点,则返回 null
      参数:
      unit - 要搜索的编译单元
      target - 要定位的节点
      返回:
      树路径
    • getPath

      public static TreePath  getPath(TreePath  path, Tree  target)
      返回由 TreePath 对象标识的子树中树节点的树路径。如果未找到节点,则返回 null
      参数:
      path - 搜索路径
      target - 要定位的节点
      返回:
      目标节点的树路径
    • getCompilationUnit

      public CompilationUnitTree  getCompilationUnit()
      返回与此路径关联的编译单元。
      返回:
      编译单元
    • getLeaf

      public Tree  getLeaf()
      返回此路径的叶节点。
      返回:
      叶节点
    • getParentPath

      public TreePath  getParentPath()
      返回封闭节点的路径,如果没有封闭节点,则返回 null
      返回:
      封闭节点的路径
    • iterator

      public Iterator <Tree > iterator()
      从叶子迭代到根。
      指定者:
      iterator 在接口 Iterable<Tree>
      返回:
      一个迭代器。