Search in sources :

Example 1 with QualifierKind

use of org.checkerframework.framework.util.QualifierKind in project checker-framework by typetools.

the class ElementQualifierHierarchy method getPolymorphicAnnotation.

@Override
@Nullable
public AnnotationMirror getPolymorphicAnnotation(AnnotationMirror start) {
    QualifierKind polyKind = getQualifierKind(start).getPolymorphic();
    if (polyKind == null) {
        return null;
    }
    AnnotationMirror poly = kindToElementlessQualifier.get(polyKind);
    if (poly == null) {
        throw new TypeSystemError("Poly %s has an element. Override ElementQualifierHierarchy#getPolymorphicAnnotation.", polyKind);
    }
    return poly;
}
Also used : AnnotationMirror(javax.lang.model.element.AnnotationMirror) TypeSystemError(org.checkerframework.javacutil.TypeSystemError) QualifierKind(org.checkerframework.framework.util.QualifierKind) Nullable(org.checkerframework.checker.nullness.qual.Nullable)

Example 2 with QualifierKind

use of org.checkerframework.framework.util.QualifierKind in project checker-framework by typetools.

the class MostlyNoElementQualifierHierarchy method leastUpperBound.

@Override
@Nullable
public final AnnotationMirror leastUpperBound(AnnotationMirror a1, AnnotationMirror a2) {
    QualifierKind qual1 = getQualifierKind(a1);
    QualifierKind qual2 = getQualifierKind(a2);
    QualifierKind lub = qualifierKindHierarchy.leastUpperBound(qual1, qual2);
    if (lub == null) {
        // Qualifiers are not in the same hierarchy.
        return null;
    }
    if (lub.hasElements()) {
        return leastUpperBoundWithElements(a1, qual1, a2, qual2, lub);
    }
    return kindToElementlessQualifier.get(lub);
}
Also used : QualifierKind(org.checkerframework.framework.util.QualifierKind) Nullable(org.checkerframework.checker.nullness.qual.Nullable)

Example 3 with QualifierKind

use of org.checkerframework.framework.util.QualifierKind in project checker-framework by typetools.

the class MostlyNoElementQualifierHierarchy method greatestLowerBound.

@Override
@Nullable
public final AnnotationMirror greatestLowerBound(AnnotationMirror a1, AnnotationMirror a2) {
    QualifierKind qual1 = getQualifierKind(a1);
    QualifierKind qual2 = getQualifierKind(a2);
    QualifierKind glb = qualifierKindHierarchy.greatestLowerBound(qual1, qual2);
    if (glb == null) {
        // Qualifiers are not in the same hierarchy.
        return null;
    }
    if (glb.hasElements()) {
        return greatestLowerBoundWithElements(a1, qual1, a2, qual2, glb);
    }
    return kindToElementlessQualifier.get(glb);
}
Also used : QualifierKind(org.checkerframework.framework.util.QualifierKind) Nullable(org.checkerframework.checker.nullness.qual.Nullable)

Example 4 with QualifierKind

use of org.checkerframework.framework.util.QualifierKind in project checker-framework by typetools.

the class NoElementQualifierHierarchy method isSubtype.

@Override
public boolean isSubtype(AnnotationMirror subAnno, AnnotationMirror superAnno) {
    QualifierKind subKind = getQualifierKind(subAnno);
    QualifierKind superKind = getQualifierKind(superAnno);
    return subKind.isSubtypeOf(superKind);
}
Also used : QualifierKind(org.checkerframework.framework.util.QualifierKind)

Example 5 with QualifierKind

use of org.checkerframework.framework.util.QualifierKind in project checker-framework by typetools.

the class NoElementQualifierHierarchy method getQualifierKind.

/**
 * Returns the {@link QualifierKind} for the given annotation.
 *
 * @param anno an annotation that is a qualifier in this
 * @return the {@code QualifierKind} for the given annotation
 */
protected QualifierKind getQualifierKind(AnnotationMirror anno) {
    String name = AnnotationUtils.annotationName(anno);
    QualifierKind kind = qualifierKindHierarchy.getQualifierKind(name);
    if (kind == null) {
        throw new BugInCF("Annotation not in hierarchy: %s", anno);
    }
    return kind;
}
Also used : QualifierKind(org.checkerframework.framework.util.QualifierKind) BugInCF(org.checkerframework.javacutil.BugInCF)

Aggregations

QualifierKind (org.checkerframework.framework.util.QualifierKind)12 AnnotationMirror (javax.lang.model.element.AnnotationMirror)5 Nullable (org.checkerframework.checker.nullness.qual.Nullable)5 NonNull (org.checkerframework.checker.nullness.qual.NonNull)4 RequiresNonNull (org.checkerframework.checker.nullness.qual.RequiresNonNull)4 BugInCF (org.checkerframework.javacutil.BugInCF)1 TypeSystemError (org.checkerframework.javacutil.TypeSystemError)1