src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java
Print this page
*** 21,40 ****
* 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;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.EnumSet;
- import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileManager.Location;
--- 21,43 ----
* 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 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.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,61 ****
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;
/**
* 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
--- 52,64 ----
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.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,151 ****
messager.error(Position.NOPOS, ex.getMessage());
return null;
}
}
! public RootDocImpl getRootDocImpl(String doclocale,
! String encoding,
! ModifierFilter filter,
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;
javadocFinder.sourceCompleter = docClasses ? Completer.NULL_COMPLETER : sourceCompleter;
if (docClasses) {
// If -Xclasses is set, the args should be a series of class names
--- 125,146 ----
messager.error(Position.NOPOS, ex.getMessage());
return null;
}
}
! public DocletEnvironment getEnvironment(String encoding,
! String showAccess,
! String overviewpath,
List<String> args,
Iterable<? extends JavaFileObject> fileObjects,
List<String> subPackages,
List<String> excludedPackages,
boolean docClasses,
boolean quiet) throws IOException {
docenv = DocEnv.instance(context);
! 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,164 ****
docenv.error(null, "main.illegal_class_name", arg);
}
if (messager.nerrors() != 0) {
return null;
}
! return new RootDocImpl(docenv, args, options);
}
ListBuffer<JCCompilationUnit> classTrees = new ListBuffer<>();
Set<String> includedPackages = new LinkedHashSet<>();
--- 149,159 ----
docenv.error(null, "main.illegal_class_name", arg);
}
if (messager.nerrors() != 0) {
return null;
}
! return new RootDocImpl(docenv, args);
}
ListBuffer<JCCompilationUnit> classTrees = new ListBuffer<>();
Set<String> includedPackages = new LinkedHashSet<>();
*** 199,211 ****
// 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);
parse(files, packageTrees, false);
}
if (messager.nerrors() != 0) {
return null;
--- 194,205 ----
// 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())
! docenv.warning("main.no_source_files_for_package", packageName);
parse(files, packageTrees, false);
}
if (messager.nerrors() != 0) {
return null;
*** 216,227 ****
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);
}
/** Is the given string a valid package name? */
boolean isValidPackageName(String s) {
int index;
--- 210,222 ----
javadocEnter.main(classTrees.toList().appendList(packageTrees.toList()));
} catch (Abort ex) {}
if (messager.nerrors() != 0)
return null;
! 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,303 ****
/**
* 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<>();
for (JCCompilationUnit t : trees) {
for (JCTree def : t.defs) {
if (def.hasTag(JCTree.Tag.CLASSDEF))
! result.append((JCClassDecl)def);
}
}
! return result.toList();
}
/**
* A table to manage included and excluded packages.
*/
--- 281,298 ----
/**
* From a list of top level trees, return the list of contained class definitions
*/
List<JCClassDecl> listClasses(List<JCCompilationUnit> trees) {
! List<JCClassDecl> result = new ArrayList<>();
for (JCCompilationUnit t : trees) {
for (JCTree def : t.defs) {
if (def.hasTag(JCTree.Tag.CLASSDEF))
! result.add((JCClassDecl)def);
}
}
! return result;
}
/**
* A table to manage included and excluded packages.
*/
*** 336,346 ****
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));
}
}
}
return this;
}
--- 331,343 ----
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
! ? com.sun.tools.javac.util.List.of(fo)
! : e.files.prepend(fo));
}
}
}
return this;
}
*** 396,406 ****
}
class Entry {
final String name;
Boolean excluded;
! List<JavaFileObject> files;
Entry(String name) {
this.name = name;
}
--- 393,403 ----
}
class Entry {
final String name;
Boolean excluded;
! com.sun.tools.javac.util.List<JavaFileObject> files;
Entry(String name) {
this.name = name;
}