Class Trees
java.lang.Object
com.sun.source.util.Trees
- Direct Known Subclasses:
DocTrees
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract String
getDocComment
(TreePath path) Returns the doc comment, if any, for theTree
node identified by a givenTreePath
.abstract Element
getElement
(TreePath path) Returns theElement
for theTree
node identified by a givenTreePath
.abstract TypeMirror
Returns the lub of an exception parameter declared in a catch clause.abstract TypeMirror
getOriginalType
(ErrorType errorType) Returns the original type from theErrorType
object.abstract TreePath
getPath
(CompilationUnitTree unit, Tree node) Returns the path to tree node within the specified compilation unit.abstract TreePath
Returns theTreePath
node for a givenElement
.abstract TreePath
getPath
(Element e, AnnotationMirror a) Returns theTreePath
node for anAnnotationMirror
on a givenElement
.abstract TreePath
getPath
(Element e, AnnotationMirror a, AnnotationValue v) Returns theTreePath
node for anAnnotationValue
for anAnnotationMirror
on a givenElement
.abstract Scope
Returns theScope
for theTree
node identified by a givenTreePath
.abstract SourcePositions
Returns a utility object for obtaining source positions.abstract Tree
Returns theTree
node for a givenElement
.abstract Tree
getTree
(Element e, AnnotationMirror a) Returns theTree
node for anAnnotationMirror
on a givenElement
.abstract Tree
getTree
(Element e, AnnotationMirror a, AnnotationValue v) Returns theTree
node for anAnnotationValue
for anAnnotationMirror
on a givenElement
.abstract MethodTree
getTree
(ExecutableElement method) Returns theMethodTree
node for a givenExecutableElement
.abstract ClassTree
getTree
(TypeElement element) Returns theClassTree
node for a givenTypeElement
.abstract TypeMirror
getTypeMirror
(TreePath path) Returns theTypeMirror
for theTree
node identified by a givenTreePath
.static Trees
Returns aTrees
object for a givenProcessingEnvironment
.static Trees
Returns aTrees
object for a givenCompilationTask
.abstract boolean
isAccessible
(Scope scope, Element member, DeclaredType type) Checks whether the given element is accessible as a member of the given type in a given scope.abstract boolean
isAccessible
(Scope scope, TypeElement type) Checks whether a given type is accessible in a given scope.abstract void
printMessage
(Diagnostic.Kind kind, CharSequence msg, Tree t, CompilationUnitTree root) Prints a message of the specified kind at the location of the tree within the provided compilation unit
-
Constructor Details
-
Trees
public Trees()Constructor for subclasses to call.
-
-
Method Details
-
instance
Returns aTrees
object for a givenCompilationTask
.- Parameters:
task
- the compilation task for which to get theTrees
object- Returns:
- the
Trees
object - Throws:
IllegalArgumentException
- if the task does not support the Tree API.
-
instance
Returns aTrees
object for a givenProcessingEnvironment
.- Parameters:
env
- the processing environment for which to get theTrees
object- Returns:
- the
Trees
object - Throws:
IllegalArgumentException
- if the env does not support the Tree API.
-
getSourcePositions
Returns a utility object for obtaining source positions.- Returns:
- the utility object for obtaining source positions
-
getTree
-
getTree
Returns theClassTree
node for a givenTypeElement
. Returnsnull
if the node can not be found.- Parameters:
element
- the element- Returns:
- the class tree node
-
getTree
Returns theMethodTree
node for a givenExecutableElement
. Returnsnull
if the node can not be found.- Parameters:
method
- the executable element- Returns:
- the method tree node
-
getTree
Returns theTree
node for anAnnotationMirror
on a givenElement
. Returnsnull
if the node can not be found.- Parameters:
e
- the elementa
- the annotation mirror- Returns:
- the tree node
-
getTree
Returns theTree
node for anAnnotationValue
for anAnnotationMirror
on a givenElement
. Returnsnull
if the node can not be found.- Parameters:
e
- the elementa
- the annotation mirrorv
- the annotation value- Returns:
- the tree node
-
getPath
Returns the path to tree node within the specified compilation unit.- Parameters:
unit
- the compilation unitnode
- the tree node- Returns:
- the tree path
-
getPath
-
getPath
Returns theTreePath
node for anAnnotationMirror
on a givenElement
. Returnsnull
if the node can not be found.- Parameters:
e
- the elementa
- the annotation mirror- Returns:
- the tree path
-
getPath
Returns theTreePath
node for anAnnotationValue
for anAnnotationMirror
on a givenElement
. Returnsnull
if the node can not be found.- Parameters:
e
- the elementa
- the annotation mirrorv
- the annotation value- Returns:
- the tree path
-
getElement
Returns theElement
for theTree
node identified by a givenTreePath
. Returnsnull
if the element is not available.- Parameters:
path
- the tree path- Returns:
- the element
- Throws:
IllegalArgumentException
- is theTreePath
does not identify aTree
node that might have an associatedElement
.
-
getTypeMirror
Returns theTypeMirror
for theTree
node identified by a givenTreePath
. Returnsnull
if theTypeMirror
is not available.- Parameters:
path
- the tree path- Returns:
- the type mirror
- Throws:
IllegalArgumentException
- is theTreePath
does not identify aTree
node that might have an associatedTypeMirror
.
-
getScope
-
getDocComment
-
isAccessible
Checks whether a given type is accessible in a given scope.- Parameters:
scope
- the scope to be checkedtype
- the type to be checked- Returns:
- true if
type
is accessible
-
isAccessible
Checks whether the given element is accessible as a member of the given type in a given scope.- Parameters:
scope
- the scope to be checkedmember
- the member to be checkedtype
- the type for which to check if the member is accessible- Returns:
- true if
member
is accessible intype
-
getOriginalType
Returns the original type from theErrorType
object.- Parameters:
errorType
- the errorType for which we want to get the original type- Returns:
- the type mirror corresponding to the original type, replaced by the
ErrorType
-
printMessage
public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg, Tree t, CompilationUnitTree root) Prints a message of the specified kind at the location of the tree within the provided compilation unit- Parameters:
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 tree
-
getLub
Returns the lub of an exception parameter declared in a catch clause.- Parameters:
tree
- the tree for the catch clause- Returns:
- the lub of the exception parameter
-