Skip to content
Permalink
Browse files

8237845: Encapsulate doclet options

Reviewed-by: hannesw, prappo
  • Loading branch information
jonathan-gibbons committed Jan 27, 2020
1 parent 6b4223e commit 08e63539f2c22f354b6585994c593bcc8880e0cc
Showing with 699 additions and 239 deletions.
  1. +2 −2 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java
  2. +2 −2 ....javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractOverviewIndexWriter.java
  3. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java
  4. +3 −3 ...jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java
  5. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java
  6. +3 −3 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java
  7. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java
  8. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java
  9. +6 −6 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java
  10. +19 −17 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java
  11. +18 −18 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java
  12. +17 −17 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
  13. +213 −23 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlOptions.java
  14. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java
  15. +4 −4 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java
  16. +3 −3 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java
  17. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java
  18. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java
  19. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java
  20. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java
  21. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java
  22. +7 −7 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java
  23. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java
  24. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java
  25. +26 −26 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java
  26. +4 −4 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java
  27. +11 −11 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseConfiguration.java
  28. +294 −29 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseOptions.java
  29. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Messages.java
  30. +2 −4 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PropertyUtils.java
  31. +1 −1 ...vadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java
  32. +1 −1 ...re/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java
  33. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java
  34. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/EnumConstantBuilder.java
  35. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java
  36. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java
  37. +2 −2 ...jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java
  38. +9 −9 ...dk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java
  39. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java
  40. +6 −6 ...dk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java
  41. +6 −6 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java
  42. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassTree.java
  43. +2 −2 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ElementListWriter.java
  44. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java
  45. +4 −4 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/MetaKeywords.java
  46. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/StandardDocFileFactory.java
  47. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/TypeElementCatalog.java
  48. +4 −5 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java
  49. +2 −2 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberTable.java
  50. +6 −0 src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOptions.java
@@ -378,7 +378,7 @@ protected void addUseInfo(List<? extends Element> mems, Content heading, Content
}

protected void serialWarning(Element e, String key, String a1, String a2) {
if (options.serialWarn) {
if (options.serialWarn()) {
configuration.messages.warning(e, key, a1, a2);
}
}
@@ -596,7 +596,7 @@ Content toContent() {
// Name
HtmlTree nameSpan = new HtmlTree(HtmlTag.SPAN);
nameSpan.setStyle(HtmlStyle.memberName);
if (options.linkSource) {
if (options.linkSource()) {
Content name = new StringContent(name(element));
writer.addSrcLink(element, name, nameSpan);
} else {
@@ -141,7 +141,7 @@ protected void buildOverviewIndexFile(String title, String description)
.setFooter(footer)
.toContent());
printHtmlDocument(
configuration.metakeywords.getOverviewMetaKeywords(title, configuration.getOptions().docTitle),
configuration.metakeywords.getOverviewMetaKeywords(title, configuration.getOptions().docTitle()),
description, body);
}

@@ -158,7 +158,7 @@ protected void buildOverviewIndexFile(String title, String description)
* @param body the document tree to which the title will be added
*/
protected void addConfigurationTitle(Content body) {
String doctitle = configuration.getOptions().docTitle;
String doctitle = configuration.getOptions().docTitle();
if (!doctitle.isEmpty()) {
Content title = new RawHtml(doctitle);
Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
@@ -113,7 +113,7 @@ protected void addPackages(Content content) {
.setHeader(new TableHeader(contents.packageLabel, contents.descriptionLabel))
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast);
for (PackageElement pkg : configuration.packages) {
if (!(configuration.getOptions().noDeprecated && utils.isDeprecated(pkg))) {
if (!(options.noDeprecated() && utils.isDeprecated(pkg))) {
Content packageLinkContent = getPackageLink(pkg, getPackageName(pkg));
Content summaryContent = new ContentBuilder();
addSummaryComment(pkg, summaryContent);
@@ -187,7 +187,7 @@ public void addAnnotationTypeSignature(String modifiers, Content annotationInfoT
LinkInfoImpl.Kind.CLASS_SIGNATURE, annotationType);
Content annotationName = new StringContent(utils.getSimpleName(annotationType));
Content parameterLinks = getTypeParameterLinks(linkInfo);
if (configuration.getOptions().linkSource) {
if (options.linkSource()) {
addSrcLink(annotationType, annotationName, pre);
pre.add(parameterLinks);
} else {
@@ -203,7 +203,7 @@ public void addAnnotationTypeSignature(String modifiers, Content annotationInfoT
*/
@Override
public void addAnnotationTypeDescription(Content annotationInfoTree) {
if (!configuration.getOptions().noComment) {
if (!options.noComment()) {
if (!utils.getFullBody(annotationType).isEmpty()) {
addInlineComment(annotationType, annotationInfoTree);
}
@@ -215,7 +215,7 @@ public void addAnnotationTypeDescription(Content annotationInfoTree) {
*/
@Override
public void addAnnotationTypeTagInfo(Content annotationInfoTree) {
if (!configuration.getOptions().noComment) {
if (!options.noComment()) {
addTagsInfo(annotationType, annotationInfoTree);
}
}
@@ -159,7 +159,7 @@ public ClassUseWriter(HtmlConfiguration configuration,
*/
public static void generate(HtmlConfiguration configuration, ClassTree classtree) throws DocFileIOException {
ClassUseMapper mapper = new ClassUseMapper(configuration, classtree);
boolean nodeprecated = configuration.getOptions().noDeprecated;
boolean nodeprecated = configuration.getOptions().noDeprecated();
Utils utils = configuration.utils;
for (TypeElement aClass : configuration.getIncludedTypeElements()) {
// If -nodeprecated option is set and the containing package is marked
@@ -228,7 +228,7 @@ public void addClassSignature(String modifiers, Content classInfoTree) {
linkInfo.linkToSelf = false;
Content className = new StringContent(utils.getSimpleName(typeElement));
Content parameterLinks = getTypeParameterLinks(linkInfo);
if (configuration.getOptions().linkSource) {
if (options.linkSource()) {
addSrcLink(typeElement, className, pre);
pre.add(parameterLinks);
} else {
@@ -299,7 +299,7 @@ private Content getRecordComponents(TypeElement typeElem) {
*/
@Override
public void addClassDescription(Content classInfoTree) {
if(!configuration.getOptions().noComment) {
if (!options.noComment()) {
// generate documentation for the class.
if (!utils.getFullBody(typeElement).isEmpty()) {
addInlineComment(typeElement, classInfoTree);
@@ -312,7 +312,7 @@ public void addClassDescription(Content classInfoTree) {
*/
@Override
public void addClassTagInfo(Content classInfoTree) {
if(!configuration.getOptions().noComment) {
if (!options.noComment()) {
// Print Information about all the tags here
addTagsInfo(typeElement, classInfoTree);
}
@@ -162,7 +162,7 @@ private void copyDirectory(DocFile srcdir, final DocPath dstDocPath,
}
}
} else if (srcfile.isDirectory()) {
if (options.copyDocfileSubdirs
if (options.copyDocfileSubdirs()
&& !configuration.shouldExcludeDocFileDir(srcfile.getName())) {
DocPath dirDocPath = dstDocPath.resolve(srcfile.getName());
copyDirectory(srcfile, dirDocPath, first);
@@ -201,7 +201,7 @@ public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedT
Content classLink = writer.getPreQualifiedClassLink(
LinkInfoImpl.Kind.MEMBER, typeElement, false);
Content label;
if (options.summarizeOverriddenMethods) {
if (options.summarizeOverriddenMethods()) {
label = new StringContent(utils.isClass(typeElement)
? resources.getText("doclet.Fields_Declared_In_Class")
: resources.getText("doclet.Fields_Declared_In_Interface"));
@@ -132,7 +132,7 @@ protected void addHelpFileContents(Content contentTree) {
ul.setStyle(HtmlStyle.blockList);

// Overview
if (options.createOverview) {
if (options.createOverview()) {
Content overviewHeading = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.overviewLabel);
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, overviewHeading);
@@ -246,7 +246,7 @@ protected void addHelpFileContents(Content contentTree) {
ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));

// Class Use
if (options.classUse) {
if (options.classUse()) {
Content useHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.getContent("doclet.help.use.head"));
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, useHead);
@@ -257,7 +257,7 @@ protected void addHelpFileContents(Content contentTree) {
}

// Tree
if (options.createTree) {
if (options.createTree()) {
Content treeHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.getContent("doclet.help.tree.head"));
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, treeHead);
@@ -275,7 +275,7 @@ protected void addHelpFileContents(Content contentTree) {
}

// Deprecated
if (!(options.noDeprecatedList || options.noDeprecated)) {
if (!(options.noDeprecatedList() || options.noDeprecated())) {
Content dHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.deprecatedAPI);
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, dHead);
@@ -288,9 +288,9 @@ protected void addHelpFileContents(Content contentTree) {
}

// Index
if (options.createIndex) {
if (options.createIndex()) {
Content indexlink;
if (options.splitIndex) {
if (options.splitIndex()) {
indexlink = links.createLink(DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)),
resources.getText("doclet.Index"));
} else {
@@ -188,7 +188,7 @@ public boolean finishOptionSettings() {
docPaths = new DocPaths(utils);
setCreateOverview();
setTopFile(docEnv);
workArounds.initDocLint(options.doclintOpts.values(), tagletManager.getAllTagletNames());
workArounds.initDocLint(options.doclintOpts().values(), tagletManager.getAllTagletNames());
return true;
}

@@ -206,7 +206,7 @@ protected void setTopFile(DocletEnvironment docEnv) {
if (!checkForDeprecation(docEnv)) {
return;
}
if (options.createOverview) {
if (options.createOverview()) {
topFile = DocPaths.INDEX;
} else {
if (showModules) {
@@ -224,7 +224,7 @@ protected void setTopFile(DocletEnvironment docEnv) {
}

protected TypeElement getValidClass(List<TypeElement> classes) {
if (!options.noDeprecated) {
if (!options.noDeprecated()) {
return classes.get(0);
}
for (TypeElement te : classes) {
@@ -246,14 +246,14 @@ protected boolean checkForDeprecation(DocletEnvironment docEnv) {

/**
* Generate "overview.html" page if option "-overview" is used or number of
* packages is more than one. Sets {@link HtmlOptions#createOverview} field to true.
* packages is more than one. Sets {@code HtmlOptions.createOverview} field to true.
*/
protected void setCreateOverview() {
if (!options.noOverview) {
if (options.overviewPath != null
if (!options.noOverview()) {
if (options.overviewPath() != null
|| modules.size() > 1
|| (modules.isEmpty() && packages.size() > 1)) {
options.createOverview = true;
options.setCreateOverview(true);
}
}
}
@@ -283,7 +283,7 @@ public Locale getLocale() {
*/
@Override
public JavaFileObject getOverviewPath() {
String overviewpath = options.overviewPath;
String overviewpath = options.overviewPath();
if (overviewpath != null && getFileManager() instanceof StandardJavaFileManager) {
StandardJavaFileManager fm = (StandardJavaFileManager) getFileManager();
return fm.getJavaFileObjects(overviewpath).iterator().next();
@@ -292,7 +292,7 @@ public JavaFileObject getOverviewPath() {
}

public DocPath getMainStylesheet() {
String stylesheetfile = options.stylesheetFile;
String stylesheetfile = options.stylesheetFile();
if(!stylesheetfile.isEmpty()){
DocFile docFile = DocFile.createFileForInput(this, stylesheetfile);
return DocPath.create(docFile.getName());
@@ -301,7 +301,7 @@ public DocPath getMainStylesheet() {
}

public List<DocPath> getAdditionalStylesheets() {
return options.additionalStylesheets.stream()
return options.additionalStylesheets().stream()
.map(ssf -> DocFile.createFileForInput(this, ssf)).map(file -> DocPath.create(file.getName()))
.collect(Collectors.toList());
}
@@ -342,16 +342,18 @@ protected void buildSearchTagIndex() {

@Override
protected boolean finishOptionSettings0() throws DocletException {
if (options.docEncoding == null) {
if (options.charset == null) {
options.docEncoding = options.charset = (options.encoding == null) ? HTML_DEFAULT_CHARSET : options.encoding;
if (options.docEncoding() == null) {
if (options.charset() == null) {
String charset = (options.encoding() == null) ? HTML_DEFAULT_CHARSET : options.encoding();
options.setCharset(charset);
options.setDocEncoding((options.charset()));
} else {
options.docEncoding = options.charset;
options.setDocEncoding(options.charset());
}
} else {
if (options.charset == null) {
options.charset = options.docEncoding;
} else if (!options.charset.equals(options.docEncoding)) {
if (options.charset() == null) {
options.setCharset(options.docEncoding());
} else if (!options.charset().equals(options.docEncoding())) {
reporter.print(ERROR, resources.getText("doclet.Option_conflict", "-charset", "-docencoding"));
return false;
}
@@ -109,7 +109,7 @@ protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree)
throws DocletException {
super.generateOtherFiles(docEnv, classtree);
HtmlOptions options = configuration.getOptions();
if (options.linkSource) {
if (options.linkSource()) {
SourceToHTMLConverter.convertRoot(configuration,
docEnv, DocPaths.SOURCE_OUTPUT);
}
@@ -120,37 +120,37 @@ protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree)
messages.error("doclet.No_Non_Deprecated_Classes_To_Document");
return;
}
boolean nodeprecated = options.noDeprecated;
performCopy(options.helpFile);
performCopy(options.stylesheetFile);
for (String stylesheet : options.additionalStylesheets) {
boolean nodeprecated = options.noDeprecated();
performCopy(options.helpFile());
performCopy(options.stylesheetFile());
for (String stylesheet : options.additionalStylesheets()) {
performCopy(stylesheet);
}
// do early to reduce memory footprint
if (options.classUse) {
if (options.classUse()) {
ClassUseWriter.generate(configuration, classtree);
}
IndexBuilder indexbuilder = new IndexBuilder(configuration, nodeprecated);

if (options.createTree) {
if (options.createTree()) {
TreeWriter.generate(configuration, classtree);
}

if (!(options.noDeprecatedList || nodeprecated)) {
if (!(options.noDeprecatedList() || nodeprecated)) {
DeprecatedListWriter.generate(configuration);
}

if (options.createOverview) {
if (options.createOverview()) {
if (configuration.showModules) {
ModuleIndexWriter.generate(configuration);
} else {
PackageIndexWriter.generate(configuration);
}
}

if (options.createIndex) {
if (options.createIndex()) {
configuration.buildSearchTagIndex();
if (options.splitIndex) {
if (options.splitIndex()) {
SplitIndexWriter.generate(configuration, indexbuilder);
} else {
SingleIndexWriter.generate(configuration, indexbuilder);
@@ -163,25 +163,25 @@ protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree)
SystemPropertiesWriter.generate(configuration);
}

if (options.createOverview) {
if (options.createOverview()) {
IndexRedirectWriter.generate(configuration, DocPaths.OVERVIEW_SUMMARY, DocPaths.INDEX);
} else {
IndexRedirectWriter.generate(configuration);
}

if (options.helpFile.isEmpty() && !options.noHelp) {
if (options.helpFile().isEmpty() && !options.noHelp()) {
HelpWriter.generate(configuration);
}
// If a stylesheet file is not specified, copy the default stylesheet
// and replace newline with platform-specific newline.
DocFile f;
if (options.stylesheetFile.length() == 0) {
if (options.stylesheetFile().length() == 0) {
f = DocFile.createFileForOutput(configuration, DocPaths.STYLESHEET);
f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.STYLESHEET), true, true);
}
f = DocFile.createFileForOutput(configuration, DocPaths.JAVASCRIPT);
f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.JAVASCRIPT), true, true);
if (options.createIndex) {
if (options.createIndex()) {
f = DocFile.createFileForOutput(configuration, DocPaths.SEARCH_JS);
f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.SEARCH_JS), true, true);

@@ -280,12 +280,12 @@ protected void generatePackageFiles(ClassTree classtree) throws DocletException
// if -nodeprecated option is set and the package is marked as
// deprecated, do not generate the package-summary.html, package-frame.html
// and package-tree.html pages for that package.
if (!(options.noDeprecated && utils.isDeprecated(pkg))) {
if (!(options.noDeprecated() && utils.isDeprecated(pkg))) {
AbstractBuilder packageSummaryBuilder =
configuration.getBuilderFactory().getPackageSummaryBuilder(pkg);
packageSummaryBuilder.build();
if (options.createTree) {
PackageTreeWriter.generate(configuration, pkg, options.noDeprecated);
if (options.createTree()) {
PackageTreeWriter.generate(configuration, pkg, options.noDeprecated());
}
}
}

0 comments on commit 08e6353

Please sign in to comment.