Class AnnotatedTypeReplacer
java.lang.Object
org.checkerframework.framework.type.visitor.AnnotatedTypeScanner<R,AnnotatedTypeMirror>
org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner<Void>
org.checkerframework.framework.type.AnnotatedTypeReplacer
- All Implemented Interfaces:
AnnotatedTypeVisitor<Void,
AnnotatedTypeMirror>
Replaces or adds all the annotations in the parameter with the annotations from the visited type.
An annotation is replaced if the parameter type already has an annotation in the same hierarchy
at the same location as the visited type.
Example use:
AnnotatedTypeMirror visitType = ...;
AnnotatedTypeMirror parameter = ...;
visitType.accept(new AnnotatedTypeReplacer(), parameter);
-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.framework.type.visitor.AnnotatedTypeScanner
AnnotatedTypeScanner.Reduce<R>
-
Field Summary
Fields inherited from class org.checkerframework.framework.type.visitor.AnnotatedTypeScanner
defaultResult, reduceFunction, visitedNodes
-
Constructor Summary
ConstructorDescriptionConstruct an AnnotatedTypeReplacer that will replace all annotations.Construct an AnnotatedTypeReplacer that will only replace annotations intop
's hierarchy. -
Method Summary
Modifier and TypeMethodDescriptionprotected Void
Called by default for any visit method that is not overridden.protected void
Replace the annotations in to with the annotations in from, wherever from has an annotation.void
For type variables and wildcards, the absence of a primary annotations has an implied meaning on substitution.void
Iftop != null
, then only annotations in the hierarchy oftop
are affected; otherwise, all annotations are replaced.Visits a type variable.Visits a wildcard type.Methods inherited from class org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner
scan, scan, scanAndReduce, scanAndReduce, visitArray, visitDeclared, visitExecutable, visitIntersection, visitUnion
Methods inherited from class org.checkerframework.framework.type.visitor.AnnotatedTypeScanner
reduce, reset, scan, scanAndReduce, visit, visit, visitNoType, visitNull, visitPrimitive
-
Constructor Details
-
AnnotatedTypeReplacer
public AnnotatedTypeReplacer()Construct an AnnotatedTypeReplacer that will replace all annotations. -
AnnotatedTypeReplacer
Construct an AnnotatedTypeReplacer that will only replace annotations intop
's hierarchy.- Parameters:
top
- if top != null, then only annotations in the hierarchy of top are affected
-
-
Method Details
-
setTop
Iftop != null
, then only annotations in the hierarchy oftop
are affected; otherwise, all annotations are replaced.- Parameters:
top
- if top != null, then only annotations in the hierarchy of top are replaced; otherwise, all annotations are replaced.
-
defaultAction
Description copied from class:DoubleAnnotatedTypeScanner
Called by default for any visit method that is not overridden.- Specified by:
defaultAction
in classDoubleAnnotatedTypeScanner<Void>
- Parameters:
from
- the type to visitto
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
replaceAnnotations
Replace the annotations in to with the annotations in from, wherever from has an annotation.- Parameters:
from
- the source of the annotationsto
- the destination of the annotations, modified by this method
-
visitTypeVariable
public Void visitTypeVariable(AnnotatedTypeMirror.AnnotatedTypeVariable from, AnnotatedTypeMirror to) Description copied from interface:AnnotatedTypeVisitor
Visits a type variable.- Specified by:
visitTypeVariable
in interfaceAnnotatedTypeVisitor<Void,
AnnotatedTypeMirror> - Overrides:
visitTypeVariable
in classDoubleAnnotatedTypeScanner<Void>
- Parameters:
from
- the type to visitto
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
visitWildcard
Description copied from interface:AnnotatedTypeVisitor
Visits a wildcard type.- Specified by:
visitWildcard
in interfaceAnnotatedTypeVisitor<Void,
AnnotatedTypeMirror> - Overrides:
visitWildcard
in classDoubleAnnotatedTypeScanner<Void>
- Parameters:
from
- the type to visitto
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
resolvePrimaries
For type variables and wildcards, the absence of a primary annotations has an implied meaning on substitution. Therefore, in these cases we remove the primary annotation and rely on the fact that the bounds are also merged into the type to.- Parameters:
from
- a type variable or wildcardto
- the destination annotated type mirror
-