|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object checkers.types.AnnotatedTypes
public class AnnotatedTypes extends Object
Utility methods for operating on AnnotatedTypeMirror
. This
class mimics the class Types
.
Constructor and Description |
---|
AnnotatedTypes(ProcessingEnvironment env,
AnnotatedTypeFactory factory)
Constructor for AnnotatedTypeUtils |
Modifier and Type | Method and Description |
---|---|
void |
annotateAsLub(AnnotatedTypeMirror lub,
AnnotatedTypeMirror... types)
Annotate the lub type as if it is the least upper bound of the rest of the types. |
AnnotatedTypeMirror |
asMemberOf(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. |
AnnotatedTypeMirror.AnnotatedExecutableType |
asMemberOf(AnnotatedTypeMirror t,
ExecutableElement elem)
|
AnnotatedTypeMirror |
assignedTo(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. |
AnnotatedTypeMirror |
asSuper(AnnotatedTypeMirror t,
AnnotatedTypeMirror superType)
Returns the most specific base type of t whose erasure type
is superType . |
AnnotatedTypeMirror |
deepCopy(AnnotatedTypeMirror type)
Returns a deep copy of the passed type |
List<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,AnnotatedTypeMirror> |
findTypeArguments(MethodInvocationTree methodInvocation)
Given a method method invocation, it returns a mapping of the type variables to their parameters if any exist. |
List<AnnotatedTypeMirror> |
getAnnotatedTypes(Iterable<? 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. |
AnnotatedTypeMirror |
getIteratedType(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. |
boolean |
isAnonymousType(AnnotatedTypeMirror type)
Determines if the type is for an anonymous type or not |
boolean |
isIntersectType(AnnotatedTypeMirror type)
Determines if the type is for an intersect type or not |
Map<AnnotatedTypeMirror.AnnotatedDeclaredType,ExecutableElement> |
overriddenMethods(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,ExecutableElement> |
overriddenMethods(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). |
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 and return the substituted in type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AnnotatedTypes(ProcessingEnvironment env, AnnotatedTypeFactory factory)
AnnotatedTypeUtils
env
- the processing environment for this roundMethod Detail |
---|
public AnnotatedTypeMirror asSuper(AnnotatedTypeMirror t, 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 type
public AnnotatedTypeMirror.AnnotatedExecutableType asMemberOf(AnnotatedTypeMirror t, ExecutableElement elem)
asMemberOf(AnnotatedTypeMirror, Element)
public AnnotatedTypeMirror asMemberOf(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 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
and return the substituted in type.
t
- the typefrom
- the from typesto
- the to typespublic AnnotatedTypeMirror deepCopy(AnnotatedTypeMirror type)
type
- the annotated type to be copiedpublic AnnotatedTypeMirror getIteratedType(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,ExecutableElement> overriddenMethods(ExecutableElement method)
ExecutableElement
s)
method
- the overriding methodExecutableElement
s
representing the elements that method overridespublic Map<AnnotatedTypeMirror.AnnotatedDeclaredType,ExecutableElement> overriddenMethods(ExecutableElement method, Collection<AnnotatedTypeMirror.AnnotatedDeclaredType> supertypes)
ExecutableElement
s).
method
- the overriding methodsupertypes
- the set of supertypes to check for methods that are
overriden by method
ExecutableElement
s
representing the elements that method
overrides
among supertypes
public Map<AnnotatedTypeMirror.AnnotatedTypeVariable,AnnotatedTypeMirror> findTypeArguments(MethodInvocationTree methodInvocation)
methodInvocation
- the method invocation treepublic AnnotatedTypeMirror assignedTo(TreePath path)
path
- public boolean isAnonymousType(AnnotatedTypeMirror type)
type
- type to be checkedpublic boolean isIntersectType(AnnotatedTypeMirror type)
type
- type to be checkedpublic void annotateAsLub(AnnotatedTypeMirror lub, AnnotatedTypeMirror... types)
lub
- the type to be the least upper boundtypes
- the type argumentspublic int getArrayDepth(AnnotatedTypeMirror.AnnotatedArrayType array)
array
- the type of the arraypublic List<AnnotatedTypeMirror> expandVarArgs(AnnotatedTypeMirror.AnnotatedExecutableType method, List<? extends ExpressionTree> args)
method
- the method's typeargs
- the arguments to the method invocationpublic List<AnnotatedTypeMirror> getAnnotatedTypes(Iterable<? extends ExpressionTree> trees)
trees
- the AST nodes
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |