use of org.checkerframework.framework.qual.TypeUseLocation in project checker-framework by typetools.
the class QualifierDefaults method fromDefaultQualifier.
private DefaultSet fromDefaultQualifier(DefaultQualifier dq) {
// TODO: I want to simply write d.value(), but that doesn't work.
// It works in other places, e.g. see handling of @SubtypeOf.
// The hack below should probably be added to:
// Class<? extends Annotation> cls = AnnotationUtils.parseTypeValue(dq, "value");
Class<? extends Annotation> cls;
try {
cls = dq.value();
} catch (MirroredTypeException mte) {
try {
@SuppressWarnings("unchecked") Class<? extends Annotation> clscast = (Class<? extends Annotation>) Class.forName(mte.getTypeMirror().toString());
cls = clscast;
} catch (ClassNotFoundException e) {
ErrorReporter.errorAbort("Could not load qualifier: " + e.getMessage(), e);
cls = null;
}
}
AnnotationMirror anno = AnnotationBuilder.fromClass(elements, cls);
if (anno == null) {
return null;
}
if (!atypeFactory.isSupportedQualifier(anno)) {
anno = atypeFactory.aliasedAnnotation(anno);
}
if (atypeFactory.isSupportedQualifier(anno)) {
EnumSet<TypeUseLocation> locations = EnumSet.of(dq.locations()[0], dq.locations());
DefaultSet ret = new DefaultSet();
for (TypeUseLocation loc : locations) {
ret.add(new Default(anno, loc));
}
return ret;
} else {
return null;
}
}
use of org.checkerframework.framework.qual.TypeUseLocation in project checker-framework by typetools.
the class QualifierDefaults method addUncheckedStandardDefaults.
/**
* Add standard unchecked defaults that do not conflict with previously added defaults.
*/
public void addUncheckedStandardDefaults() {
QualifierHierarchy qualHierarchy = this.atypeFactory.getQualifierHierarchy();
Set<? extends AnnotationMirror> tops = qualHierarchy.getTopAnnotations();
Set<? extends AnnotationMirror> bottoms = qualHierarchy.getBottomAnnotations();
for (TypeUseLocation loc : standardUncheckedDefaultsTop) {
// Only add standard defaults in locations where a default has not be specified
for (AnnotationMirror top : tops) {
if (!conflictsWithExistingDefaults(uncheckedCodeDefaults, top, loc)) {
addUncheckedCodeDefault(top, loc);
}
}
}
for (TypeUseLocation loc : standardUncheckedDefaultsBottom) {
for (AnnotationMirror bottom : bottoms) {
// Only add standard defaults in locations where a default has not be specified
if (!conflictsWithExistingDefaults(uncheckedCodeDefaults, bottom, loc)) {
addUncheckedCodeDefault(bottom, loc);
}
}
}
}
Aggregations