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
Constructors -
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.voidsubstitute(AnnotatedTypeMirror.AnnotatedTypeVariable type, Map<TypeVariable, AnnotatedTypeMirror.AnnotatedTypeVariable> capturedTypeVarToAnnotatedTypeVar) Substitutes references to captured type variable intypeusingcapturedTypeVarToAnnotatedTypeVar.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 intypeusingcapturedTypeVarToAnnotatedTypeVar.Unlike
AnnotatedTypeFactory.typeVarSubstitutor, this method does not copy the type.- Parameters:
type- the type whose captured type variables are substituted with those incapturedTypeVarToAnnotatedTypeVarcapturedTypeVarToAnnotatedTypeVar- 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:AnnotatedTypeVisitorVisits a type variable.- Specified by:
visitTypeVariablein interfaceAnnotatedTypeVisitor<AnnotatedTypeMirror,IdentityHashMap<AnnotatedTypeMirror, AnnotatedTypeMirror>> - Overrides:
visitTypeVariablein 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:AnnotatedTypeCopierFor 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:
makeOrReturnCopyin 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
-