< prev index next >
src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java
Print this page
*** 162,172 ****
private final Symtab syms;
private final Names names;
private final JavaFileManager fm;
private final List<Location> locations;
private final Modules modules;
! private final Map<ToolOption, Object> opts;
private final Messager messager;
private final JavaCompiler compiler;
private final Map<String, Entry> entries = new LinkedHashMap<>();
--- 162,172 ----
private final Symtab syms;
private final Names names;
private final JavaFileManager fm;
private final List<Location> locations;
private final Modules modules;
! private final ToolOptions options;
private final Messager messager;
private final JavaCompiler compiler;
private final Map<String, Entry> entries = new LinkedHashMap<>();
*** 199,217 ****
/**
* Creates the table to manage included and excluded elements.
*
* @param context the context to locate commonly used objects
! * @param location the location used to locate source files
*/
! ElementsTable(Context context, Map<ToolOption, Object> opts) {
this.toolEnv = ToolEnvironment.instance(context);
this.syms = Symtab.instance(context);
this.names = Names.instance(context);
this.fm = toolEnv.fileManager;
this.modules = Modules.instance(context);
! this.opts = opts;
this.messager = Messager.instance0(context);
this.compiler = JavaCompiler.instance(context);
Source source = Source.instance(context);
List<Location> locs = new ArrayList<>();
--- 199,217 ----
/**
* Creates the table to manage included and excluded elements.
*
* @param context the context to locate commonly used objects
! * @param options the tool options
*/
! ElementsTable(Context context, ToolOptions options) {
this.toolEnv = ToolEnvironment.instance(context);
this.syms = Symtab.instance(context);
this.names = Names.instance(context);
this.fm = toolEnv.fileManager;
this.modules = Modules.instance(context);
! this.options = options;
this.messager = Messager.instance0(context);
this.compiler = JavaCompiler.instance(context);
Source source = Source.instance(context);
List<Location> locs = new ArrayList<>();
*** 227,239 ****
locs.add(StandardLocation.PATCH_MODULE_PATH);
this.locations = Collections.unmodifiableList(locs);
getEntry("").excluded = false;
! accessFilter = new ModifierFilter(opts);
! xclasses = (boolean)opts.getOrDefault(ToolOption.XCLASSES, false);
! expandRequires = (AccessKind)opts.get(ToolOption.EXPAND_REQUIRES);
}
/**
* Returns the module documentation level mode.
* @return the module documentation level mode
--- 227,239 ----
locs.add(StandardLocation.PATCH_MODULE_PATH);
this.locations = Collections.unmodifiableList(locs);
getEntry("").excluded = false;
! accessFilter = new ModifierFilter(options);
! xclasses = options.xclasses();
! expandRequires = options.expandRequires();
}
/**
* Returns the module documentation level mode.
* @return the module documentation level mode
*** 316,328 ****
* A member (constructor, method, field) is included if
* - it is visible in a fully included type (--show-members)
*
* @param e the element in question
*
! * @see getIncludedModuleElements
! * @see getIncludedPackageElements
! * @see getIncludedTypeElements
*
* @return true if included
*/
public boolean isIncluded(Element e) {
if (e == null) {
--- 316,326 ----
* A member (constructor, method, field) is included if
* - it is visible in a fully included type (--show-members)
*
* @param e the element in question
*
! * @see #getIncludedElements()
*
* @return true if included
*/
public boolean isIncluded(Element e) {
if (e == null) {
*** 405,429 ****
throw new ToolException(SYSERR, text, ioe);
}
return null;
}
- @SuppressWarnings("unchecked")
ElementsTable scanSpecifiedItems() throws ToolException {
// scan modules specified on the command line
! List<String> moduleNames = (List<String>) opts.computeIfAbsent(ToolOption.MODULE,
! s -> Collections.EMPTY_LIST);
List<String> mlist = new ArrayList<>();
! for (String m : moduleNames) {
List<Location> moduleLocations = getModuleLocation(locations, m);
if (moduleLocations.isEmpty()) {
String text = messager.getText("main.module_not_found", m);
throw new ToolException(CMDERR, text);
}
if (moduleLocations.contains(StandardLocation.SOURCE_PATH)) {
! sanityCheckSourcePathModules(moduleNames);
}
mlist.add(m);
ModuleSymbol msym = syms.enterModule(names.fromString(m));
specifiedModuleElements.add((ModuleElement) msym);
}
--- 403,425 ----
throw new ToolException(SYSERR, text, ioe);
}
return null;
}
ElementsTable scanSpecifiedItems() throws ToolException {
// scan modules specified on the command line
! List<String> modules = options.modules();
List<String> mlist = new ArrayList<>();
! for (String m : modules) {
List<Location> moduleLocations = getModuleLocation(locations, m);
if (moduleLocations.isEmpty()) {
String text = messager.getText("main.module_not_found", m);
throw new ToolException(CMDERR, text);
}
if (moduleLocations.contains(StandardLocation.SOURCE_PATH)) {
! sanityCheckSourcePathModules(modules);
}
mlist.add(m);
ModuleSymbol msym = syms.enterModule(names.fromString(m));
specifiedModuleElements.add((ModuleElement) msym);
}
*** 434,457 ****
.forEachOrdered((mpkg) -> {
mlist.add(mpkg.moduleName);
});
// scan for modules with qualified subpackages
! ((List<String>)opts.computeIfAbsent(ToolOption.SUBPACKAGES, v -> Collections.EMPTY_LIST))
! .stream()
.map(ModulePackage::new)
.forEachOrdered((mpkg) -> {
subPackages.add(mpkg);
if (mpkg.hasModule()) {
mlist.add(mpkg.moduleName);
}
});
// all the modules specified on the command line have been scraped
// init the module systems
! modules.addExtraAddModules(mlist.toArray(new String[mlist.size()]));
! modules.initModules(this.classTreeList);
return this;
}
/**
--- 430,452 ----
.forEachOrdered((mpkg) -> {
mlist.add(mpkg.moduleName);
});
// scan for modules with qualified subpackages
! options.subpackages().stream()
.map(ModulePackage::new)
.forEachOrdered((mpkg) -> {
subPackages.add(mpkg);
if (mpkg.hasModule()) {
mlist.add(mpkg.moduleName);
}
});
// all the modules specified on the command line have been scraped
// init the module systems
! this.modules.addExtraAddModules(mlist.toArray(new String[mlist.size()]));
! this.modules.initModules(this.classTreeList);
return this;
}
/**
*** 502,515 ****
result.addAll(cmdLinePackages);
result.addAll(subPackages);
return result;
}
- @SuppressWarnings("unchecked")
private void computeSubpackages() throws ToolException {
! ((List<String>) opts.computeIfAbsent(ToolOption.EXCLUDE, v -> Collections.EMPTY_LIST))
! .stream()
.map(ModulePackage::new)
.forEachOrdered((mpkg) -> excludePackages.add(mpkg));
excludePackages.forEach((p) -> {
getEntry(p).excluded = true;
--- 497,508 ----
result.addAll(cmdLinePackages);
result.addAll(subPackages);
return result;
}
private void computeSubpackages() throws ToolException {
! options.excludes().stream()
.map(ModulePackage::new)
.forEachOrdered((mpkg) -> excludePackages.add(mpkg));
excludePackages.forEach((p) -> {
getEntry(p).excluded = true;
*** 828,838 ****
}
/**
* Returns the set of source files for a package.
*
! * @param packageName the specified package
* @return the set of file objects for the specified package
* @throws ToolException if an error occurs while accessing the files
*/
private List<JavaFileObject> getFiles(ModulePackage modpkg,
boolean recurse) throws ToolException {
--- 821,831 ----
}
/**
* Returns the set of source files for a package.
*
! * @param modpkg the specified package
* @return the set of file objects for the specified package
* @throws ToolException if an error occurs while accessing the files
*/
private List<JavaFileObject> getFiles(ModulePackage modpkg,
boolean recurse) throws ToolException {
*** 1212,1239 ****
new EnumMap<>(ElementKind.class);
/**
* Constructor - Specify a filter.
*
! * @param accessSet an Access filter.
*/
! ModifierFilter(Map<ToolOption, Object> opts) {
AccessKind accessValue = null;
for (ElementKind kind : ALLOWED_KINDS) {
switch (kind) {
case METHOD:
! accessValue = (AccessKind)opts.get(ToolOption.SHOW_MEMBERS);
break;
case CLASS:
! accessValue = (AccessKind)opts.get(ToolOption.SHOW_TYPES);
break;
case PACKAGE:
! accessValue = (AccessKind)opts.get(ToolOption.SHOW_PACKAGES);
break;
case MODULE:
! accessValue = (AccessKind)opts.get(ToolOption.SHOW_MODULE_CONTENTS);
break;
default:
throw new AssertionError("unknown element: " + kind);
}
--- 1205,1232 ----
new EnumMap<>(ElementKind.class);
/**
* Constructor - Specify a filter.
*
! * @param options the tool options
*/
! ModifierFilter(ToolOptions options) {
AccessKind accessValue = null;
for (ElementKind kind : ALLOWED_KINDS) {
switch (kind) {
case METHOD:
! accessValue = options.showMembersAccess();
break;
case CLASS:
! accessValue = options.showTypesAccess();
break;
case PACKAGE:
! accessValue = options.showPackagesAccess();
break;
case MODULE:
! accessValue = options.showModuleContents();
break;
default:
throw new AssertionError("unknown element: " + kind);
}
< prev index next >