DocTreespublic abstract class Trees extends Object
| Constructor | Description | 
|---|---|
| Trees() | Constructor for subclasses to call. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| abstract String | getDocComment | Returns the doc comment, if any, for the  Treenode identified by a givenTreePath. | 
| abstract Element | getElement | Returns the  Elementfor theTreenode identified by a givenTreePath. | 
| abstract TypeMirror | getLub | Returns the lub of an exception parameter declared in a catch clause. | 
| abstract TypeMirror | getOriginalType | Returns the original type from the  ErrorTypeobject. | 
| abstract TreePath | getPath | Returns the path to tree node within the specified compilation unit. | 
| abstract TreePath | getPath | Returns the  TreePathnode for a givenElement. | 
| abstract TreePath | getPath | Returns the  TreePathnode for anAnnotationMirroron a givenElement. | 
| abstract TreePath | getPath | Returns the  TreePathnode for anAnnotationValuefor anAnnotationMirroron a givenElement. | 
| abstract Scope | getScope | Returns the  Scopefor theTreenode identified by a givenTreePath. | 
| abstract SourcePositions | getSourcePositions() | Returns a utility object for obtaining source positions. | 
| abstract Tree | getTree | Returns the  Treenode for a givenElement. | 
| abstract Tree | getTree | Returns the  Treenode for anAnnotationMirroron a givenElement. | 
| abstract Tree | getTree | Returns the  Treenode for anAnnotationValuefor anAnnotationMirroron a givenElement. | 
| abstract MethodTree | getTree | Returns the  MethodTreenode for a givenExecutableElement. | 
| abstract ClassTree | getTree | Returns the  ClassTreenode for a givenTypeElement. | 
| abstract TypeMirror | getTypeMirror | Returns the  TypeMirrorfor theTreenode identified by a givenTreePath. | 
| static Trees | instance | Returns a  Treesobject for a givenProcessingEnvironment. | 
| static Trees | instance | Returns a  Treesobject for a givenCompilationTask. | 
| abstract boolean | isAccessible | Checks whether the given element is accessible as a member of the given type in a given scope. | 
| abstract boolean | isAccessible | Checks whether a given type is accessible in a given scope. | 
| abstract void | printMessage | Prints a message of the specified kind at the location of the tree within the provided compilation unit | 
public Trees()
public static Trees instance(JavaCompiler.CompilationTask task)
Trees object for a given CompilationTask.task - the compilation task for which to get the Trees objectTrees objectIllegalArgumentException - if the task does not support the Tree API.public static Trees instance(ProcessingEnvironment env)
Trees object for a given ProcessingEnvironment.env - the processing environment for which to get the Trees objectTrees objectIllegalArgumentException - if the env does not support the Tree API.public abstract SourcePositions getSourcePositions()
public abstract Tree getTree(Element element)
Tree node for a given Element. Returns null if the node can not be found.element - the elementpublic abstract ClassTree getTree(TypeElement element)
ClassTree node for a given TypeElement. Returns null if the node can not be found.element - the elementpublic abstract MethodTree getTree(ExecutableElement method)
MethodTree node for a given ExecutableElement. Returns null if the node can not be found.method - the executable elementpublic abstract Tree getTree(Element e, AnnotationMirror a)
Tree node for an AnnotationMirror on a given Element. Returns null if the node can not be found.e - the elementa - the annotation mirrorpublic abstract Tree getTree(Element e, AnnotationMirror a, AnnotationValue v)
Tree node for an AnnotationValue for an AnnotationMirror on a given Element. Returns null if the node can not be found.e - the elementa - the annotation mirrorv - the annotation valuepublic abstract TreePath getPath(CompilationUnitTree unit, Tree node)
unit - the compilation unitnode - the tree nodepublic abstract TreePath getPath(Element e)
TreePath node for a given Element. Returns null if the node can not be found.e - the elementpublic abstract TreePath getPath(Element e, AnnotationMirror a)
TreePath node for an AnnotationMirror on a given Element. Returns null if the node can not be found.e - the elementa - the annotation mirrorpublic abstract TreePath getPath(Element e, AnnotationMirror a, AnnotationValue v)
TreePath node for an AnnotationValue for an AnnotationMirror on a given Element. Returns null if the node can not be found.e - the elementa - the annotation mirrorv - the annotation valuepublic abstract Element getElement(TreePath path)
Element for the Tree node identified by a given TreePath. Returns null if the element is not available.path - the tree pathIllegalArgumentException - is the TreePath does not identify a Tree node that might have an associated Element.public abstract TypeMirror getTypeMirror(TreePath path)
TypeMirror for the Tree node identified by a given TreePath. Returns null if the TypeMirror is not available.path - the tree pathIllegalArgumentException - is the TreePath does not identify a Tree node that might have an associated TypeMirror.public abstract Scope getScope(TreePath path)
Scope for the Tree node identified by a given TreePath. Returns null if the Scope is not available.path - the tree pathpublic abstract String getDocComment(TreePath path)
Tree node identified by a given TreePath. Returns null if no doc comment was found.path - the tree pathpublic abstract boolean isAccessible(Scope scope, TypeElement type)
scope - the scope to be checkedtype - the type to be checkedtype is accessiblepublic abstract boolean isAccessible(Scope scope, Element member, DeclaredType type)
scope - the scope to be checkedmember - the member to be checkedtype - the type for which to check if the member is accessiblemember is accessible in type
public abstract TypeMirror getOriginalType(ErrorType errorType)
ErrorType object.errorType - the errorType for which we want to get the original typeErrorType
public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg, Tree t, CompilationUnitTree root)
kind - the kind of messagemsg - the message, or an empty string if nonet - the tree to use as a position hintroot - the compilation unit that contains treepublic abstract TypeMirror getLub(CatchTree tree)
tree - the tree for the catch clause
    © 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
    https://docs.oracle.com/en/java/javase/21/docs/api/jdk.compiler/com/sun/source/util/Trees.html