java.lang.Object
com.sun.source.util.Trees
- 直接已知的子类:
-
DocTrees
桥接JSR 199、JSR 269和Tree API。
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract StringgetDocComment(TreePath path) 返回给定TreePath标识的Tree节点的文档注释(如果有)。abstract ElementgetElement(TreePath path) 返回给定TreePath标识的Tree节点的Element。abstract TypeMirror返回在catch子句中声明的异常参数的lub。abstract TypeMirrorgetOriginalType(ErrorType errorType) 返回ErrorType对象的原始类型。abstract TreePathgetPath(CompilationUnitTree unit, Tree node) 返回指定编译单元中树节点的路径。abstract TreePath返回给定Element的TreePath节点。abstract TreePathgetPath(Element e, AnnotationMirror a) 返回给定Element上的AnnotationMirror的TreePath节点。abstract TreePathgetPath(Element e, AnnotationMirror a, AnnotationValue v) 返回给定Element上的AnnotationMirror的AnnotationValue的TreePath节点。abstract Scope返回给定TreePath标识的Tree节点的Scope。abstract SourcePositions返回用于获取源代码位置的实用对象。abstract Tree返回给定Element的Tree节点。abstract TreegetTree(Element e, AnnotationMirror a) 返回给定Element上的AnnotationMirror的Tree节点。abstract TreegetTree(Element e, AnnotationMirror a, AnnotationValue v) 返回给定Element上的AnnotationMirror的AnnotationValue的Tree节点。abstract MethodTreegetTree(ExecutableElement method) 返回给定ExecutableElement的MethodTree节点。abstract ClassTreegetTree(TypeElement element) 返回给定TypeElement的ClassTree节点。abstract TypeMirrorgetTypeMirror(TreePath path) 返回给定TreePath标识的Tree节点的TypeMirror。static Trees返回给定ProcessingEnvironment的Trees对象。static Trees返回给定CompilationTask的Trees对象。abstract booleanisAccessible(Scope scope, Element member, DeclaredType type) 检查给定元素在给定作用域中是否可作为成员访问。abstract booleanisAccessible(Scope scope, TypeElement type) 检查给定类型在给定作用域中是否可访问。abstract voidprintMessage(Diagnostic.Kind kind, CharSequence msg, Tree t, CompilationUnitTree root) 在提供的编译单元中树的位置打印指定种类的消息。
-
Constructor Details
-
Trees
public Trees()子类调用的构造函数。
-
-
Method Details
-
instance
返回给定CompilationTask的Trees对象。- 参数:
-
task- 要获取Trees对象的编译任务 - 返回:
-
Trees对象 - 抛出:
-
IllegalArgumentException- 如果任务不支持Tree API。
-
instance
返回给定ProcessingEnvironment的Trees对象。- 参数:
-
env- 要获取Trees对象的处理环境 - 返回:
-
Trees对象 - 抛出:
-
IllegalArgumentException- 如果环境不支持Tree API。
-
getSourcePositions
返回用于获取源代码位置的实用对象。- 返回:
- 用于获取源代码位置的实用对象
-
getTree
返回给定Element的Tree节点。如果找不到节点,则返回null。- 参数:
-
element- 元素 - 返回:
- 树节点
-
getTree
返回给定TypeElement的ClassTree节点。如果找不到节点,则返回null。- 参数:
-
element- 元素 - 返回:
- 类树节点
-
getTree
返回给定ExecutableElement的MethodTree节点。如果找不到节点,则返回null。- 参数:
-
method- 可执行元素 - 返回:
- 方法树节点
-
getTree
返回给定Element上的AnnotationMirror的Tree节点。如果找不到节点,则返回null。- 参数:
-
e- 元素 -
a- 注解镜像 - 返回:
- 树节点
-
getTree
返回给定Element上的AnnotationMirror的AnnotationValue的Tree节点。如果找不到节点,则返回null。- 参数:
-
e- 元素 -
a- 注解镜像 -
v- 注解值 - 返回:
- 树节点
-
getPath
返回指定编译单元中树节点的路径。- 参数:
-
unit- 编译单元 -
node- 树节点 - 返回:
- 树路径
-
getPath
返回给定Element的TreePath节点。如果找不到节点,则返回null。- 参数:
-
e- 元素 - 返回:
- 树路径
-
getPath
返回给定Element上的AnnotationMirror的TreePath节点。如果找不到节点,则返回null。- 参数:
-
e- 元素 -
a- 注解镜像 - 返回:
- 树路径
-
getPath
返回给定Element上的AnnotationMirror的AnnotationValue的TreePath节点。如果找不到节点,则返回null。- 参数:
-
e- 元素 -
a- 注解镜像 -
v- 注解值 - 返回:
- 树路径
-
getElement
返回给定TreePath标识的Tree节点的Element。如果元素不可用,则返回null。- 参数:
-
path- 树路径 - 返回:
- 元素
- 抛出:
-
IllegalArgumentException- 如果TreePath未标识可能具有关联Element的Tree节点。
-
getTypeMirror
返回给定TreePath标识的Tree节点的TypeMirror。如果TypeMirror不可用,则返回null。- 参数:
-
path- 树路径 - 返回:
- 类型镜像
- 抛出:
-
IllegalArgumentException- 如果TreePath未标识可能具有关联TypeMirror的Tree节点。
-
getScope
返回给定TreePath标识的Tree节点的Scope。如果Scope不可用,则返回null。- 参数:
-
path- 树路径 - 返回:
- 作用域
-
getDocComment
返回给定TreePath标识的Tree节点的文档注释。如果找不到文档注释,则返回null。- 参数:
-
path- 树路径 - 返回:
- 文档注释
- 参见:
-
isAccessible
检查给定类型在给定作用域中是否可访问。- 参数:
-
scope- 要检查的作用域 -
type- 要检查的类型 - 返回:
-
如果
type可访问,则为true
-
isAccessible
检查给定元素在给定类型的成员中是否可访问。- 参数:
-
scope- 要检查的作用域 -
member- 要检查的成员 -
type- 要检查成员是否可访问的类型 - 返回:
-
如果
member在type中可访问,则为true
-
getOriginalType
返回ErrorType对象的原始类型。- 参数:
-
errorType- 要获取原始类型的errorType - 返回:
-
对应于被
ErrorType替换的原始类型的类型镜像
-
printMessage
public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg, Tree t, CompilationUnitTree root) 在提供的编译单元中树的位置打印指定种类的消息。- 参数:
-
kind- 消息的种类 -
msg- 消息,如果没有则为空字符串 -
t- 用作位置提示的树 -
root- 包含树的编译单元
-
getLub
返回在catch子句中声明的异常参数的lub。- 参数:
-
tree- catch子句的树 - 返回:
- 异常参数的lub
-