public class InternalUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static javax.lang.model.element.AnnotationMirror |
annotationFromAnnotationTree(com.sun.source.tree.AnnotationTree tree) |
static java.util.List<? extends javax.lang.model.element.AnnotationMirror> |
annotationsFromArrayCreation(com.sun.source.tree.NewArrayTree node,
int level) |
static java.util.List<? extends javax.lang.model.element.AnnotationMirror> |
annotationsFromTree(com.sun.source.tree.AnnotatedTypeTree node) |
static java.util.List<? extends javax.lang.model.element.AnnotationMirror> |
annotationsFromTree(com.sun.source.tree.TypeParameterTree node) |
static java.util.List<javax.lang.model.element.AnnotationMirror> |
annotationsFromTypeAnnotationTrees(java.util.List<? extends com.sun.source.tree.AnnotationTree> annos) |
static int |
compareDiagnosticPosition(com.sun.source.tree.Tree tree1,
com.sun.source.tree.Tree tree2)
Compares tree1 to tree2 by the position at which a diagnostic (e.g., an error message) for
the tree should be printed.
|
static javax.lang.model.element.ExecutableElement |
constructor(com.sun.source.tree.NewClassTree tree)
Determines the symbol for a constructor given an invocation via
new . |
static com.sun.tools.javac.code.Symbol |
findFunction(com.sun.source.tree.Tree tree,
javax.annotation.processing.ProcessingEnvironment env)
The type of the lambda or method reference tree is a functional interface type.
|
static javax.lang.model.type.WildcardType |
getCapturedWildcard(javax.lang.model.type.TypeVariable typeVar)
If typeVar is a captured wildcard, returns that wildcard; otherwise returns null.
|
static java.lang.ClassLoader |
getClassLoaderForClass(java.lang.Class<? extends java.lang.Object> clazz)
Obtain the class loader for
clazz . |
static com.sun.tools.javac.util.Context |
getJavacContext(javax.annotation.processing.ProcessingEnvironment env)
Helper function to extract the javac Context from the javac processing environment.
|
static javax.lang.model.element.TypeElement |
getTypeElement(javax.lang.model.type.TypeMirror type)
Returns the type element for
type if type is a class, interface, annotation
type, or enum. |
static javax.lang.model.type.TypeMirror |
greatestLowerBound(javax.annotation.processing.ProcessingEnvironment processingEnv,
javax.lang.model.type.TypeMirror tm1,
javax.lang.model.type.TypeMirror tm2)
Returns the greatest lower bound of two
TypeMirror s, ignoring any annotations on the
types. |
static boolean |
isAnonymousConstructor(com.sun.source.tree.MethodTree method)
Determines whether or not the node referred to by the given
TreePath is an anonymous
constructor (the constructor for an anonymous class. |
static boolean |
isCaptured(javax.lang.model.type.TypeVariable typeVar)
Returns whether a TypeVariable represents a captured type.
|
static boolean |
isClassType(javax.lang.model.type.TypeMirror type)
Returns whether a TypeMirror represents a class type.
|
static boolean |
isFunctionalInterface(javax.lang.model.type.TypeMirror type,
javax.annotation.processing.ProcessingEnvironment env)
Returns whether or not
type is a functional interface type (as defined in JLS 9.8). |
static javax.lang.model.type.TypeMirror |
leastUpperBound(javax.annotation.processing.ProcessingEnvironment processingEnv,
javax.lang.model.type.TypeMirror tm1,
javax.lang.model.type.TypeMirror tm2)
Returns the least upper bound of two
TypeMirror s, ignoring any annotations on the
types. |
static javax.lang.model.type.TypeMirror |
substituteMethodReturnType(javax.annotation.processing.ProcessingEnvironment env,
javax.lang.model.element.Element methodElement,
javax.lang.model.type.TypeMirror substitutedReceiverType)
Returns the return type of a method, given the receiver of the method call.
|
static @Nullable javax.lang.model.element.Element |
symbol(com.sun.source.tree.Tree tree)
Gets the
Element ("symbol") for the given Tree API node. |
static javax.lang.model.type.TypeMirror |
typeOf(com.sun.source.tree.Tree tree) |
public static @Nullable javax.lang.model.element.Element symbol(com.sun.source.tree.Tree tree)
Element
("symbol") for the given Tree API node.tree
- the Tree
node to get the symbol forSymbol
for the given tree, or null if one could not be foundjava.lang.IllegalArgumentException
- if tree
is null or is not a valid javac-internal
tree (JCTree)public static boolean isAnonymousConstructor(com.sun.source.tree.MethodTree method)
TreePath
is an anonymous
constructor (the constructor for an anonymous class.method
- the TreePath
for a node that may be an anonymous constructorpublic static javax.lang.model.element.ExecutableElement constructor(com.sun.source.tree.NewClassTree tree)
new
.
If the tree is a declaration of an anonymous class, then method returns constructor that gets invoked in the extended class, rather than the anonymous constructor implicitly added by the constructor (JLS 15.9.5.1)
tree
- the constructor invocationExecutableElement
corresponding to the constructor call in tree
public static final java.util.List<javax.lang.model.element.AnnotationMirror> annotationsFromTypeAnnotationTrees(java.util.List<? extends com.sun.source.tree.AnnotationTree> annos)
public static javax.lang.model.element.AnnotationMirror annotationFromAnnotationTree(com.sun.source.tree.AnnotationTree tree)
public static final java.util.List<? extends javax.lang.model.element.AnnotationMirror> annotationsFromTree(com.sun.source.tree.AnnotatedTypeTree node)
public static final java.util.List<? extends javax.lang.model.element.AnnotationMirror> annotationsFromTree(com.sun.source.tree.TypeParameterTree node)
public static final java.util.List<? extends javax.lang.model.element.AnnotationMirror> annotationsFromArrayCreation(com.sun.source.tree.NewArrayTree node, int level)
public static javax.lang.model.type.TypeMirror typeOf(com.sun.source.tree.Tree tree)
public static boolean isCaptured(javax.lang.model.type.TypeVariable typeVar)
public static javax.lang.model.type.WildcardType getCapturedWildcard(javax.lang.model.type.TypeVariable typeVar)
public static boolean isClassType(javax.lang.model.type.TypeMirror type)
public static javax.lang.model.type.TypeMirror leastUpperBound(javax.annotation.processing.ProcessingEnvironment processingEnv, javax.lang.model.type.TypeMirror tm1, javax.lang.model.type.TypeMirror tm2)
TypeMirror
s, ignoring any annotations on the
types.
Wrapper around Types.lub to add special handling for null types, primitives, and wildcards.
processingEnv
- the ProcessingEnvironment
to usetm1
- a TypeMirror
tm2
- a TypeMirror
tm1
and tm2
.public static javax.lang.model.type.TypeMirror greatestLowerBound(javax.annotation.processing.ProcessingEnvironment processingEnv, javax.lang.model.type.TypeMirror tm1, javax.lang.model.type.TypeMirror tm2)
TypeMirror
s, ignoring any annotations on the
types.
Wrapper around Types.glb to add special handling for null types, primitives, and wildcards.
processingEnv
- the ProcessingEnvironment
to usetm1
- a TypeMirror
tm2
- a TypeMirror
tm1
and tm2
.public static javax.lang.model.type.TypeMirror substituteMethodReturnType(javax.annotation.processing.ProcessingEnvironment env, javax.lang.model.element.Element methodElement, javax.lang.model.type.TypeMirror substitutedReceiverType)
public static com.sun.tools.javac.util.Context getJavacContext(javax.annotation.processing.ProcessingEnvironment env)
env
- the processing environmentpublic static javax.lang.model.element.TypeElement getTypeElement(javax.lang.model.type.TypeMirror type)
type
if type
is a class, interface, annotation
type, or enum. Otherwise, returns null.type
- whose element is returnedtype
if type
is a class, interface, annotation
type, or enum; otherwise, returns nullpublic static java.lang.ClassLoader getClassLoaderForClass(java.lang.Class<? extends java.lang.Object> clazz)
clazz
. If that is not available, return the system class
loader.clazz
- the class whose class loader to findclazz
, or the system class loader, or null if both
are unavailablepublic static int compareDiagnosticPosition(com.sun.source.tree.Tree tree1, com.sun.source.tree.Tree tree2)
public static boolean isFunctionalInterface(javax.lang.model.type.TypeMirror type, javax.annotation.processing.ProcessingEnvironment env)
type
is a functional interface type (as defined in JLS 9.8).type
- possible functional interface typeenv
- ProcessingEnvironmenttype
is a functional interface type (as defined in JLS 9.8)public static com.sun.tools.javac.code.Symbol findFunction(com.sun.source.tree.Tree tree, javax.annotation.processing.ProcessingEnvironment env)
tree
- lambda or member reference treeenv
- ProcessingEnvironment