Modifier and Type | Method and Description |
---|---|
static void |
annotateAsLub(ProcessingEnvironment processingEnv,
AnnotatedTypeFactory atypeFactory,
AnnotatedTypeMirror lub,
Collection<AnnotatedTypeMirror> types)
Annotate the lub type as if it is the least upper bound of the rest of
the types.
|
static boolean |
areSame(AnnotatedTypeMirror t1,
AnnotatedTypeMirror t2) |
static AnnotatedTypeMirror |
asMemberOf(Types types,
AnnotatedTypeFactory atypeFactory,
AnnotatedTypeMirror t,
Element elem)
Returns the type of an element when that element is viewed as a member
of, or otherwise directly contained by, a given type.
|
static AnnotatedTypeMirror.AnnotatedExecutableType |
asMemberOf(Types types,
AnnotatedTypeFactory atypeFactory,
AnnotatedTypeMirror t,
ExecutableElement elem) |
static AnnotatedTypeMirror |
asSuper(Types types,
AnnotatedTypeFactory atypeFactory,
AnnotatedTypeMirror t,
AnnotatedTypeMirror superType)
Returns the most specific base type of
t whose erasure type
is superType . |
static boolean |
containsModifier(AnnotatedTypeMirror type,
AnnotationMirror modifier)
Checks whether type contains the given modifier, also recursively in type arguments and arrays.
|
static boolean |
containsTypeAnnotation(Collection<? extends AnnotationMirror> annos) |
static <ATM extends AnnotatedTypeMirror> |
deepCopy(ATM type)
Returns a deep copy of the passed type.
|
static List<AnnotatedTypeMirror> |
expandVarArgs(AnnotatedTypeFactory atypeFactory,
AnnotatedTypeMirror.AnnotatedExecutableType method,
List<? extends ExpressionTree> args)
Returns the method parameters for the invoked method, with the same number
of arguments passed in the methodInvocation tree.
|
static Map<AnnotatedTypeMirror.AnnotatedTypeVariable,AnnotatedTypeMirror> |
findTypeArguments(ProcessingEnvironment processingEnv,
AnnotatedTypeFactory atypeFactory,
ExpressionTree expr)
Given a method or constructor invocation, return a mapping
of the type variables to their type arguments, if any exist.
|
static List<AnnotatedTypeMirror> |
getAnnotatedTypes(AnnotatedTypeFactory atypeFactory,
List<AnnotatedTypeMirror> paramTypes,
List<? extends ExpressionTree> trees)
Return a list of the AnnotatedTypeMirror of the passed
expression trees, in the same order as the trees.
|
static int |
getArrayDepth(AnnotatedTypeMirror.AnnotatedArrayType array)
Returns the depth of the array type of the provided array.
|
static AnnotatedTypeMirror |
getIteratedType(ProcessingEnvironment processingEnv,
AnnotatedTypeFactory atypeFactory,
AnnotatedTypeMirror iterableType)
Returns the iterated type of the passed iterable type, and throws
IllegalArgumentException if the passed type is not iterable. |
static Set<AnnotatedTypeMirror.AnnotatedDeclaredType> |
getSuperTypes(AnnotatedTypeMirror.AnnotatedDeclaredType type)
Returns all the super types of the given declared type.
|
static AnnotatedTypeMirror |
innerMostType(AnnotatedTypeMirror t) |
static boolean |
isTypeAnnotation(AnnotationMirror anno) |
static Map<AnnotatedTypeMirror.AnnotatedDeclaredType,ExecutableElement> |
overriddenMethods(Elements elements,
AnnotatedTypeFactory atypeFactory,
ExecutableElement method)
A utility method that takes a Method element and returns a set
of all elements that this method overrides (as
ExecutableElement s) |
static Map<AnnotatedTypeMirror.AnnotatedDeclaredType,ExecutableElement> |
overriddenMethods(Elements elements,
ExecutableElement method,
Collection<AnnotatedTypeMirror.AnnotatedDeclaredType> supertypes)
A utility method that takes the element for a method and the
set of all supertypes of the method's containing class and
returns the set of all elements that method overrides (as
ExecutableElement s). |
static AnnotatedTypeMirror |
subst(AnnotatedTypeMirror t,
List<? extends AnnotatedTypeMirror> from,
List<? extends AnnotatedTypeMirror> to)
Returns a new type, a copy of the passed
t , with all
instances of from type substituted with their correspondents
in to . |
public static AnnotatedTypeMirror asSuper(Types types, AnnotatedTypeFactory atypeFactory, AnnotatedTypeMirror t, AnnotatedTypeMirror superType)
t
whose erasure type
is superType
. It returns null if t
is not a subtype
of superType
.types
- the type utilities to useatypeFactory
- the type factory to uset
- a typesuperType
- a type that is a supertype of t
public static AnnotatedTypeMirror.AnnotatedExecutableType asMemberOf(Types types, AnnotatedTypeFactory atypeFactory, AnnotatedTypeMirror t, ExecutableElement elem)
#asMemberOf(AnnotatedTypeMirror, Element)
public static AnnotatedTypeMirror asMemberOf(Types types, AnnotatedTypeFactory atypeFactory, AnnotatedTypeMirror t, Element elem)
Set<@NonNull String>
, the Set.add
method is an
ExecutableType
whose parameter is of type
@NonNull String
.
The result is customized according to the type system semantics,
according to AnnotatedTypeFactory.postAsMemberOf(
AnnotatedTypeMirror, AnnotatedTypeMirror, Element)
.t
- a typeelem
- an elementpublic static AnnotatedTypeMirror subst(AnnotatedTypeMirror t, List<? extends AnnotatedTypeMirror> from, List<? extends AnnotatedTypeMirror> to)
t
, with all
instances of from
type substituted with their correspondents
in to
.t
- the typefrom
- the from typesto
- the to typespublic static <ATM extends AnnotatedTypeMirror> ATM deepCopy(ATM type)
type
- the annotated type to be copiedpublic static AnnotatedTypeMirror getIteratedType(ProcessingEnvironment processingEnv, AnnotatedTypeFactory atypeFactory, AnnotatedTypeMirror iterableType)
IllegalArgumentException
if the passed type is not iterable.
The iterated type is the component type of an array, and the type
argument of Iterable
for declared types.iterableType
- the iterable type (either array or declared)public static Set<AnnotatedTypeMirror.AnnotatedDeclaredType> getSuperTypes(AnnotatedTypeMirror.AnnotatedDeclaredType type)
type
- a declared typepublic static Map<AnnotatedTypeMirror.AnnotatedDeclaredType,ExecutableElement> overriddenMethods(Elements elements, AnnotatedTypeFactory atypeFactory, ExecutableElement method)
ExecutableElement
s)method
- the overriding methodExecutableElement
s
representing the elements that method overridespublic static Map<AnnotatedTypeMirror.AnnotatedDeclaredType,ExecutableElement> overriddenMethods(Elements elements, ExecutableElement method, Collection<AnnotatedTypeMirror.AnnotatedDeclaredType> supertypes)
ExecutableElement
s).method
- the overriding methodsupertypes
- the set of supertypes to check for methods that are
overridden by method
ExecutableElement
s
representing the elements that method
overrides
among supertypes
public static Map<AnnotatedTypeMirror.AnnotatedTypeVariable,AnnotatedTypeMirror> findTypeArguments(ProcessingEnvironment processingEnv, AnnotatedTypeFactory atypeFactory, ExpressionTree expr)
expr
- the method or constructor invocation tree; the passed argument
has to be a subtype of MethodInvocationTree or NewClassTree.public static void annotateAsLub(ProcessingEnvironment processingEnv, AnnotatedTypeFactory atypeFactory, AnnotatedTypeMirror lub, Collection<AnnotatedTypeMirror> types)
lub
- the type to be the least upper boundtypes
- the type argumentspublic static List<AnnotatedTypeMirror> expandVarArgs(AnnotatedTypeFactory atypeFactory, AnnotatedTypeMirror.AnnotatedExecutableType method, List<? extends ExpressionTree> args)
method
- the method's typeargs
- the arguments to the method invocationpublic static List<AnnotatedTypeMirror> getAnnotatedTypes(AnnotatedTypeFactory atypeFactory, List<AnnotatedTypeMirror> paramTypes, List<? extends ExpressionTree> trees)
paramTypes
- The parameter types to use as assignment contexttrees
- the AST nodespublic static boolean areSame(AnnotatedTypeMirror t1, AnnotatedTypeMirror t2)
public static int getArrayDepth(AnnotatedTypeMirror.AnnotatedArrayType array)
array
- the type of the arraypublic static AnnotatedTypeMirror innerMostType(AnnotatedTypeMirror t)
public static boolean containsModifier(AnnotatedTypeMirror type, AnnotationMirror modifier)
AnnotatedTypeMirror.hasAnnotation(AnnotationMirror)
.type
- the type to search.modifier
- the modifier to search for.public static boolean isTypeAnnotation(AnnotationMirror anno)
public static boolean containsTypeAnnotation(Collection<? extends AnnotationMirror> annos)