< prev index next >

src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java

Print this page

        

@@ -162,11 +162,11 @@
     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 ToolOptions options;
     private final Messager messager;
     private final JavaCompiler compiler;
 
     private final Map<String, Entry> entries = new LinkedHashMap<>();
 

@@ -199,19 +199,19 @@
 
     /**
      * 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
+     * @param options the tool options
      */
-    ElementsTable(Context context, Map<ToolOption, Object> opts) {
+    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.opts = opts;
+        this.options = options;
         this.messager = Messager.instance0(context);
         this.compiler = JavaCompiler.instance(context);
         Source source = Source.instance(context);
 
         List<Location> locs = new ArrayList<>();

@@ -227,13 +227,13 @@
             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);
+        accessFilter = new ModifierFilter(options);
+        xclasses = options.xclasses();
+        expandRequires = options.expandRequires();
     }
 
     /**
      * Returns the module documentation level mode.
      * @return the module documentation level mode

@@ -316,13 +316,11 @@
      * 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
+     * @see #getIncludedElements()
      *
      * @return true if included
      */
     public boolean isIncluded(Element e) {
         if (e == null) {

@@ -409,21 +407,20 @@
 
     @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> modules = options.modules();
         List<String> mlist = new ArrayList<>();
-        for (String m : moduleNames) {
+        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(moduleNames);
+                sanityCheckSourcePathModules(modules);
             }
             mlist.add(m);
             ModuleSymbol msym = syms.enterModule(names.fromString(m));
             specifiedModuleElements.add((ModuleElement) msym);
         }

@@ -434,24 +431,23 @@
                 .forEachOrdered((mpkg) -> {
                     mlist.add(mpkg.moduleName);
         });
 
         // scan for modules with qualified subpackages
-        ((List<String>)opts.computeIfAbsent(ToolOption.SUBPACKAGES, v -> Collections.EMPTY_LIST))
-            .stream()
+        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
-        modules.addExtraAddModules(mlist.toArray(new String[mlist.size()]));
-        modules.initModules(this.classTreeList);
+        this.modules.addExtraAddModules(mlist.toArray(new String[mlist.size()]));
+        this.modules.initModules(this.classTreeList);
 
         return this;
     }
 
     /**

@@ -504,12 +500,11 @@
         return result;
     }
 
     @SuppressWarnings("unchecked")
     private void computeSubpackages() throws ToolException {
-        ((List<String>) opts.computeIfAbsent(ToolOption.EXCLUDE, v -> Collections.EMPTY_LIST))
-                .stream()
+        options.excludes().stream()
                 .map(ModulePackage::new)
                 .forEachOrdered((mpkg) -> excludePackages.add(mpkg));
 
         excludePackages.forEach((p) -> {
             getEntry(p).excluded = true;

@@ -828,11 +823,11 @@
     }
 
     /**
      * Returns the set of source files for a package.
      *
-     * @param packageName the specified 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,28 +1207,28 @@
                 new EnumMap<>(ElementKind.class);
 
         /**
          * Constructor - Specify a filter.
          *
-         * @param accessSet an Access filter.
+         * @param options the tool options
          */
-        ModifierFilter(Map<ToolOption, Object> opts) {
+        ModifierFilter(ToolOptions options) {
 
             AccessKind accessValue = null;
             for (ElementKind kind : ALLOWED_KINDS) {
                 switch (kind) {
                     case METHOD:
-                        accessValue  = (AccessKind)opts.get(ToolOption.SHOW_MEMBERS);
+                        accessValue  = options.showMembersAccess();
                         break;
                     case CLASS:
-                        accessValue  = (AccessKind)opts.get(ToolOption.SHOW_TYPES);
+                        accessValue  = options.showTypesAccess();
                         break;
                     case PACKAGE:
-                        accessValue  = (AccessKind)opts.get(ToolOption.SHOW_PACKAGES);
+                        accessValue  = options.showPackagesAccess();
                         break;
                     case MODULE:
-                        accessValue  = (AccessKind)opts.get(ToolOption.SHOW_MODULE_CONTENTS);
+                        accessValue  = options.showModuleContents();
                         break;
                     default:
                         throw new AssertionError("unknown element: " + kind);
 
                 }
< prev index next >