diff --git a/framework/src/main/java/org/checkerframework/common/wholeprograminference/WholeProgramInferenceJavaParserStorage.java b/framework/src/main/java/org/checkerframework/common/wholeprograminference/WholeProgramInferenceJavaParserStorage.java index ec3cb24c58f..7a9d92832f5 100644 --- a/framework/src/main/java/org/checkerframework/common/wholeprograminference/WholeProgramInferenceJavaParserStorage.java +++ b/framework/src/main/java/org/checkerframework/common/wholeprograminference/WholeProgramInferenceJavaParserStorage.java @@ -36,6 +36,7 @@ import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; +import java.lang.annotation.Annotation; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; @@ -123,14 +124,22 @@ public class WholeProgramInferenceJavaParserStorage */ public static Set getInvisibleQualifierNames(AnnotatedTypeFactory atypeFactory) { return atypeFactory.getSupportedTypeQualifiers().stream() - .filter( - qual -> - Arrays.stream(qual.getAnnotations()) - .anyMatch(anno -> anno.annotationType() == InvisibleQualifier.class)) + .filter(WholeProgramInferenceJavaParserStorage::isInvisible) .map(Class::getCanonicalName) .collect(Collectors.toSet()); } + /** + * Is the definition of the given annotation class annotated with {@link InvisibleQualifier}? + * + * @param qual an annotation class + * @return true iff {@code qual} is meta-annotated with {@link InvisibleQualifier} + */ + public static boolean isInvisible(Class qual) { + return Arrays.stream(qual.getAnnotations()) + .anyMatch(anno -> anno.annotationType() == InvisibleQualifier.class); + } + /** * Constructs a new {@code WholeProgramInferenceJavaParser} that has not yet inferred any * annotations.