Search in sources :

Example 71 with Nullable

use of org.checkerframework.checker.nullness.qual.Nullable 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 72 with Nullable

use of org.checkerframework.checker.nullness.qual.Nullable 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 73 with Nullable

use of org.checkerframework.checker.nullness.qual.Nullable 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 74 with Nullable

use of org.checkerframework.checker.nullness.qual.Nullable in project checker-framework by typetools.

the class AnnotationClassLoader method getURLFromClasspaths.

/**
 * Scans all classpaths and returns the resource URL to the jar which contains the checker's qual
 * package, or the qual package directory if it exists, or null if no jar or directory contains
 * the package.
 *
 * @return a URL to the jar that contains the qual package, or to the qual package's directory, or
 *     null if no jar or directory contains the qual package
 */
@Nullable
private final URL getURLFromClasspaths() {
    // TODO: This method could probably be replaced with
    // io.github.classgraph.ClassGraph#getClasspathURIs()
    // Debug use, uncomment if needed to see all of the classpaths (boot
    // classpath, extension classpath, and classpath)
    // printPaths();
    URL url = null;
    // obtain all classpaths
    Set<String> paths = getClasspaths();
    // examined first.
    for (String path : paths) {
        // see if the current classpath segment is a jar or a directory
        if (path.endsWith(JAR_SUFFIX)) {
            // current classpath segment is a jar
            url = getJarURL(path);
            // see if the jar contains the package
            if (url != null && containsPackage(url)) {
                return url;
            }
        } else {
            // current classpath segment is a directory
            url = getDirectoryURL(path);
            // see if the directory contains the package
            if (url != null && containsPackage(url)) {
                // append a slash if necessary
                if (!path.endsWith(Character.toString(SLASH))) {
                    path += SLASH;
                }
                // update URL to the qual directory
                url = getDirectoryURL(path + packageNameWithSlashes);
                return url;
            }
        }
    }
    // if no jar or directory contains the qual package, then return null
    return null;
}
Also used : URL(java.net.URL) Nullable(org.checkerframework.checker.nullness.qual.Nullable)

Example 75 with Nullable

use of org.checkerframework.checker.nullness.qual.Nullable in project checker-framework by typetools.

the class TreeUtils method isAnonymousConstructor.

/**
 * Determines whether or not the node referred to by the given {@link MethodTree} is an anonymous
 * constructor (the constructor for an anonymous class.
 *
 * @param method a method tree that may be an anonymous constructor
 * @return true if the given path points to an anonymous constructor, false if it does not
 */
public static boolean isAnonymousConstructor(final MethodTree method) {
    @Nullable Element e = elementFromTree(method);
    if (e == null || e.getKind() != ElementKind.CONSTRUCTOR) {
        return false;
    }
    TypeElement typeElement = (TypeElement) e.getEnclosingElement();
    return typeElement.getNestingKind() == NestingKind.ANONYMOUS;
}
Also used : TypeElement(javax.lang.model.element.TypeElement) TypeElement(javax.lang.model.element.TypeElement) Element(javax.lang.model.element.Element) VariableElement(javax.lang.model.element.VariableElement) ExecutableElement(javax.lang.model.element.ExecutableElement) Nullable(org.checkerframework.checker.nullness.qual.Nullable)

Aggregations

Nullable (org.checkerframework.checker.nullness.qual.Nullable)285 ArrayList (java.util.ArrayList)27 TypeElement (javax.lang.model.element.TypeElement)23 IOException (java.io.IOException)21 Map (java.util.Map)21 ExecutableElement (javax.lang.model.element.ExecutableElement)19 ServerLevel (net.minecraft.server.level.ServerLevel)19 List (java.util.List)16 Instant (org.joda.time.Instant)16 VariableElement (javax.lang.model.element.VariableElement)15 HashMap (java.util.HashMap)14 Optional (java.util.Optional)14 Element (javax.lang.model.element.Element)13 TreePath (com.sun.source.util.TreePath)12 BlockPos (net.minecraft.core.BlockPos)12 Method (java.lang.reflect.Method)11 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)11 MonotonicNonNull (org.checkerframework.checker.nullness.qual.MonotonicNonNull)10 VariableTree (com.sun.source.tree.VariableTree)8 ClassTree (com.sun.source.tree.ClassTree)7