Class AnnotatedTypeFactory.CapturedTypeVarSubstitutor
java.lang.Object
org.checkerframework.framework.type.AnnotatedTypeCopier
org.checkerframework.framework.type.AnnotatedTypeFactory.CapturedTypeVarSubstitutor
- All Implemented Interfaces:
AnnotatedTypeVisitor<AnnotatedTypeMirror,
IdentityHashMap<AnnotatedTypeMirror, AnnotatedTypeMirror>>
- Enclosing class:
- AnnotatedTypeFactory
Substitutes references to captured types in
type
using
capturedTypeVarToAnnotatedTypeVar
.
Unlike AnnotatedTypeFactory.typeVarSubstitutor
, this class does not copy the type. Call
substitute
to use.
-
Field Summary
Fields inherited from class org.checkerframework.framework.type.AnnotatedTypeCopier
copyAnnotations, visitingExecutableTypeParam
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected <T extends AnnotatedTypeMirror>
TmakeOrReturnCopy
(T original, IdentityHashMap<AnnotatedTypeMirror, AnnotatedTypeMirror> originalToCopy) For any given object in the type being copied, we only want to generate one copy of that object.void
substitute
(AnnotatedTypeMirror.AnnotatedTypeVariable type, Map<TypeVariable, AnnotatedTypeMirror.AnnotatedTypeVariable> capturedTypeVarToAnnotatedTypeVar) Substitutes references to captured type variable intype
usingcapturedTypeVarToAnnotatedTypeVar
.visitTypeVariable
(AnnotatedTypeMirror.AnnotatedTypeVariable original, IdentityHashMap<AnnotatedTypeMirror, AnnotatedTypeMirror> originalToCopy) Visits a type variable.Methods inherited from class org.checkerframework.framework.type.AnnotatedTypeCopier
makeCopy, maybeCopyPrimaryAnnotations, visit, visit, visitArray, visitDeclared, visitExecutable, visitIntersection, visitNoType, visitNull, visitPrimitive, visitUnion, visitWildcard
-
Constructor Details
-
CapturedTypeVarSubstitutor
public CapturedTypeVarSubstitutor()Creates a CapturedTypeVarSubstitutor.
-
-
Method Details
-
substitute
public void substitute(AnnotatedTypeMirror.AnnotatedTypeVariable type, Map<TypeVariable, AnnotatedTypeMirror.AnnotatedTypeVariable> capturedTypeVarToAnnotatedTypeVar) Substitutes references to captured type variable intype
usingcapturedTypeVarToAnnotatedTypeVar
.Unlike
AnnotatedTypeFactory.typeVarSubstitutor
, this method does not copy the type.- Parameters:
type
- the type whose captured type variables are substituted with those incapturedTypeVarToAnnotatedTypeVar
capturedTypeVarToAnnotatedTypeVar
- mapping from a TypeVariable (which is a captured type variable) to an AnnotatedTypeVariable
-
visitTypeVariable
public AnnotatedTypeMirror visitTypeVariable(AnnotatedTypeMirror.AnnotatedTypeVariable original, IdentityHashMap<AnnotatedTypeMirror, AnnotatedTypeMirror> originalToCopy) Description copied from interface:AnnotatedTypeVisitor
Visits a type variable.- Specified by:
visitTypeVariable
in interfaceAnnotatedTypeVisitor<AnnotatedTypeMirror,
IdentityHashMap<AnnotatedTypeMirror, AnnotatedTypeMirror>> - Overrides:
visitTypeVariable
in classAnnotatedTypeCopier
- Parameters:
original
- the type to visitoriginalToCopy
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
makeOrReturnCopy
protected <T extends AnnotatedTypeMirror> T makeOrReturnCopy(T original, IdentityHashMap<AnnotatedTypeMirror, AnnotatedTypeMirror> originalToCopy) Description copied from class:AnnotatedTypeCopier
For any given object in the type being copied, we only want to generate one copy of that object. When that object is encountered again, using the previously generated copy will preserve the structure of the original AnnotatedTypeMirror.makeOrReturnCopy first checks to see if an object has been encountered before. If so, it returns the previously generated duplicate of that object if not, it creates a duplicate of the object and stores it in the history, originalToCopy
- Overrides:
makeOrReturnCopy
in classAnnotatedTypeCopier
- Type Parameters:
T
- the type of original copy, this is a shortcut to avoid having to insert casts all over the visitor- Parameters:
original
- a reference to a type to copyoriginalToCopy
- a mapping of previously encountered references to the copies made for those references- Returns:
- a copy of original
-