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);
}
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);
}
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);
}
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;
}
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;
}
Aggregations