src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java
Print this page
@@ -21,20 +21,23 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-package com.sun.tools.javadoc;
+package jdk.javadoc.internal.tool;
+
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.EnumSet;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileManager.Location;
@@ -49,13 +52,13 @@
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.util.Abort;
import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Position;
+import jdk.javadoc.doclet.DocletEnvironment;
/**
* This class could be the main entry point for Javadoc when Javadoc is used as a
* component in a larger software system. It provides operations to
@@ -122,30 +125,22 @@
messager.error(Position.NOPOS, ex.getMessage());
return null;
}
}
- public RootDocImpl getRootDocImpl(String doclocale,
- String encoding,
- ModifierFilter filter,
+ public DocletEnvironment getEnvironment(String encoding,
+ String showAccess,
+ String overviewpath,
List<String> args,
- List<String[]> options,
Iterable<? extends JavaFileObject> fileObjects,
- boolean breakiterator,
List<String> subPackages,
List<String> excludedPackages,
boolean docClasses,
- boolean legacyDoclet,
boolean quiet) throws IOException {
docenv = DocEnv.instance(context);
- docenv.showAccess = filter;
- docenv.quiet = quiet;
- docenv.breakiterator = breakiterator;
- docenv.setLocale(doclocale);
- docenv.setEncoding(encoding);
- docenv.docClasses = docClasses;
- docenv.legacyDoclet = legacyDoclet;
+ docenv.intialize(encoding, showAccess, overviewpath, args, fileObjects,
+ subPackages, excludedPackages, docClasses, quiet);
javadocFinder.sourceCompleter = docClasses ? Completer.NULL_COMPLETER : sourceCompleter;
if (docClasses) {
// If -Xclasses is set, the args should be a series of class names
@@ -154,11 +149,11 @@
docenv.error(null, "main.illegal_class_name", arg);
}
if (messager.nerrors() != 0) {
return null;
}
- return new RootDocImpl(docenv, args, options);
+ return new RootDocImpl(docenv, args);
}
ListBuffer<JCCompilationUnit> classTrees = new ListBuffer<>();
Set<String> includedPackages = new LinkedHashSet<>();
@@ -199,13 +194,12 @@
// Parse the files in the packages to be documented
ListBuffer<JCCompilationUnit> packageTrees = new ListBuffer<>();
for (String packageName: includedPackages) {
List<JavaFileObject> files = t.getFiles(packageName);
docenv.notice("main.Loading_source_files_for_package", packageName);
-
if (files.isEmpty())
- messager.warning(Messager.NOPOS, "main.no_source_files_for_package", packageName);
+ docenv.warning("main.no_source_files_for_package", packageName);
parse(files, packageTrees, false);
}
if (messager.nerrors() != 0) {
return null;
@@ -216,12 +210,13 @@
javadocEnter.main(classTrees.toList().appendList(packageTrees.toList()));
} catch (Abort ex) {}
if (messager.nerrors() != 0)
return null;
-
- return new RootDocImpl(docenv, listClasses(classTrees.toList()), List.from(includedPackages), options);
+ docenv.root = new RootDocImpl(docenv, listClasses(classTrees.toList()),
+ new ArrayList<>(includedPackages));
+ return docenv.root;
}
/** Is the given string a valid package name? */
boolean isValidPackageName(String s) {
int index;
@@ -286,18 +281,18 @@
/**
* From a list of top level trees, return the list of contained class definitions
*/
List<JCClassDecl> listClasses(List<JCCompilationUnit> trees) {
- ListBuffer<JCClassDecl> result = new ListBuffer<>();
+ List<JCClassDecl> result = new ArrayList<>();
for (JCCompilationUnit t : trees) {
for (JCTree def : t.defs) {
if (def.hasTag(JCTree.Tag.CLASSDEF))
- result.append((JCClassDecl)def);
+ result.add((JCClassDecl)def);
}
}
- return result.toList();
+ return result;
}
/**
* A table to manage included and excluded packages.
*/
@@ -336,11 +331,13 @@
String pn = getPackageName(binaryName);
String simpleName = getSimpleName(binaryName);
Entry e = getEntry(pn);
if (!e.isExcluded() && isValidClassName(simpleName)) {
includedPackages.add(pn);
- e.files = (e.files == null ? List.of(fo) : e.files.prepend(fo));
+ e.files = (e.files == null
+ ? com.sun.tools.javac.util.List.of(fo)
+ : e.files.prepend(fo));
}
}
}
return this;
}
@@ -396,11 +393,11 @@
}
class Entry {
final String name;
Boolean excluded;
- List<JavaFileObject> files;
+ com.sun.tools.javac.util.List<JavaFileObject> files;
Entry(String name) {
this.name = name;
}