Class ElementQualifierHierarchy
- Direct Known Subclasses:
AccumulationAnnotatedTypeFactory.AccumulationQualifierHierarchy,ClassValAnnotatedTypeFactory.ClassValQualifierHierarchy,MethodValAnnotatedTypeFactory.MethodValQualifierHierarchy,MostlyNoElementQualifierHierarchy,UpperBoundAnnotatedTypeFactory.UpperBoundQualifierHierarchy
QualifierHierarchy where qualifiers may be represented by annotations with elements.
ElementQualifierHierarchy uses a QualifierKindHierarchy to model the relationships
between qualifiers. (By contrast, MostlyNoElementQualifierHierarchy uses the QualifierKindHierarchy to implement isSubtype, leastUpperBound, and
greatestLowerBound methods for qualifiers without elements.)
Subclasses can override createQualifierKindHierarchy(Collection) to return a subclass
of QualifierKindHierarchy.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AnnotationMirrorSetThe set of bottom annotation mirrors.protected final Map<QualifierKind, AnnotationMirror> A mapping from bottom QualifierKinds to their corresponding AnnotationMirror.protected final Map<QualifierKind, AnnotationMirror> A mapping from QualifierKind to AnnotationMirror for all qualifiers whose annotations do not have elements.protected final QualifierKindHierarchyprotected final AnnotationMirrorSetThe set of top annotation mirrors.protected final Map<QualifierKind, AnnotationMirror> A mapping from top QualifierKinds to their corresponding AnnotationMirror.Fields inherited from class org.checkerframework.framework.type.QualifierHierarchy
atypeFactory -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedElementQualifierHierarchy(Collection<Class<? extends Annotation>> qualifierClasses, Elements elements, GenericAnnotatedTypeFactory<?, ?, ?, ?> atypeFactory) Creates a ElementQualifierHierarchy from the given classes. -
Method Summary
Modifier and TypeMethodDescriptionprotected Map<QualifierKind, AnnotationMirror> Creates a mapping from QualifierKind to AnnotationMirror, where the QualifierKind is bottom and the AnnotationMirror is bottom in their respective hierarchies.protected Map<QualifierKind, AnnotationMirror> Creates a mapping from QualifierKind to AnnotationMirror for all qualifiers whose annotations do not have elements.protected QualifierKindHierarchycreateQualifierKindHierarchy(Collection<Class<? extends Annotation>> qualifierClasses) Create theQualifierKindHierarchy.protected Map<QualifierKind, AnnotationMirror> Creates a mapping from QualifierKind to AnnotationMirror, where the QualifierKind is top and the AnnotationMirror is top in their respective hierarchies.findAnnotationInHierarchy(Collection<? extends AnnotationMirror> annos, AnnotationMirror top) Returns the annotation inqualifiersthat is in the hierarchy for whichtopis top.findAnnotationInSameHierarchy(Collection<? extends AnnotationMirror> annos, AnnotationMirror annotationMirror) Returns the annotation inqualifiersthat is in the same hierarchy asqualifier.Return the bottom for the given qualifier, that is, the qualifier that is a subtype ofqualifierbut no further subtypes exist.Returns the bottom type qualifiers in the hierarchy.Returns the polymorphic qualifier for the hierarchy containingqualifier, ornullif there is no polymorphic qualifier in that hierarchy.protected QualifierKindReturns the qualifier kind for the annotation with the canonical namename.protected QualifierKindReturns the qualifier kind for the given annotation.getTopAnnotation(AnnotationMirror start) Return the top qualifier for the given qualifier, that is, the qualifier that is a supertype ofqualifierbut no further supertypes exist.Returns the top (ultimate super) type qualifiers in the type system.booleanisPolymorphicQualifier(AnnotationMirror qualifier) Returnstrueif the qualifier is a polymorphic qualifier; otherwise, returnsfalse.booleanisValid()Determine whether this QualifierHierarchy is valid.Methods inherited from class org.checkerframework.framework.type.QualifierHierarchy
assertSameSize, assertSameSize, canHaveEmptyAnnotationSet, getWidth, greatestLowerBoundQualifiers, greatestLowerBoundQualifiersOnly, greatestLowerBoundShallow, greatestLowerBoundsQualifiersOnly, greatestLowerBoundsQualifiersOnly, greatestLowerBoundsShallow, isSubtypeQualifiers, isSubtypeQualifiersOnly, isSubtypeQualifiersOnly, isSubtypeShallow, isSubtypeShallow, isSubtypeShallow, isSubtypeShallow, isTop, leastUpperBoundQualifiers, leastUpperBoundQualifiersOnly, leastUpperBoundShallow, leastUpperBoundsQualifiersOnly, leastUpperBoundsQualifiersOnly, leastUpperBoundsShallow, numberOfIterationsBeforeWidening, updateMappingToMutableSet, widenedUpperBound
-
Field Details
-
qualifierKindHierarchy
-
topsMap
A mapping from top QualifierKinds to their corresponding AnnotationMirror. -
tops
The set of top annotation mirrors. -
bottomsMap
A mapping from bottom QualifierKinds to their corresponding AnnotationMirror. -
bottoms
The set of bottom annotation mirrors. -
kindToElementlessQualifier
A mapping from QualifierKind to AnnotationMirror for all qualifiers whose annotations do not have elements.
-
-
Constructor Details
-
ElementQualifierHierarchy
protected ElementQualifierHierarchy(Collection<Class<? extends Annotation>> qualifierClasses, Elements elements, GenericAnnotatedTypeFactory<?, ?, ?, ?> atypeFactory) Creates a ElementQualifierHierarchy from the given classes.- Parameters:
qualifierClasses- classes of annotations that are the qualifiers for this hierarchyelements- element utilsatypeFactory- the associated type factory
-
-
Method Details
-
isValid
public boolean isValid()Description copied from class:QualifierHierarchyDetermine whether this QualifierHierarchy is valid.- Overrides:
isValidin classQualifierHierarchy- Returns:
- true if this QualifierHierarchy is valid
-
createQualifierKindHierarchy
protected QualifierKindHierarchy createQualifierKindHierarchy(@UnderInitialization ElementQualifierHierarchy this, Collection<Class<? extends Annotation>> qualifierClasses) Create theQualifierKindHierarchy. (Subclasses may override to return a subclass of QualifierKindHierarchy.)- Parameters:
qualifierClasses- classes of annotations that are the qualifiers for this hierarchy- Returns:
- the newly created qualifier kind hierarchy
-
createElementlessQualifierMap
@RequiresNonNull({"this.qualifierKindHierarchy","this.elements"}) protected Map<QualifierKind,AnnotationMirror> createElementlessQualifierMap(@UnderInitialization ElementQualifierHierarchy this) Creates a mapping from QualifierKind to AnnotationMirror for all qualifiers whose annotations do not have elements.- Returns:
- the mapping
-
createTopsMap
@RequiresNonNull({"this.qualifierKindHierarchy","this.elements"}) protected Map<QualifierKind,AnnotationMirror> createTopsMap(@UnderInitialization ElementQualifierHierarchy this) Creates a mapping from QualifierKind to AnnotationMirror, where the QualifierKind is top and the AnnotationMirror is top in their respective hierarchies.This implementation works if the top annotation has no elements, or if it has elements, provides a default, and that default is the top. Otherwise, subclasses must override this.
- Returns:
- a mapping from top QualifierKind to top AnnotationMirror
-
createBottomsMap
@RequiresNonNull({"this.qualifierKindHierarchy","this.elements"}) protected Map<QualifierKind,AnnotationMirror> createBottomsMap(@UnderInitialization ElementQualifierHierarchy this) Creates a mapping from QualifierKind to AnnotationMirror, where the QualifierKind is bottom and the AnnotationMirror is bottom in their respective hierarchies.This implementation works if the bottom annotation has no elements, or if it has elements, provides a default, and that default is the bottom. Otherwise, subclasses must override this.
- Returns:
- a mapping from bottom QualifierKind to bottom AnnotationMirror
-
getQualifierKind
Returns the qualifier kind for the given annotation.- Parameters:
anno- an annotation mirror that is in this hierarchy- Returns:
- the qualifier kind for the given annotation
-
getQualifierKind
Returns the qualifier kind for the annotation with the canonical namename.- Parameters:
name- fully qualified annotation name- Returns:
- the qualifier kind for the annotation named
name
-
getTopAnnotations
Description copied from class:QualifierHierarchyReturns the top (ultimate super) type qualifiers in the type system. The size of this set is equal toQualifierHierarchy.getWidth().- Specified by:
getTopAnnotationsin classQualifierHierarchy- Returns:
- the top (ultimate super) type qualifiers in the type system
-
getTopAnnotation
Description copied from class:QualifierHierarchyReturn the top qualifier for the given qualifier, that is, the qualifier that is a supertype ofqualifierbut no further supertypes exist.- Specified by:
getTopAnnotationin classQualifierHierarchy- Parameters:
start- any qualifier from one of the qualifier hierarchies represented by this- Returns:
- the top qualifier of
qualifier's hierarchy
-
getBottomAnnotations
Description copied from class:QualifierHierarchyReturns the bottom type qualifiers in the hierarchy. The size of this set is equal toQualifierHierarchy.getWidth().- Specified by:
getBottomAnnotationsin classQualifierHierarchy- Returns:
- the bottom type qualifiers in the hierarchy
-
getPolymorphicAnnotation
Description copied from class:QualifierHierarchyReturns the polymorphic qualifier for the hierarchy containingqualifier, ornullif there is no polymorphic qualifier in that hierarchy.- Specified by:
getPolymorphicAnnotationin classQualifierHierarchy- Parameters:
start- any qualifier from one of the qualifier hierarchies represented by this- Returns:
- the polymorphic qualifier for the hierarchy containing
qualifier, ornullif there is no polymorphic qualifier in that hierarchy
-
isPolymorphicQualifier
Description copied from class:QualifierHierarchyReturnstrueif the qualifier is a polymorphic qualifier; otherwise, returnsfalse.- Specified by:
isPolymorphicQualifierin classQualifierHierarchy- Parameters:
qualifier- qualifier- Returns:
trueif the qualifier is a polymorphic qualifier; otherwise, returnsfalse.
-
getBottomAnnotation
Description copied from class:QualifierHierarchyReturn the bottom for the given qualifier, that is, the qualifier that is a subtype ofqualifierbut no further subtypes exist.- Specified by:
getBottomAnnotationin classQualifierHierarchy- Parameters:
start- any qualifier from one of the qualifier hierarchies represented by this- Returns:
- the bottom qualifier of
qualifier's hierarchy
-
findAnnotationInSameHierarchy
public @Nullable AnnotationMirror findAnnotationInSameHierarchy(Collection<? extends AnnotationMirror> annos, AnnotationMirror annotationMirror) Description copied from class:QualifierHierarchyReturns the annotation inqualifiersthat is in the same hierarchy asqualifier.The default implementation calls
QualifierHierarchy.getTopAnnotation(AnnotationMirror)and then callsQualifierHierarchy.findAnnotationInHierarchy(Collection, AnnotationMirror). So, ifqualifieris a top qualifier, then callQualifierHierarchy.findAnnotationInHierarchy(Collection, AnnotationMirror)directly is faster.- Overrides:
findAnnotationInSameHierarchyin classQualifierHierarchy- Parameters:
annos- the set of annotations to searchannotationMirror- annotation that is in the same hierarchy as the returned annotation- Returns:
- annotation in the same hierarchy as qualifier, or null if one is not found
-
findAnnotationInHierarchy
public @Nullable AnnotationMirror findAnnotationInHierarchy(Collection<? extends AnnotationMirror> annos, AnnotationMirror top) Description copied from class:QualifierHierarchyReturns the annotation inqualifiersthat is in the hierarchy for whichtopis top.- Overrides:
findAnnotationInHierarchyin classQualifierHierarchy- Parameters:
annos- the set of annotations to searchtop- the top annotation in the hierarchy to which the returned annotation belongs- Returns:
- annotation in the same hierarchy as annotationMirror, or null if one is not found
-