use of org.revapi.java.filters.AnnotatedElementFilter in project revapi by revapi.
the class AnnotatedElementFilterTest method testWith.
private void testWith(String configJSON, Consumer<List<Element>> test) throws Exception {
ArchiveAndCompilationPath archive = createCompiledJar("test.jar", "annotationfilter/NonPublic.java", "annotationfilter/NonPublicClass.java", "annotationfilter/Public.java", "annotationfilter/PublicClass.java", "annotationfilter/UndecisiveClass.java");
try {
JavaArchiveAnalyzer analyzer = new JavaArchiveAnalyzer(new API(Arrays.asList(new ShrinkwrapArchive(archive.archive)), null), Executors.newSingleThreadExecutor(), null, false, InclusionFilter.acceptAll());
JavaElementForest forest = analyzer.analyze();
AnnotatedElementFilter filter = new AnnotatedElementFilter();
Revapi r = new Revapi(emptySet(), emptySet(), emptySet(), singleton(AnnotatedElementFilter.class));
AnalysisContext ctx = AnalysisContext.builder(r).withConfigurationFromJSON(configJSON).build();
AnalysisContext filterCtx = r.prepareAnalysis(ctx).getFirstConfigurationOrNull(AnnotatedElementFilter.class);
filter.initialize(filterCtx);
List<Element> results = forest.search(Element.class, true, filter, null);
analyzer.getCompilationValve().removeCompiledResults();
test.accept(results);
} finally {
deleteDir(archive.compilationPath);
}
}
Aggregations