Search in sources :

Example 6 with QualifierKind

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

the class NoElementQualifierHierarchy method createTops.

/**
 * Creates and returns the unmodifiable set of top {@link AnnotationMirror}s.
 *
 * @return the unmodifiable set of top {@link AnnotationMirror}s
 */
@RequiresNonNull({ "this.kindToAnnotationMirror", "this.qualifierKindHierarchy" })
protected Set<AnnotationMirror> createTops(@UnderInitialization NoElementQualifierHierarchy this, ) {
    Set<AnnotationMirror> tops = AnnotationUtils.createAnnotationSet();
    for (QualifierKind top : qualifierKindHierarchy.getTops()) {
        @SuppressWarnings(// All QualifierKinds are keys in kindToAnnotationMirror
        "nullness:assignment") @NonNull AnnotationMirror topAnno = kindToAnnotationMirror.get(top);
        tops.add(topAnno);
    }
    return Collections.unmodifiableSet(tops);
}
Also used : AnnotationMirror(javax.lang.model.element.AnnotationMirror) NonNull(org.checkerframework.checker.nullness.qual.NonNull) RequiresNonNull(org.checkerframework.checker.nullness.qual.RequiresNonNull) QualifierKind(org.checkerframework.framework.util.QualifierKind) RequiresNonNull(org.checkerframework.checker.nullness.qual.RequiresNonNull)

Example 7 with QualifierKind

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

the class NoElementQualifierHierarchy method greatestLowerBound.

@Override
@Nullable
public AnnotationMirror greatestLowerBound(AnnotationMirror a1, AnnotationMirror a2) {
    QualifierKind qual1 = getQualifierKind(a1);
    QualifierKind qual2 = getQualifierKind(a2);
    QualifierKind glb = qualifierKindHierarchy.greatestLowerBound(qual1, qual2);
    if (glb == null) {
        return null;
    }
    return kindToAnnotationMirror.get(glb);
}
Also used : QualifierKind(org.checkerframework.framework.util.QualifierKind) Nullable(org.checkerframework.checker.nullness.qual.Nullable)

Example 8 with QualifierKind

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

the class NoElementQualifierHierarchy method createBottoms.

/**
 * Creates and returns the unmodifiable set of bottom {@link AnnotationMirror}s.
 *
 * @return the unmodifiable set of bottom {@link AnnotationMirror}s
 */
@RequiresNonNull({ "this.kindToAnnotationMirror", "this.qualifierKindHierarchy" })
protected Set<AnnotationMirror> createBottoms(@UnderInitialization NoElementQualifierHierarchy this, ) {
    Set<AnnotationMirror> bottoms = AnnotationUtils.createAnnotationSet();
    for (QualifierKind bottom : qualifierKindHierarchy.getBottoms()) {
        @SuppressWarnings(// All QualifierKinds are keys in kindToAnnotationMirror
        "nullness:assignment") @NonNull AnnotationMirror bottomAnno = kindToAnnotationMirror.get(bottom);
        bottoms.add(bottomAnno);
    }
    return Collections.unmodifiableSet(bottoms);
}
Also used : AnnotationMirror(javax.lang.model.element.AnnotationMirror) NonNull(org.checkerframework.checker.nullness.qual.NonNull) RequiresNonNull(org.checkerframework.checker.nullness.qual.RequiresNonNull) QualifierKind(org.checkerframework.framework.util.QualifierKind) RequiresNonNull(org.checkerframework.checker.nullness.qual.RequiresNonNull)

Example 9 with QualifierKind

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

the class NoElementQualifierHierarchy method leastUpperBound.

@Override
@Nullable
public AnnotationMirror leastUpperBound(AnnotationMirror a1, AnnotationMirror a2) {
    QualifierKind qual1 = getQualifierKind(a1);
    QualifierKind qual2 = getQualifierKind(a2);
    QualifierKind lub = qualifierKindHierarchy.leastUpperBound(qual1, qual2);
    if (lub == null) {
        return null;
    }
    return kindToAnnotationMirror.get(lub);
}
Also used : QualifierKind(org.checkerframework.framework.util.QualifierKind) Nullable(org.checkerframework.checker.nullness.qual.Nullable)

Example 10 with QualifierKind

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

the class MostlyNoElementQualifierHierarchy method isSubtype.

@Override
public final boolean isSubtype(AnnotationMirror subAnno, AnnotationMirror superAnno) {
    QualifierKind subKind = getQualifierKind(subAnno);
    QualifierKind superKind = getQualifierKind(superAnno);
    if (subKind.isSubtypeOf(superKind)) {
        if (superKind.hasElements() && subKind.hasElements()) {
            return isSubtypeWithElements(subAnno, subKind, superAnno, superKind);
        } else {
            return true;
        }
    }
    return false;
}
Also used : QualifierKind(org.checkerframework.framework.util.QualifierKind)

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