use of org.checkerframework.framework.qual.DefaultQualifierInHierarchyInUncheckedCode in project checker-framework by typetools.
the class GenericAnnotatedTypeFactory method addUncheckedCodeDefaults.
/**
* Adds default qualifiers for code that is not type-checked by reading
* {@code @DefaultInUncheckedCodeFor} and {@code @DefaultQualifierInHierarchyInUncheckedCode}
* meta-annotations. Then it applies the standard unchecked code defaults, if a default was not
* specified for a particular location.
*
* <p>Standard unchecked code default are: <br>
* top: {@code TypeUseLocation.RETURN,TypeUseLocation.FIELD,TypeUseLocation.UPPER_BOUND}<br>
* bottom: {@code TypeUseLocation.PARAMETER, TypeUseLocation.LOWER_BOUND}<br>
*
* <p>If {@code @DefaultQualifierInHierarchyInUncheckedCode} code is not found or a default for
* {@code TypeUseLocation.Otherwise} is not used, the defaults for checked code will be applied
* to locations without a default for unchecked code.
*
* <p>Subclasses may override this method to add defaults that cannot be specified with a
* {@code @DefaultInUncheckedCodeFor} or {@code @DefaultQualifierInHierarchyInUncheckedCode}
* meta-annotations or to change the standard defaults.
*
* @param defs {@link QualifierDefaults} object to which defaults are added
*/
protected void addUncheckedCodeDefaults(QualifierDefaults defs) {
for (Class<? extends Annotation> annotation : getSupportedTypeQualifiers()) {
DefaultInUncheckedCodeFor defaultInUncheckedCodeFor = annotation.getAnnotation(DefaultInUncheckedCodeFor.class);
if (defaultInUncheckedCodeFor != null) {
final TypeUseLocation[] locations = defaultInUncheckedCodeFor.value();
defs.addUncheckedCodeDefaults(AnnotationBuilder.fromClass(elements, annotation), locations);
}
if (annotation.getAnnotation(DefaultQualifierInHierarchyInUncheckedCode.class) != null) {
defs.addUncheckedCodeDefault(AnnotationBuilder.fromClass(elements, annotation), TypeUseLocation.OTHERWISE);
}
}
}
Aggregations