Class NoElementQualifierHierarchy
- Direct Known Subclasses:
AliasingAnnotatedTypeFactory.AliasingQualifierHierarchy
QualifierHierarchy where no qualifier has arguments; that is, no qualifier is
represented by an annotation with elements. The meta-annotation SubtypeOf specifies the subtyping relationships.
It uses a QualifierKindHierarchy to model the relationships between qualifiers.
Subclasses can override createQualifierKindHierarchy(Collection) to return a subclass of
QualifierKindHierarchy.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AnnotationMirrorSetSet of bottom annotation mirrors.protected final Map<QualifierKind, AnnotationMirror> Mapping fromQualifierKindto its correspondingAnnotationMirror.protected final QualifierKindHierarchyprotected final Set<? extends AnnotationMirror> Set of all annotations in all the hierarchies.protected final AnnotationMirrorSetSet of top annotation mirrors.Fields inherited from class org.checkerframework.framework.type.QualifierHierarchy
atypeFactory -
Constructor Summary
ConstructorsConstructorDescriptionNoElementQualifierHierarchy(Collection<Class<? extends Annotation>> qualifierClasses, Elements elements, GenericAnnotatedTypeFactory<?, ?, ?, ?> atypeFactory) Creates a NoElementQualifierHierarchy from the given classes. -
Method Summary
Modifier and TypeMethodDescriptionprotected Map<QualifierKind, AnnotationMirror> createAnnotationMirrors(Elements elements) Creates and returns a mapping from qualifier kind to an annotation mirror created from the qualifier kind's annotation class.protected AnnotationMirrorSetCreates and returns the unmodifiable set of bottomAnnotationMirrors.protected QualifierKindHierarchycreateQualifierKindHierarchy(Collection<Class<? extends Annotation>> qualifierClasses) Create theQualifierKindHierarchy.protected AnnotationMirrorSetCreates and returns the unmodifiable set of topAnnotationMirrors.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 theQualifierKindfor 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.Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2.booleanisPolymorphicQualifier(AnnotationMirror qualifier) Returnstrueif the qualifier is a polymorphic qualifier; otherwise, returnsfalse.booleanisSubtypeQualifiers(AnnotationMirror subAnno, AnnotationMirror superAnno) Tests whethersubQualifieris equal to or a sub-qualifier ofsuperQualifier, according to the type qualifier hierarchy, ignoring Java basetypes.Returns the least upper bound (LUB) of the qualifiersqualifier1andqualifier2.Methods inherited from class org.checkerframework.framework.type.QualifierHierarchy
assertSameSize, assertSameSize, canHaveEmptyAnnotationSet, getWidth, greatestLowerBoundQualifiersOnly, greatestLowerBoundShallow, greatestLowerBoundsQualifiersOnly, greatestLowerBoundsQualifiersOnly, greatestLowerBoundsShallow, isSubtypeQualifiersOnly, isSubtypeQualifiersOnly, isSubtypeShallow, isSubtypeShallow, isSubtypeShallow, isSubtypeShallow, isTop, isValid, leastUpperBoundQualifiersOnly, leastUpperBoundShallow, leastUpperBoundsQualifiersOnly, leastUpperBoundsQualifiersOnly, leastUpperBoundsShallow, numberOfIterationsBeforeWidening, updateMappingToMutableSet, widenedUpperBound
-
Field Details
-
qualifierKindHierarchy
-
tops
Set of top annotation mirrors. -
bottoms
Set of bottom annotation mirrors. -
kindToAnnotationMirror
Mapping fromQualifierKindto its correspondingAnnotationMirror. -
qualifiers
Set of all annotations in all the hierarchies.
-
-
Constructor Details
-
NoElementQualifierHierarchy
public NoElementQualifierHierarchy(Collection<Class<? extends Annotation>> qualifierClasses, Elements elements, GenericAnnotatedTypeFactory<?, ?, ?, ?> atypeFactory) Creates a NoElementQualifierHierarchy from the given classes.- Parameters:
qualifierClasses- classes of annotations that are the qualifierselements- element utilsatypeFactory- the associated type factory
-
-
Method Details
-
createQualifierKindHierarchy
protected QualifierKindHierarchy createQualifierKindHierarchy(@UnderInitialization NoElementQualifierHierarchy 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- Returns:
- the newly created qualifier kind hierarchy
-
createAnnotationMirrors
@RequiresNonNull("this.qualifierKindHierarchy") protected Map<QualifierKind,AnnotationMirror> createAnnotationMirrors(@UnderInitialization NoElementQualifierHierarchy this, Elements elements) Creates and returns a mapping from qualifier kind to an annotation mirror created from the qualifier kind's annotation class.- Parameters:
elements- element utils- Returns:
- a mapping from qualifier kind to its annotation mirror
-
createTops
@RequiresNonNull({"this.kindToAnnotationMirror","this.qualifierKindHierarchy"}) protected AnnotationMirrorSet createTops(@UnderInitialization NoElementQualifierHierarchy this) Creates and returns the unmodifiable set of topAnnotationMirrors.- Returns:
- the unmodifiable set of top
AnnotationMirrors
-
createBottoms
@RequiresNonNull({"this.kindToAnnotationMirror","this.qualifierKindHierarchy"}) protected AnnotationMirrorSet createBottoms(@UnderInitialization NoElementQualifierHierarchy this) Creates and returns the unmodifiable set of bottomAnnotationMirrors.- Returns:
- the unmodifiable set of bottom
AnnotationMirrors
-
getQualifierKind
Returns theQualifierKindfor the given annotation.- Parameters:
anno- an annotation that is a qualifier in this- Returns:
- the
QualifierKindfor the given annotation
-
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
-
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
-
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
-
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.
-
isSubtypeQualifiers
Description copied from class:QualifierHierarchyTests whethersubQualifieris equal to or a sub-qualifier ofsuperQualifier, according to the type qualifier hierarchy, ignoring Java basetypes.Clients should generally call
QualifierHierarchy.isSubtypeShallow(javax.lang.model.element.AnnotationMirror, javax.lang.model.type.TypeMirror, javax.lang.model.element.AnnotationMirror, javax.lang.model.type.TypeMirror). However, subtypes should generally override this method (if needed).This method behaves the same as
QualifierHierarchy.isSubtypeQualifiersOnly(AnnotationMirror, AnnotationMirror), which calls this method. This method is for clients inside the framework, and it hasprotectedaccess to prevent use by clients outside the framework. This makes it easy to find places where code outside the framework is ignoring Java basetypes -- at calls toQualifierHierarchy.isSubtypeQualifiersOnly(javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationMirror).- Specified by:
isSubtypeQualifiersin classQualifierHierarchy- Parameters:
subAnno- possible subqualifiersuperAnno- possible superqualifier- Returns:
- true iff
subQualifieris a subqualifier of, or equal to,superQualifier
-
leastUpperBoundQualifiers
public @Nullable AnnotationMirror leastUpperBoundQualifiers(AnnotationMirror a1, AnnotationMirror a2) Description copied from class:QualifierHierarchyReturns the least upper bound (LUB) of the qualifiersqualifier1andqualifier2. Returnsnullif the qualifiers are not from the same qualifier hierarchy. Ignores Java basetypes.Examples:
- For NonNull, leastUpperBound('Nullable', 'NonNull') ⇒ Nullable
- Specified by:
leastUpperBoundQualifiersin classQualifierHierarchy- Parameters:
a1- the first qualifier; may not be in the same hierarchy asqualifier2a2- the second qualifier; may not be in the same hierarchy asqualifier1- Returns:
- the least upper bound of the qualifiers, or
nullif the qualifiers are from different hierarchies
-
greatestLowerBoundQualifiers
public @Nullable AnnotationMirror greatestLowerBoundQualifiers(AnnotationMirror a1, AnnotationMirror a2) Description copied from class:QualifierHierarchyReturns the greatest lower bound for the qualifiers qualifier1 and qualifier2. Returns null if the qualifiers are not from the same qualifier hierarchy.- Specified by:
greatestLowerBoundQualifiersin classQualifierHierarchy- Parameters:
a1- first qualifiera2- second qualifier- Returns:
- greatest lower bound of the two annotations, or null if the two annotations are not from the same hierarchy
-