Module jdk.compiler

Class Trees

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

public abstract class Trees extends Object
桥接JSR 199、JSR 269和Tree API。
  • Constructor Details

    • Trees

      public Trees()
      子类调用的构造函数。
  • Method Details

    • instance

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

      public static Trees instance(ProcessingEnvironment env)
      返回给定ProcessingEnvironmentTrees对象。
      参数:
      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)
      返回给定Element上的AnnotationMirrorTree节点。如果找不到节点,则返回null
      参数:
      e - 元素
      a - 注解镜像
      返回:
      树节点
    • getTree

      public abstract Tree getTree(Element e, AnnotationMirror a, AnnotationValue v)
      返回给定Element上的AnnotationMirrorAnnotationValueTree节点。如果找不到节点,则返回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)
      返回给定Element上的AnnotationMirrorTreePath节点。如果找不到节点,则返回null
      参数:
      e - 元素
      a - 注解镜像
      返回:
      树路径
    • getPath

      public abstract TreePath getPath(Element e, AnnotationMirror a, AnnotationValue v)
      返回给定Element上的AnnotationMirrorAnnotationValueTreePath节点。如果找不到节点,则返回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可访问,则为true
    • isAccessible

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

      public abstract TypeMirror getOriginalType(ErrorType 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