Constructor and Description |
---|
AnnotatedTypes(ProcessingEnvironment env,
AnnotatedTypeFactory factory)
Constructor for
AnnotatedTypes |
Modifier and Type | Method and Description |
---|---|
void |
annotateAsLub(@Mutable AnnotatedTypeMirror lub,
Collection<@Mutable AnnotatedTypeMirror> types)
Annotate the lub type as if it is the least upper bound of the rest of
the types.
|
boolean |
areSame(@Mutable AnnotatedTypeMirror t1,
@Mutable AnnotatedTypeMirror t2) |
@Mutable AnnotatedTypeMirror |
asMemberOf(@Mutable AnnotatedTypeMirror t,
@Nullable 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.
|
AnnotatedTypeMirror.AnnotatedExecutableType |
asMemberOf(@Mutable AnnotatedTypeMirror t,
@NonNull ExecutableElement elem) |
@Mutable AnnotatedTypeMirror |
assignedTo(@Nullable TreePath path)
Returns the annotated type that the leaf of path is assigned to, if it
is within an assignment context
Returns the annotated type that the method invocation at the leaf
is assigned to.
|
@Mutable AnnotatedTypeMirror |
asSuper(@Mutable AnnotatedTypeMirror t,
@Mutable AnnotatedTypeMirror superType)
Returns the most specific base type of
t whose erasure type
is superType . |
static boolean |
containsModifier(@Mutable AnnotatedTypeMirror type,
@Nullable AnnotationMirror modifier)
Checks whether type contains the given modifier, also recursively in type arguments and arrays.
|
static boolean |
containsTypeAnnotation(Collection<? extends @Nullable AnnotationMirror> annos) |
static <ATM extends @Mutable AnnotatedTypeMirror> |
deepCopy(ATM type)
Returns a deep copy of the passed type.
|
List<@Mutable AnnotatedTypeMirror> |
expandVarArgs(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.
|
Map<AnnotatedTypeMirror.AnnotatedTypeVariable,@Mutable AnnotatedTypeMirror> |
findTypeArguments(ExpressionTree expr)
Given a method or constructor invocation, return a mapping
of the type variables to their type arguments, if any exist.
|
List<@Mutable AnnotatedTypeMirror> |
getAnnotatedTypes(List<@Mutable AnnotatedTypeMirror> paramTypes,
List<? extends ExpressionTree> trees)
Return a list of the AnnotatedTypeMirror of the passed
expression trees, in the same order as the trees.
|
int |
getArrayDepth(AnnotatedTypeMirror.AnnotatedArrayType array)
Returns the depth of the array type of the provided array.
|
@Mutable AnnotatedTypeMirror |
getIteratedType(@Mutable AnnotatedTypeMirror iterableType)
Returns the iterated type of the passed iterable type, and throws
IllegalArgumentException if the passed type is not iterable. |
Set<AnnotatedTypeMirror.AnnotatedDeclaredType> |
getSuperTypes(AnnotatedTypeMirror.AnnotatedDeclaredType type)
Returns all the super types of the given declared type.
|
static @Mutable AnnotatedTypeMirror |
innerMostType(@Mutable AnnotatedTypeMirror t) |
boolean |
isAnonymousType(@Mutable AnnotatedTypeMirror type)
Determines if the type is for an anonymous type or not
|
boolean |
isIntersectType(@Mutable AnnotatedTypeMirror type)
Determines if the type is for an intersect type or not
|
static boolean |
isTypeAnnotation(@Nullable AnnotationMirror anno) |
Map<AnnotatedTypeMirror.AnnotatedDeclaredType,@NonNull ExecutableElement> |
overriddenMethods(@NonNull ExecutableElement method)
A utility method that takes a Method element and returns a set
of all elements that this method overrides (as
ExecutableElement s) |
Map<AnnotatedTypeMirror.AnnotatedDeclaredType,@NonNull ExecutableElement> |
overriddenMethods(@NonNull 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). |
@Mutable AnnotatedTypeMirror |
subst(@Mutable AnnotatedTypeMirror t,
List<? extends @Mutable AnnotatedTypeMirror> from,
List<? extends @Mutable AnnotatedTypeMirror> to)
Returns a new type, a copy of the passed
t , with all
instances of from type substituted with their correspondents
in to . |
@ReadOnly String |
toString() |
public AnnotatedTypes(ProcessingEnvironment env, AnnotatedTypeFactory factory)
AnnotatedTypes
env
- the processing environment for this roundpublic @Mutable AnnotatedTypeMirror asSuper(@Mutable AnnotatedTypeMirror t, @Mutable AnnotatedTypeMirror superType)
t
whose erasure type
is superType
. It returns null if t
is not a subtype
of superType
.t
- a typesuperType
- a type that is a supertype of t
public AnnotatedTypeMirror.AnnotatedExecutableType asMemberOf(@Mutable AnnotatedTypeMirror t, @NonNull ExecutableElement elem)
public @Mutable AnnotatedTypeMirror asMemberOf(@Mutable AnnotatedTypeMirror t, @Nullable 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 @Mutable AnnotatedTypeMirror subst(@Mutable AnnotatedTypeMirror t, List<? extends @Mutable AnnotatedTypeMirror> from, List<? extends @Mutable 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 @Mutable AnnotatedTypeMirror> ATM deepCopy(ATM type)
type
- the annotated type to be copiedpublic @Mutable AnnotatedTypeMirror getIteratedType(@Mutable 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 Set<AnnotatedTypeMirror.AnnotatedDeclaredType> getSuperTypes(AnnotatedTypeMirror.AnnotatedDeclaredType type)
type
- a declared typepublic Map<AnnotatedTypeMirror.AnnotatedDeclaredType,@NonNull ExecutableElement> overriddenMethods(@NonNull ExecutableElement method)
ExecutableElement
s)method
- the overriding methodExecutableElement
s
representing the elements that method overridespublic Map<AnnotatedTypeMirror.AnnotatedDeclaredType,@NonNull ExecutableElement> overriddenMethods(@NonNull 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 Map<AnnotatedTypeMirror.AnnotatedTypeVariable,@Mutable AnnotatedTypeMirror> findTypeArguments(ExpressionTree expr)
expr
- the method or constructor invocation tree; the passed argument
has to be a subtype of MethodInvocationTree or NewClassTree.public @Mutable AnnotatedTypeMirror assignedTo(@Nullable TreePath path)
path
- public boolean isAnonymousType(@Mutable AnnotatedTypeMirror type)
type
- type to be checkedpublic boolean isIntersectType(@Mutable AnnotatedTypeMirror type)
type
- type to be checkedpublic void annotateAsLub(@Mutable AnnotatedTypeMirror lub, Collection<@Mutable AnnotatedTypeMirror> types)
lub
- the type to be the least upper boundtypes
- the type argumentspublic List<@Mutable AnnotatedTypeMirror> expandVarArgs(AnnotatedTypeMirror.AnnotatedExecutableType method, List<? extends ExpressionTree> args)
method
- the method's typeargs
- the arguments to the method invocationpublic List<@Mutable AnnotatedTypeMirror> getAnnotatedTypes(List<@Mutable AnnotatedTypeMirror> paramTypes, List<? extends ExpressionTree> trees)
paramTypes
- The parameter types to use as assignment contexttrees
- the AST nodespublic boolean areSame(@Mutable AnnotatedTypeMirror t1, @Mutable AnnotatedTypeMirror t2)
public int getArrayDepth(AnnotatedTypeMirror.AnnotatedArrayType array)
array
- the type of the arraypublic static @Mutable AnnotatedTypeMirror innerMostType(@Mutable AnnotatedTypeMirror t)
public static boolean containsModifier(@Mutable AnnotatedTypeMirror type, @Nullable AnnotationMirror modifier)
AnnotatedTypeMirror.hasAnnotation(AnnotationMirror)
.type
- the type to search.modifier
- the modifier to search for.public static boolean isTypeAnnotation(@Nullable AnnotationMirror anno)
public static boolean containsTypeAnnotation(Collection<? extends @Nullable AnnotationMirror> annos)