Skip to content

Commit

Permalink
8254796: Cleanup pervasive unnecessary parameter
Browse files Browse the repository at this point in the history
Reviewed-by: ksrini, hannesw
  • Loading branch information
jonathan-gibbons committed Oct 19, 2020
1 parent 953e472 commit 60f63ec
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 37 deletions.
Expand Up @@ -126,13 +126,12 @@ public HtmlConfiguration getConfiguration() {
* @throws DocletException if there is a problem while writing the other files * @throws DocletException if there is a problem while writing the other files
*/ */
@Override // defined by AbstractDoclet @Override // defined by AbstractDoclet
protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree) protected void generateOtherFiles(ClassTree classtree)
throws DocletException { throws DocletException {
super.generateOtherFiles(docEnv, classtree); super.generateOtherFiles(classtree);
HtmlOptions options = configuration.getOptions(); HtmlOptions options = configuration.getOptions();
if (options.linkSource()) { if (options.linkSource()) {
SourceToHTMLConverter.convertRoot(configuration, SourceToHTMLConverter.convertRoot(configuration,DocPaths.SOURCE_OUTPUT);
docEnv, DocPaths.SOURCE_OUTPUT);
} }
// Modules with no documented classes may be specified on the // Modules with no documented classes may be specified on the
// command line to specify a service provider, allow these. // command line to specify a service provider, allow these.
Expand Down
Expand Up @@ -80,8 +80,6 @@ public class SourceToHTMLConverter {
private final Resources resources; private final Resources resources;
private final Utils utils; private final Utils utils;


private final DocletEnvironment docEnv;

private final DocPath outputdir; private final DocPath outputdir;


/** /**
Expand All @@ -90,33 +88,30 @@ public class SourceToHTMLConverter {
*/ */
private DocPath relativePath = DocPath.empty; private DocPath relativePath = DocPath.empty;


private SourceToHTMLConverter(HtmlConfiguration configuration, DocletEnvironment rd, private SourceToHTMLConverter(HtmlConfiguration configuration, DocPath outputdir) {
DocPath outputdir) {
this.configuration = configuration; this.configuration = configuration;
this.options = configuration.getOptions(); this.options = configuration.getOptions();
this.messages = configuration.getMessages(); this.messages = configuration.getMessages();
this.resources = configuration.docResources; this.resources = configuration.docResources;
this.utils = configuration.utils; this.utils = configuration.utils;
this.docEnv = rd;
this.outputdir = outputdir; this.outputdir = outputdir;
} }


/** /**
* Translate the TypeElements in the given DocletEnvironment to HTML representation. * Translate the TypeElements in the given DocletEnvironment to HTML representation.
* *
* @param configuration the configuration. * @param configuration the configuration.
* @param docEnv the DocletEnvironment to convert.
* @param outputdir the name of the directory to output to. * @param outputdir the name of the directory to output to.
* @throws DocFileIOException if there is a problem generating an output file * @throws DocFileIOException if there is a problem generating an output file
* @throws SimpleDocletException if there is a problem reading a source file * @throws SimpleDocletException if there is a problem reading a source file
*/ */
public static void convertRoot(HtmlConfiguration configuration, DocletEnvironment docEnv, public static void convertRoot(HtmlConfiguration configuration, DocPath outputdir)
DocPath outputdir) throws DocFileIOException, SimpleDocletException { throws DocFileIOException, SimpleDocletException {
new SourceToHTMLConverter(configuration, docEnv, outputdir).generate(); new SourceToHTMLConverter(configuration, outputdir).generate();
} }


void generate() throws DocFileIOException, SimpleDocletException { void generate() throws DocFileIOException, SimpleDocletException {
if (docEnv == null || outputdir == null) { if (outputdir == null) {
return; return;
} }
for (ModuleElement mdl : configuration.getSpecifiedModuleElements()) { for (ModuleElement mdl : configuration.getSpecifiedModuleElements()) {
Expand Down
Expand Up @@ -110,7 +110,7 @@ public boolean run(DocletEnvironment docEnv) {


try { try {
try { try {
startGeneration(docEnv); startGeneration();
return true; return true;
} catch (UncheckedDocletException e) { } catch (UncheckedDocletException e) {
throw (DocletException) e.getCause(); throw (DocletException) e.getCause();
Expand Down Expand Up @@ -187,7 +187,7 @@ public SourceVersion getSupportedSourceVersion() {
* *
* @throws DocletException if there is a problem while generating the documentation * @throws DocletException if there is a problem while generating the documentation
*/ */
private void startGeneration(DocletEnvironment docEnv) throws DocletException { private void startGeneration() throws DocletException {


// Modules with no documented classes may be specified on the // Modules with no documented classes may be specified on the
// command line to specify a service provider, allow these. // command line to specify a service provider, allow these.
Expand All @@ -203,25 +203,23 @@ private void startGeneration(DocletEnvironment docEnv) throws DocletException {
configuration.getDocletVersion()); configuration.getDocletVersion());
ClassTree classtree = new ClassTree(configuration, configuration.getOptions().noDeprecated()); ClassTree classtree = new ClassTree(configuration, configuration.getOptions().noDeprecated());


generateClassFiles(docEnv, classtree); generateClassFiles(classtree);


ElementListWriter.generate(configuration); ElementListWriter.generate(configuration);
generatePackageFiles(classtree); generatePackageFiles(classtree);
generateModuleFiles(); generateModuleFiles();


generateOtherFiles(docEnv, classtree); generateOtherFiles(classtree);
configuration.tagletManager.printReport(); configuration.tagletManager.printReport();
} }


/** /**
* Generate additional documentation that is added to the API documentation. * Generate additional documentation that is added to the API documentation.
* *
* @param docEnv the DocletEnvironment
* @param classtree the data structure representing the class tree * @param classtree the data structure representing the class tree
* @throws DocletException if there is a problem while generating the documentation * @throws DocletException if there is a problem while generating the documentation
*/ */
protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree) protected void generateOtherFiles(ClassTree classtree) throws DocletException {
throws DocletException {
BuilderFactory builderFactory = configuration.getBuilderFactory(); BuilderFactory builderFactory = configuration.getBuilderFactory();
AbstractBuilder constantsSummaryBuilder = builderFactory.getConstantsSummaryBuilder(); AbstractBuilder constantsSummaryBuilder = builderFactory.getConstantsSummaryBuilder();
constantsSummaryBuilder.build(); constantsSummaryBuilder.build();
Expand Down Expand Up @@ -258,31 +256,22 @@ protected abstract void generateClassFiles(SortedSet<TypeElement> arr, ClassTree
/** /**
* Iterate through all classes and construct documentation for them. * Iterate through all classes and construct documentation for them.
* *
* @param docEnv the DocletEnvironment
* @param classtree the data structure representing the class tree * @param classtree the data structure representing the class tree
* @throws DocletException if there is a problem while generating the documentation * @throws DocletException if there is a problem while generating the documentation
*/ */
protected void generateClassFiles(DocletEnvironment docEnv, ClassTree classtree) protected void generateClassFiles(ClassTree classtree)
throws DocletException { throws DocletException {
generateClassFiles(classtree); // handle classes specified as files on the command line
for (PackageElement pkg : configuration.typeElementCatalog.packages()) {
generateClassFiles(configuration.typeElementCatalog.allClasses(pkg), classtree);
}

// handle classes specified in m odules and packages on the command line
SortedSet<PackageElement> packages = new TreeSet<>(utils.comparators.makePackageComparator()); SortedSet<PackageElement> packages = new TreeSet<>(utils.comparators.makePackageComparator());
packages.addAll(configuration.getSpecifiedPackageElements()); packages.addAll(configuration.getSpecifiedPackageElements());
configuration.modulePackages.values().stream().forEach(packages::addAll); configuration.modulePackages.values().stream().forEach(packages::addAll);
for (PackageElement pkg : packages) { for (PackageElement pkg : packages) {
generateClassFiles(utils.getAllClasses(pkg), classtree); generateClassFiles(utils.getAllClasses(pkg), classtree);
} }
} }

/**
* Generate the class files for single classes specified on the command line.
*
* @param classtree the data structure representing the class tree
* @throws DocletException if there is a problem while generating the documentation
*/
private void generateClassFiles(ClassTree classtree) throws DocletException {
SortedSet<PackageElement> packages = configuration.typeElementCatalog.packages();
for (PackageElement pkg : packages) {
generateClassFiles(configuration.typeElementCatalog.allClasses(pkg), classtree);
}
}
} }

1 comment on commit 60f63ec

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 60f63ec Oct 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.