use of org.revapi.java.compilation.InclusionFilter in project revapi by revapi.
the class JavaApiAnalyzer method getArchiveAnalyzer.
@Nonnull
@Override
public ArchiveAnalyzer getArchiveAnalyzer(@Nonnull API api) {
boolean ignoreMissingAnnotations = configuration.isIgnoreMissingAnnotations();
InclusionFilter inclusionFilter = composeInclusionFilter(configuration);
return new JavaArchiveAnalyzer(api, compilationExecutor, configuration.getMissingClassReporting(), ignoreMissingAnnotations, inclusionFilter);
}
use of org.revapi.java.compilation.InclusionFilter in project revapi by revapi.
the class JavaApiAnalyzer method composeInclusionFilter.
private static InclusionFilter composeInclusionFilter(AnalysisConfiguration config) {
final Set<Pattern> inclClasses = config.getClassInclusionFilters();
final Set<Pattern> exclClasses = config.getClassExclusionFilters();
final Set<Pattern> inclPkgs = config.getPackageInclusionFilters();
final Set<Pattern> exclPkgs = config.getPackageExclusionFilters();
return new InclusionFilter() {
@Override
public boolean accepts(String typeBinaryName, String typeCanonicalName) {
for (Pattern p : inclClasses) {
if (p.matcher(typeCanonicalName).matches()) {
return true;
}
}
int lastDot = typeBinaryName.lastIndexOf('.');
String pkg = lastDot == -1 ? "" : typeBinaryName.substring(0, lastDot);
for (Pattern p : inclPkgs) {
if (p.matcher(pkg).matches()) {
return true;
}
}
return false;
}
@Override
public boolean rejects(String typeBinaryName, String typeCanonicalName) {
for (Pattern p : exclClasses) {
if (p.matcher(typeCanonicalName).matches()) {
return true;
}
}
int lastDot = typeBinaryName.lastIndexOf('.');
String pkg = lastDot == -1 ? "" : typeBinaryName.substring(0, lastDot);
for (Pattern p : exclPkgs) {
if (p.matcher(pkg).matches()) {
return true;
}
}
return false;
}
@Override
public boolean defaultCase() {
return inclClasses.isEmpty() && inclPkgs.isEmpty();
}
};
}
Aggregations