use of org.checkerframework.framework.qual.DefaultQualifierInHierarchy in project checker-framework by typetools.
the class GenericAnnotatedTypeFactory method addCheckedCodeDefaults.
/**
* Adds default qualifiers for type-checked code by reading {@link DefaultFor} and {@link
* DefaultQualifierInHierarchy} meta-annotations. Subclasses may override this method to add
* defaults that cannot be specified with a {@link DefaultFor} or {@link
* DefaultQualifierInHierarchy} meta-annotations.
*
* @param defs QualifierDefault object to which defaults are added
*/
protected void addCheckedCodeDefaults(QualifierDefaults defs) {
boolean foundOtherwise = false;
// Add defaults from @DefaultFor and @DefaultQualifierInHierarchy
for (Class<? extends Annotation> qual : getSupportedTypeQualifiers()) {
DefaultFor defaultFor = qual.getAnnotation(DefaultFor.class);
if (defaultFor != null) {
final TypeUseLocation[] locations = defaultFor.value();
defs.addCheckedCodeDefaults(AnnotationBuilder.fromClass(elements, qual), locations);
foundOtherwise = foundOtherwise || Arrays.asList(locations).contains(TypeUseLocation.OTHERWISE);
}
if (qual.getAnnotation(DefaultQualifierInHierarchy.class) != null) {
defs.addCheckedCodeDefault(AnnotationBuilder.fromClass(elements, qual), TypeUseLocation.OTHERWISE);
foundOtherwise = true;
}
}
// If Unqualified is a supported qualifier, make it the default.
AnnotationMirror unqualified = AnnotationBuilder.fromClass(elements, Unqualified.class);
if (!foundOtherwise && this.isSupportedQualifier(unqualified)) {
defs.addCheckedCodeDefault(unqualified, TypeUseLocation.OTHERWISE);
}
}
Aggregations