模块 jdk.compiler

类 Trees

java.lang.Object
com.sun.source.util.Trees
已知子类:
DocTrees

public abstract class Trees extends Object
桥接 JSR 199、JSR 269 和 Tree API。
  • 构造方法详细信息

    • Trees

      public Trees()
      子类调用的构造方法。
  • 方法详情

    • instance

      public static Trees  instance(JavaCompiler.CompilationTask  task)
      为给定的 CompilationTask 返回一个 Trees 对象。
      参数:
      task - 为其获取 Trees 对象的编译任务
      返回:
      Trees 对象
      抛出:
      IllegalArgumentException - 如果任务不支持 Tree API。
    • instance

      public static Trees  instance(ProcessingEnvironment  env)
      为给定的 ProcessingEnvironment 返回一个 Trees 对象。
      参数:
      env - 获取 Trees 对象的处理环境
      返回:
      Trees 对象
      抛出:
      IllegalArgumentException - 如果环境不支持 Tree API。
    • getSourcePositions

      public abstract SourcePositions  getSourcePositions()
      返回用于获取源位置的实用程序对象。
      返回:
      获取源位置的实用对象
    • getTree

      public abstract Tree  getTree(Element  element)
      返回给定 ElementTree 节点。如果找不到节点,则返回 null
      参数:
      element - 元素
      返回:
      树节点
    • getTree

      public abstract ClassTree  getTree(TypeElement  element)
      返回给定 TypeElementClassTree 节点。如果找不到节点,则返回 null
      参数:
      element - 元素
      返回:
      类树节点
    • getTree

      public abstract MethodTree  getTree(ExecutableElement  method)
      返回给定 ExecutableElementMethodTree 节点。如果找不到节点,则返回 null
      参数:
      method - 可执行元素
      返回:
      方法树节点
    • getTree

      public abstract Tree  getTree(Element  e, AnnotationMirror  a)
      返回给定 ElementAnnotationMirrorTree 节点。如果找不到节点,则返回 null
      参数:
      e - 元素
      a - 注释镜像
      返回:
      树节点
    • getTree

      public abstract Tree  getTree(Element  e, AnnotationMirror  a, AnnotationValue  v)
      为给定的 Element 上的 AnnotationMirror 返回 AnnotationValueTree 节点。如果找不到节点,则返回 null
      参数:
      e - 元素
      a - 注释镜像
      v - 注解值
      返回:
      树节点
    • getPath

      public abstract TreePath  getPath(CompilationUnitTree  unit, Tree  node)
      返回指定编译单元内树节点的路径。
      参数:
      unit - 编译单元
      node - 树节点
      返回:
      树路径
    • getPath

      public abstract TreePath  getPath(Element  e)
      返回给定 ElementTreePath 节点。如果找不到节点,则返回 null
      参数:
      e - 元素
      返回:
      树路径
    • getPath

      public abstract TreePath  getPath(Element  e, AnnotationMirror  a)
      返回给定 ElementAnnotationMirrorTreePath 节点。如果找不到节点,则返回 null
      参数:
      e - 元素
      a - 注释镜像
      返回:
      树路径
    • getPath

      public abstract TreePath  getPath(Element  e, AnnotationMirror  a, AnnotationValue  v)
      为给定的 Element 上的 AnnotationMirror 返回 AnnotationValueTreePath 节点。如果找不到节点,则返回 null
      参数:
      e - 元素
      a - 注释镜像
      v - 注解值
      返回:
      树路径
    • getElement

      public abstract Element  getElement(TreePath  path)
      返回由给定的 TreePath 标识的 Tree 节点的 Element。如果元素不可用,则返回 null
      参数:
      path - 树路径
      返回:
      元素
      抛出:
      IllegalArgumentException - 是 TreePath 未识别可能具有关联的 ElementTree 节点。
    • getTypeMirror

      public abstract TypeMirror  getTypeMirror(TreePath  path)
      返回由给定的 TreePath 标识的 Tree 节点的 TypeMirror。如果 TypeMirror 不可用,则返回 null
      参数:
      path - 树路径
      返回:
      镜像类型
      抛出:
      IllegalArgumentException - 是 TreePath 未识别可能具有关联的 TypeMirrorTree 节点。
    • getScope

      public abstract Scope  getScope(TreePath  path)
      返回由给定的 TreePath 标识的 Tree 节点的 Scope。如果 Scope 不可用,则返回 null
      参数:
      path - 树路径
      返回:
      范围
    • getDocComment

      public abstract String  getDocComment(TreePath  path)
      返回给定 TreePath 标识的 Tree 节点的文档注释(如果有)。如果未找到文档注释,则返回 null
      参数:
      path - 树路径
      返回:
      文档评论
      参见:
    • isAccessible

      public abstract boolean isAccessible(Scope  scope, TypeElement  type)
      检查给定类型在给定范围内是否可访问。
      参数:
      scope - 要检查的范围
      type - 要检查的类型
      返回:
      如果 type 可访问,则为真
    • isAccessible

      public abstract boolean isAccessible(Scope  scope, Element  member, DeclaredType  type)
      检查给定元素是否可以作为给定范围内给定类型的成员访问。
      参数:
      scope - 要检查的范围
      member - 要检查的成员
      type - 检查成员是否可访问的类型
      返回:
      如果 member 可在 type 中访问,则为真
    • getOriginalType

      public abstract TypeMirror  getOriginalType(ErrorType  errorType)
      ErrorType 对象返回原始类型。
      参数:
      errorType - 我们想要获取原始类型的错误类型
      返回:
      原始类型对应的类型镜像,替换为ErrorType
    • printMessage

      public abstract void printMessage(Diagnostic.Kind  kind, CharSequence  msg, Tree  t, CompilationUnitTree  root)
      在提供的编译单元内的树的位置打印指定类型的消息
      参数:
      kind - 消息的种类
      msg - 消息,如果没有则为空字符串
      t - 用作位置提示的树
      root - 包含树的编译单元
    • getLub

      public abstract TypeMirror  getLub(CatchTree  tree)
      返回在 catch 子句中声明的异常参数的 lub。
      参数:
      tree - catch 子句的树
      返回:
      异常参数的 lub