public class InternalUtils extends Object
Modifier and Type | Method and Description |
---|---|
static List<? extends AnnotationMirror> |
annotationsFromArrayCreation(NewArrayTree node,
int level) |
static List<? extends AnnotationMirror> |
annotationsFromTree(AnnotatedTypeTree node) |
static List<? extends AnnotationMirror> |
annotationsFromTree(TypeParameterTree node) |
static List<AnnotationMirror> |
annotationsFromTypeAnnotationTrees(List<? extends AnnotationTree> annos) |
static ExecutableElement |
constructor(NewClassTree tree)
Determines the symbol for a constructor given an invocation via
new . |
static WildcardType |
getCapturedWildcard(TypeVariable typeVar)
If typeVar is a captured wildcard, returns that wildcard; otherwise returns null.
|
static ClassLoader |
getClassLoaderForClass(Class<? extends Object> clazz)
Obtain the class loader for
clazz . |
static com.sun.tools.javac.util.Context |
getJavacContext(ProcessingEnvironment env)
Helper function to extract the javac Context from the javac processing environment.
|
static TypeElement |
getTypeElement(TypeMirror type) |
static TypeMirror |
greatestLowerBound(ProcessingEnvironment processingEnv,
TypeMirror tm1,
TypeMirror tm2)
Returns the greatest lower bound of two
TypeMirror s, ignoring any annotations on the
types. |
static boolean |
isAnonymousConstructor(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(TypeVariable typeVar)
Returns whether a TypeVariable represents a captured type.
|
static boolean |
isClassType(TypeMirror type)
Returns whether a TypeMirror represents a class type.
|
static TypeMirror |
leastUpperBound(ProcessingEnvironment processingEnv,
TypeMirror tm1,
TypeMirror tm2)
Returns the least upper bound of two
TypeMirror s, ignoring any annotations on the
types. |
static TypeMirror |
substituteMethodReturnType(TypeMirror methodType,
TypeMirror substitutedReceiverType)
Returns the return type of a method, where the "raw" return type of that method is given
(i.e., the return type might still contain unsubstituted type variables), given the receiver
of the method call.
|
static @Nullable Element |
symbol(Tree tree)
Gets the
Element ("symbol") for the given Tree API node. |
static TypeMirror |
typeOf(Tree tree) |
public static @Nullable Element symbol(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 foundIllegalArgumentException
- if tree
is null or is not a valid javac-internal
tree (JCTree)public static boolean isAnonymousConstructor(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 ExecutableElement constructor(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 List<AnnotationMirror> annotationsFromTypeAnnotationTrees(List<? extends AnnotationTree> annos)
public static final List<? extends AnnotationMirror> annotationsFromTree(AnnotatedTypeTree node)
public static final List<? extends AnnotationMirror> annotationsFromTree(TypeParameterTree node)
public static final List<? extends AnnotationMirror> annotationsFromArrayCreation(NewArrayTree node, int level)
public static TypeMirror typeOf(Tree tree)
public static boolean isCaptured(TypeVariable typeVar)
public static WildcardType getCapturedWildcard(TypeVariable typeVar)
public static boolean isClassType(TypeMirror type)
public static TypeMirror leastUpperBound(ProcessingEnvironment processingEnv, TypeMirror tm1, 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 TypeMirror greatestLowerBound(ProcessingEnvironment processingEnv, TypeMirror tm1, 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 TypeMirror substituteMethodReturnType(TypeMirror methodType, TypeMirror substitutedReceiverType)
public static com.sun.tools.javac.util.Context getJavacContext(ProcessingEnvironment env)
env
- the processing environmentpublic static TypeElement getTypeElement(TypeMirror type)
public static ClassLoader getClassLoaderForClass(Class<? extends 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 unavailable