Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factor out WholeProgramInferenceJavaParserStorage#isInvisible #5196

Merged
merged 8 commits into from Jul 7, 2022
Expand Up @@ -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;
Expand Down Expand Up @@ -123,14 +124,22 @@ public class WholeProgramInferenceJavaParserStorage
*/
public static Set<String> 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<? extends Annotation> qual) {
return Arrays.stream(qual.getAnnotations())
.anyMatch(anno -> anno.annotationType() == InvisibleQualifier.class);
}

/**
* Constructs a new {@code WholeProgramInferenceJavaParser} that has not yet inferred any
* annotations.
Expand Down