Search in sources :

Example 1 with AnnotatedNullType

use of org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedNullType in project checker-framework by typetools.

the class WholeProgramInferenceScenesHelper method updateAnnotationSetInScene.

/**
 * Updates the set of annotations in a location of a Scene.
 *
 * <ul>
 *   <li>If there was no previous annotation for that location, then the updated set will be the
 *       annotations in newATM.
 *   <li>If there was a previous annotation, the updated set will be the LUB between the
 *       previous annotation and newATM.
 * </ul>
 *
 * <p>
 *
 * @param type ATypeElement of the Scene which will be modified
 * @param atf the annotated type factory of a given type system, whose type hierarchy will be
 *     used
 * @param jaifPath used to identify a Scene
 * @param rhsATM the RHS of the annotated type on the source code
 * @param lhsATM the LHS of the annotated type on the source code
 * @param defLoc the location where the annotation will be added
 */
protected void updateAnnotationSetInScene(ATypeElement type, AnnotatedTypeFactory atf, String jaifPath, AnnotatedTypeMirror rhsATM, AnnotatedTypeMirror lhsATM, TypeUseLocation defLoc) {
    if (rhsATM instanceof AnnotatedNullType && ignoreNullAssignments) {
        return;
    }
    AnnotatedTypeMirror atmFromJaif = AnnotatedTypeMirror.createType(rhsATM.getUnderlyingType(), atf, false);
    typeElementToATM(atmFromJaif, type, atf);
    updatesATMWithLUB(atf, rhsATM, atmFromJaif);
    if (lhsATM instanceof AnnotatedTypeVariable) {
        Set<AnnotationMirror> upperAnnos = ((AnnotatedTypeVariable) lhsATM).getUpperBound().getEffectiveAnnotations();
        // current type on the source code, halt.
        if (upperAnnos.size() == rhsATM.getAnnotations().size() && atf.getQualifierHierarchy().isSubtype(rhsATM.getAnnotations(), upperAnnos)) {
            return;
        }
    }
    updateTypeElementFromATM(rhsATM, lhsATM, atf, type, 1, defLoc);
    modifiedScenes.add(jaifPath);
}
Also used : AnnotationMirror(javax.lang.model.element.AnnotationMirror) AnnotatedNullType(org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedNullType) AnnotatedTypeMirror(org.checkerframework.framework.type.AnnotatedTypeMirror) AnnotatedTypeVariable(org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedTypeVariable)

Example 2 with AnnotatedNullType

use of org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedNullType in project checker-framework by typetools.

the class AnnotatedTypeFactory method getAnnotatedNullType.

/**
 * Creates and returns an AnnotatedNullType qualified with {@code annotations}.
 *
 * @param annotations set of AnnotationMirrors to qualify the returned type with
 * @return AnnotatedNullType qualified with {@code annotations}
 */
public AnnotatedNullType getAnnotatedNullType(Set<? extends AnnotationMirror> annotations) {
    final AnnotatedTypeMirror.AnnotatedNullType nullType = (AnnotatedNullType) toAnnotatedType(processingEnv.getTypeUtils().getNullType(), false);
    nullType.addAnnotations(annotations);
    return nullType;
}
Also used : AnnotatedNullType(org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedNullType) AnnotatedNullType(org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedNullType)

Aggregations

AnnotatedNullType (org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedNullType)2 AnnotationMirror (javax.lang.model.element.AnnotationMirror)1 AnnotatedTypeMirror (org.checkerframework.framework.type.AnnotatedTypeMirror)1 AnnotatedTypeVariable (org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedTypeVariable)1