Class Trees
java.lang.Object
com.sun.source.util.Trees
- Direct Known Subclasses:
DocTrees
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract StringgetDocComment(TreePath path) Returns the doc comment, if any, for theTreenode identified by a givenTreePath.abstract ElementgetElement(TreePath path) Returns theElementfor theTreenode identified by a givenTreePath.abstract TypeMirrorReturns the lub of an exception parameter declared in a catch clause.abstract TypeMirrorgetOriginalType(ErrorType errorType) Returns the original type from theErrorTypeobject.abstract TreePathgetPath(CompilationUnitTree unit, Tree node) Returns the path to tree node within the specified compilation unit.abstract TreePathReturns theTreePathnode for a givenElement.abstract TreePathgetPath(Element e, AnnotationMirror a) Returns theTreePathnode for anAnnotationMirroron a givenElement.abstract TreePathgetPath(Element e, AnnotationMirror a, AnnotationValue v) Returns theTreePathnode for anAnnotationValuefor anAnnotationMirroron a givenElement.abstract ScopeReturns theScopefor theTreenode identified by a givenTreePath.abstract SourcePositionsReturns a utility object for obtaining source positions.abstract TreeReturns theTreenode for a givenElement.abstract TreegetTree(Element e, AnnotationMirror a) Returns theTreenode for anAnnotationMirroron a givenElement.abstract TreegetTree(Element e, AnnotationMirror a, AnnotationValue v) Returns theTreenode for anAnnotationValuefor anAnnotationMirroron a givenElement.abstract MethodTreegetTree(ExecutableElement method) Returns theMethodTreenode for a givenExecutableElement.abstract ClassTreegetTree(TypeElement element) Returns theClassTreenode for a givenTypeElement.abstract TypeMirrorgetTypeMirror(TreePath path) Returns theTypeMirrorfor theTreenode identified by a givenTreePath.static TreesReturns aTreesobject for a givenProcessingEnvironment.static TreesReturns aTreesobject for a givenCompilationTask.abstract booleanisAccessible(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 booleanisAccessible(Scope scope, TypeElement type) Checks whether a given type is accessible in a given scope.abstract voidprintMessage(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 unitMethods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Constructor Details
-
Trees
public Trees()Constructor for subclasses to call.
-
-
Method Details
-
instance
Returns aTreesobject for a givenCompilationTask.- Parameters:
task- the compilation task for which to get theTreesobject- Returns:
- the
Treesobject - Throws:
IllegalArgumentException- if the task does not support the Tree API.
-
instance
Returns aTreesobject for a givenProcessingEnvironment.- Parameters:
env- the processing environment for which to get theTreesobject- Returns:
- the
Treesobject - 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 theClassTreenode for a givenTypeElement. Returnsnullif the node can not be found.- Parameters:
element- the element- Returns:
- the class tree node
-
getTree
Returns theMethodTreenode for a givenExecutableElement. Returnsnullif the node can not be found.- Parameters:
method- the executable element- Returns:
- the method tree node
-
getTree
Returns theTreenode for anAnnotationMirroron a givenElement. Returnsnullif the node can not be found.- Parameters:
e- the elementa- the annotation mirror- Returns:
- the tree node
-
getTree
Returns theTreenode for anAnnotationValuefor anAnnotationMirroron a givenElement. Returnsnullif 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 theTreePathnode for anAnnotationMirroron a givenElement. Returnsnullif the node can not be found.- Parameters:
e- the elementa- the annotation mirror- Returns:
- the tree path
-
getPath
Returns theTreePathnode for anAnnotationValuefor anAnnotationMirroron a givenElement. Returnsnullif the node can not be found.- Parameters:
e- the elementa- the annotation mirrorv- the annotation value- Returns:
- the tree path
-
getElement
Returns theElementfor theTreenode identified by a givenTreePath. Returnsnullif the element is not available.- Parameters:
path- the tree path- Returns:
- the element
- Throws:
IllegalArgumentException- is theTreePathdoes not identify aTreenode that might have an associatedElement.
-
getTypeMirror
Returns theTypeMirrorfor theTreenode identified by a givenTreePath. Returnsnullif theTypeMirroris not available.- Parameters:
path- the tree path- Returns:
- the type mirror
- Throws:
IllegalArgumentException- is theTreePathdoes not identify aTreenode 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
typeis 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
memberis accessible intype
-
getOriginalType
Returns the original type from theErrorTypeobject.- 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
-