Class KeyForPropagator
java.lang.Object
org.checkerframework.checker.nullness.KeyForPropagator
KeyForPropagator is used to move nested KeyFor annotations in type arguments from one side of a
pseudo-assignment to the other. The KeyForPropagationTreeAnnotator details the locations in which
this occurs.
- See Also:
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
propagate
(AnnotatedTypeMirror.AnnotatedDeclaredType subtype, AnnotatedTypeMirror.AnnotatedDeclaredType supertype, KeyForPropagator.PropagationDirection direction, AnnotatedTypeFactory typeFactory) Propagate annotations from the type arguments of one type to another.void
propagateNewClassTree
(NewClassTree newClassTree, AnnotatedTypeMirror type, KeyForAnnotatedTypeFactory atypeFactory) Propagate annotations from the type arguments oftype
to the assignment context ofnewClassTree
if one exists.
-
Constructor Details
-
KeyForPropagator
Creates a KeyForPropagator- Parameters:
unknownKeyfor
- anUnknownKeyFor
annotation
-
-
Method Details
-
propagate
public void propagate(AnnotatedTypeMirror.AnnotatedDeclaredType subtype, AnnotatedTypeMirror.AnnotatedDeclaredType supertype, KeyForPropagator.PropagationDirection direction, AnnotatedTypeFactory typeFactory) Propagate annotations from the type arguments of one type to another. Which type is the source and destination of the annotations depends on the direction parameter. Only @KeyFor annotations are propagated and only if the type to which it would be propagated contains an @UnknownKeyFor or contains no key for annotations of any kind. If any of the type arguments are wildcards than they are ignored.Note the primary annotations of subtype/supertype are not used.
Simple Example:
The type of supertype after propagate would be:typeOf(subtype) = ArrayList<@KeyFor("a") String> typeOf(supertype) = List<@UnknownKeyFor String> direction = TO_SUPERTYPE
List<@KeyFor("a") String>
A more complex example would be:
The type of subtype after propagate would be:typeOf(subtype) = HashMap<@UnknownKeyFor String, @KeyFor("b") List<@KeyFor("c") String>> typeOf(supertype) = Map<@KeyFor("a") String, @KeyFor("b") List<@KeyFor("c") String>> direction = TO_SUBTYPE
HashMap<@KeyFor("a") String, @KeyFor("b") List<@KeyFor("c") String>>
-
propagateNewClassTree
public void propagateNewClassTree(NewClassTree newClassTree, AnnotatedTypeMirror type, KeyForAnnotatedTypeFactory atypeFactory) Propagate annotations from the type arguments oftype
to the assignment context ofnewClassTree
if one exists.- Parameters:
newClassTree
- new class treetype
- annotated type ofnewClassTree
atypeFactory
- factory
-