< prev index next >

src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsFilter.java

Print this page

        

*** 27,41 **** import com.sun.tools.classfile.Dependencies; import com.sun.tools.classfile.Dependency; import com.sun.tools.classfile.Dependency.Location; import java.util.HashSet; - import java.util.Optional; import java.util.Set; import java.util.regex.Pattern; - import java.util.stream.Collectors; - import java.util.stream.Stream; /* * Filter configured based on the input jdeps option * 1. -p and -regex to match target dependencies * 2. -filter:package to filter out same-package dependencies --- 27,38 ----
*** 57,85 **** private final Pattern filterPattern; private final boolean filterSamePackage; private final boolean filterSameArchive; private final boolean findJDKInternals; private final Pattern includePattern; - private final Pattern includeSystemModules; private final Set<String> requires; private JdepsFilter(Dependency.Filter filter, Pattern filterPattern, boolean filterSamePackage, boolean filterSameArchive, boolean findJDKInternals, Pattern includePattern, - Pattern includeSystemModules, Set<String> requires) { this.filter = filter; this.filterPattern = filterPattern; this.filterSamePackage = filterSamePackage; this.filterSameArchive = filterSameArchive; this.findJDKInternals = findJDKInternals; this.includePattern = includePattern; - this.includeSystemModules = includeSystemModules; this.requires = requires; } /** * Tests if the given class matches the pattern given in the -include option --- 54,79 ----
*** 110,129 **** .anyMatch(this::matches); } return hasTargetFilter(); } - public boolean include(Archive source) { - Module module = source.getModule(); - // skip system module by default; or if includeSystemModules is set - // only include the ones matching the pattern - return !module.isSystem() || (includeSystemModules != null && - includeSystemModules.matcher(module.name()).matches()); - } - public boolean hasIncludePattern() { ! return includePattern != null || includeSystemModules != null; } public boolean hasTargetFilter() { return filter != null; } --- 104,115 ---- .anyMatch(this::matches); } return hasTargetFilter(); } public boolean hasIncludePattern() { ! return includePattern != null; } public boolean hasTargetFilter() { return filter != null; }
*** 195,216 **** sb.append("requires: ").append(requires).append("\n"); return sb.toString(); } public static class Builder { - static Pattern SYSTEM_MODULE_PATTERN = Pattern.compile("java\\..*|jdk\\..*|javafx\\..*"); Pattern filterPattern; Pattern regex; boolean filterSamePackage; boolean filterSameArchive; boolean findJDKInterals; // source filters Pattern includePattern; Pattern includeSystemModules; Set<String> requires = new HashSet<>(); Set<String> targetPackages = new HashSet<>(); public Builder packages(Set<String> packageNames) { this.targetPackages.addAll(packageNames); return this; } public Builder regex(Pattern regex) { --- 181,204 ---- sb.append("requires: ").append(requires).append("\n"); return sb.toString(); } public static class Builder { Pattern filterPattern; Pattern regex; boolean filterSamePackage; boolean filterSameArchive; boolean findJDKInterals; // source filters Pattern includePattern; Pattern includeSystemModules; + Set<Module> roots = new HashSet<>(); Set<String> requires = new HashSet<>(); Set<String> targetPackages = new HashSet<>(); + public Builder() {}; + public Builder packages(Set<String> packageNames) { this.targetPackages.addAll(packageNames); return this; } public Builder regex(Pattern regex) {
*** 227,259 **** return this; } public Builder requires(String name, Set<String> packageNames) { this.requires.add(name); this.targetPackages.addAll(packageNames); - - includeIfSystemModule(name); return this; } public Builder findJDKInternals(boolean value) { this.findJDKInterals = value; return this; } public Builder includePattern(Pattern regex) { this.includePattern = regex; return this; } - public Builder includeSystemModules(Pattern regex) { - this.includeSystemModules = regex; - return this; - } - public Builder includeIfSystemModule(String name) { - if (includeSystemModules == null && - SYSTEM_MODULE_PATTERN.matcher(name).matches()) { - this.includeSystemModules = SYSTEM_MODULE_PATTERN; - } - return this; - } public JdepsFilter build() { Dependency.Filter filter = null; if (regex != null) filter = Dependencies.getRegexFilter(regex); --- 215,234 ----
*** 264,274 **** filterPattern, filterSamePackage, filterSameArchive, findJDKInterals, includePattern, - includeSystemModules, requires); } } } --- 239,248 ----
< prev index next >