8237492: Reorganize impl of doclet options

8237726: Fix signature of StandardDoclet.getSupportedOptions

Reviewed-by: prappo, hannesw, ksrini
This commit is contained in:
Jonathan Gibbons 2020-01-23 15:52:54 -08:00
parent c6c828fa6e
commit 9e4830fc30
55 changed files with 1609 additions and 1326 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -154,11 +154,11 @@ public interface Doclet {
* The kind of an option. * The kind of an option.
*/ */
enum Kind { enum Kind {
/** an extended option, such as those prefixed with -X */ /** An extended option, such as those prefixed with {@code -X}. */
EXTENDED, EXTENDED,
/** a standard option */ /** A standard option. */
STANDARD, STANDARD,
/** an implementation reserved option */ /** An implementation-reserved option. */
OTHER; OTHER;
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -85,7 +85,7 @@ public class StandardDoclet implements Doclet {
} }
@Override @Override
public Set<Doclet.Option> getSupportedOptions() { public Set<? extends Doclet.Option> getSupportedOptions() {
return htmlDoclet.getSupportedOptions(); return htmlDoclet.getSupportedOptions();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -73,6 +73,7 @@ import static javax.lang.model.element.Modifier.SYNCHRONIZED;
public abstract class AbstractMemberWriter implements MemberSummaryWriter { public abstract class AbstractMemberWriter implements MemberSummaryWriter {
protected final HtmlConfiguration configuration; protected final HtmlConfiguration configuration;
protected final HtmlOptions options;
protected final Utils utils; protected final Utils utils;
protected final SubWriterHolderWriter writer; protected final SubWriterHolderWriter writer;
protected final Contents contents; protected final Contents contents;
@ -80,14 +81,11 @@ public abstract class AbstractMemberWriter implements MemberSummaryWriter {
protected final Links links; protected final Links links;
protected final TypeElement typeElement; protected final TypeElement typeElement;
public final boolean nodepr;
protected boolean printedSummaryHeader = false;
public AbstractMemberWriter(SubWriterHolderWriter writer, TypeElement typeElement) { public AbstractMemberWriter(SubWriterHolderWriter writer, TypeElement typeElement) {
this.configuration = writer.configuration; this.configuration = writer.configuration;
this.options = configuration.getOptions();
this.writer = writer; this.writer = writer;
this.nodepr = configuration.nodeprecated;
this.typeElement = typeElement; this.typeElement = typeElement;
this.utils = configuration.utils; this.utils = configuration.utils;
this.contents = configuration.contents; this.contents = configuration.contents;
@ -380,7 +378,7 @@ public abstract class AbstractMemberWriter implements MemberSummaryWriter {
} }
protected void serialWarning(Element e, String key, String a1, String a2) { protected void serialWarning(Element e, String key, String a1, String a2) {
if (configuration.serialwarn) { if (options.serialWarn) {
configuration.messages.warning(e, key, a1, a2); configuration.messages.warning(e, key, a1, a2);
} }
} }
@ -598,7 +596,7 @@ public abstract class AbstractMemberWriter implements MemberSummaryWriter {
// Name // Name
HtmlTree nameSpan = new HtmlTree(HtmlTag.SPAN); HtmlTree nameSpan = new HtmlTree(HtmlTag.SPAN);
nameSpan.setStyle(HtmlStyle.memberName); nameSpan.setStyle(HtmlStyle.memberName);
if (configuration.linksource) { if (options.linkSource) {
Content name = new StringContent(name(element)); Content name = new StringContent(name(element));
writer.addSrcLink(element, name, nameSpan); writer.addSrcLink(element, name, nameSpan);
} else { } else {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -141,7 +141,7 @@ public abstract class AbstractOverviewIndexWriter extends HtmlDocletWriter {
.setFooter(footer) .setFooter(footer)
.toContent()); .toContent());
printHtmlDocument( printHtmlDocument(
configuration.metakeywords.getOverviewMetaKeywords(title, configuration.doctitle), configuration.metakeywords.getOverviewMetaKeywords(title, configuration.getOptions().docTitle),
description, body); description, body);
} }
@ -158,8 +158,9 @@ public abstract class AbstractOverviewIndexWriter extends HtmlDocletWriter {
* @param body the document tree to which the title will be added * @param body the document tree to which the title will be added
*/ */
protected void addConfigurationTitle(Content body) { protected void addConfigurationTitle(Content body) {
if (configuration.doctitle.length() > 0) { String doctitle = configuration.getOptions().docTitle;
Content title = new RawHtml(configuration.doctitle); if (!doctitle.isEmpty()) {
Content title = new RawHtml(doctitle);
Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, title); HtmlStyle.title, title);
Content div = HtmlTree.DIV(HtmlStyle.header, heading); Content div = HtmlTree.DIV(HtmlStyle.header, heading);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -113,7 +113,7 @@ public class AllPackagesIndexWriter extends HtmlDocletWriter {
.setHeader(new TableHeader(contents.packageLabel, contents.descriptionLabel)) .setHeader(new TableHeader(contents.packageLabel, contents.descriptionLabel))
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast); .setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast);
for (PackageElement pkg : configuration.packages) { for (PackageElement pkg : configuration.packages) {
if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) { if (!(configuration.getOptions().noDeprecated && utils.isDeprecated(pkg))) {
Content packageLinkContent = getPackageLink(pkg, getPackageName(pkg)); Content packageLinkContent = getPackageLink(pkg, getPackageName(pkg));
Content summaryContent = new ContentBuilder(); Content summaryContent = new ContentBuilder();
addSummaryComment(pkg, summaryContent); addSummaryComment(pkg, summaryContent);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -187,7 +187,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
LinkInfoImpl.Kind.CLASS_SIGNATURE, annotationType); LinkInfoImpl.Kind.CLASS_SIGNATURE, annotationType);
Content annotationName = new StringContent(utils.getSimpleName(annotationType)); Content annotationName = new StringContent(utils.getSimpleName(annotationType));
Content parameterLinks = getTypeParameterLinks(linkInfo); Content parameterLinks = getTypeParameterLinks(linkInfo);
if (configuration.linksource) { if (configuration.getOptions().linkSource) {
addSrcLink(annotationType, annotationName, pre); addSrcLink(annotationType, annotationName, pre);
pre.add(parameterLinks); pre.add(parameterLinks);
} else { } else {
@ -203,7 +203,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
*/ */
@Override @Override
public void addAnnotationTypeDescription(Content annotationInfoTree) { public void addAnnotationTypeDescription(Content annotationInfoTree) {
if (!configuration.nocomment) { if (!configuration.getOptions().noComment) {
if (!utils.getFullBody(annotationType).isEmpty()) { if (!utils.getFullBody(annotationType).isEmpty()) {
addInlineComment(annotationType, annotationInfoTree); addInlineComment(annotationType, annotationInfoTree);
} }
@ -215,7 +215,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
*/ */
@Override @Override
public void addAnnotationTypeTagInfo(Content annotationInfoTree) { public void addAnnotationTypeTagInfo(Content annotationInfoTree) {
if (!configuration.nocomment) { if (!configuration.getOptions().noComment) {
addTagsInfo(annotationType, annotationInfoTree); addTagsInfo(annotationType, annotationInfoTree);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -54,6 +54,7 @@ import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
/** /**
@ -158,19 +159,21 @@ public class ClassUseWriter extends SubWriterHolderWriter {
*/ */
public static void generate(HtmlConfiguration configuration, ClassTree classtree) throws DocFileIOException { public static void generate(HtmlConfiguration configuration, ClassTree classtree) throws DocFileIOException {
ClassUseMapper mapper = new ClassUseMapper(configuration, classtree); ClassUseMapper mapper = new ClassUseMapper(configuration, classtree);
boolean nodeprecated = configuration.getOptions().noDeprecated;
Utils utils = configuration.utils;
for (TypeElement aClass : configuration.getIncludedTypeElements()) { for (TypeElement aClass : configuration.getIncludedTypeElements()) {
// If -nodeprecated option is set and the containing package is marked // If -nodeprecated option is set and the containing package is marked
// as deprecated, do not generate the class-use page. We will still generate // as deprecated, do not generate the class-use page. We will still generate
// the class-use page if the class is marked as deprecated but the containing // the class-use page if the class is marked as deprecated but the containing
// package is not since it could still be linked from that package-use page. // package is not since it could still be linked from that package-use page.
if (!(configuration.nodeprecated && if (!(nodeprecated &&
configuration.utils.isDeprecated(configuration.utils.containingPackage(aClass)))) utils.isDeprecated(utils.containingPackage(aClass))))
ClassUseWriter.generate(configuration, mapper, aClass); ClassUseWriter.generate(configuration, mapper, aClass);
} }
for (PackageElement pkg : configuration.packages) { for (PackageElement pkg : configuration.packages) {
// If -nodeprecated option is set and the package is marked // If -nodeprecated option is set and the package is marked
// as deprecated, do not generate the package-use page. // as deprecated, do not generate the package-use page.
if (!(configuration.nodeprecated && configuration.utils.isDeprecated(pkg))) if (!(nodeprecated && utils.isDeprecated(pkg)))
PackageUseWriter.generate(configuration, mapper, pkg); PackageUseWriter.generate(configuration, mapper, pkg);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -228,7 +228,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite
linkInfo.linkToSelf = false; linkInfo.linkToSelf = false;
Content className = new StringContent(utils.getSimpleName(typeElement)); Content className = new StringContent(utils.getSimpleName(typeElement));
Content parameterLinks = getTypeParameterLinks(linkInfo); Content parameterLinks = getTypeParameterLinks(linkInfo);
if (configuration.linksource) { if (configuration.getOptions().linkSource) {
addSrcLink(typeElement, className, pre); addSrcLink(typeElement, className, pre);
pre.add(parameterLinks); pre.add(parameterLinks);
} else { } else {
@ -299,7 +299,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite
*/ */
@Override @Override
public void addClassDescription(Content classInfoTree) { public void addClassDescription(Content classInfoTree) {
if(!configuration.nocomment) { if(!configuration.getOptions().noComment) {
// generate documentation for the class. // generate documentation for the class.
if (!utils.getFullBody(typeElement).isEmpty()) { if (!utils.getFullBody(typeElement).isEmpty()) {
addInlineComment(typeElement, classInfoTree); addInlineComment(typeElement, classInfoTree);
@ -312,7 +312,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite
*/ */
@Override @Override
public void addClassTagInfo(Content classInfoTree) { public void addClassTagInfo(Content classInfoTree) {
if(!configuration.nocomment) { if(!configuration.getOptions().noComment) {
// Print Information about all the tags here // Print Information about all the tags here
addTagsInfo(typeElement, classInfoTree); addTagsInfo(typeElement, classInfoTree);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -259,7 +259,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
/** /**
* Get list of all the deprecated classes and members in all the Packages * Get list of all the deprecated classes and members in all the Packages
* specified on the Command Line. * specified on the command line.
* Then instantiate DeprecatedListWriter and generate File. * Then instantiate DeprecatedListWriter and generate File.
* *
* @param configuration the current configuration of the doclet. * @param configuration the current configuration of the doclet.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -64,6 +64,7 @@ public class DocFilesHandlerImpl implements DocFilesHandler {
public final Location location; public final Location location;
public final DocPath source; public final DocPath source;
public final HtmlConfiguration configuration; public final HtmlConfiguration configuration;
private final HtmlOptions options;
private Navigation navBar; private Navigation navBar;
/** /**
@ -75,6 +76,7 @@ public class DocFilesHandlerImpl implements DocFilesHandler {
*/ */
public DocFilesHandlerImpl(HtmlConfiguration configuration, Element element) { public DocFilesHandlerImpl(HtmlConfiguration configuration, Element element) {
this.configuration = configuration; this.configuration = configuration;
this.options = configuration.getOptions();
this.element = element; this.element = element;
switch (element.getKind()) { switch (element.getKind()) {
@ -160,7 +162,7 @@ public class DocFilesHandlerImpl implements DocFilesHandler {
} }
} }
} else if (srcfile.isDirectory()) { } else if (srcfile.isDirectory()) {
if (configuration.copydocfilesubdirs if (options.copyDocfileSubdirs
&& !configuration.shouldExcludeDocFileDir(srcfile.getName())) { && !configuration.shouldExcludeDocFileDir(srcfile.getName())) {
DocPath dirDocPath = dstDocPath.resolve(srcfile.getName()); DocPath dirDocPath = dstDocPath.resolve(srcfile.getName());
copyDirectory(srcfile, dirDocPath, first); copyDirectory(srcfile, dirDocPath, first);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -201,7 +201,7 @@ public class FieldWriterImpl extends AbstractMemberWriter
Content classLink = writer.getPreQualifiedClassLink( Content classLink = writer.getPreQualifiedClassLink(
LinkInfoImpl.Kind.MEMBER, typeElement, false); LinkInfoImpl.Kind.MEMBER, typeElement, false);
Content label; Content label;
if (configuration.summarizeOverriddenMethods) { if (options.summarizeOverriddenMethods) {
label = new StringContent(utils.isClass(typeElement) label = new StringContent(utils.isClass(typeElement)
? resources.getText("doclet.Fields_Declared_In_Class") ? resources.getText("doclet.Fields_Declared_In_Class")
: resources.getText("doclet.Fields_Declared_In_Interface")); : resources.getText("doclet.Fields_Declared_In_Interface"));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -132,7 +132,7 @@ public class HelpWriter extends HtmlDocletWriter {
ul.setStyle(HtmlStyle.blockList); ul.setStyle(HtmlStyle.blockList);
// Overview // Overview
if (configuration.createoverview) { if (options.createOverview) {
Content overviewHeading = HtmlTree.HEADING(Headings.CONTENT_HEADING, Content overviewHeading = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.overviewLabel); contents.overviewLabel);
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, overviewHeading); htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, overviewHeading);
@ -246,7 +246,7 @@ public class HelpWriter extends HtmlDocletWriter {
ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
// Class Use // Class Use
if (configuration.classuse) { if (options.classUse) {
Content useHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, Content useHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.getContent("doclet.help.use.head")); contents.getContent("doclet.help.use.head"));
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, useHead); htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, useHead);
@ -257,7 +257,7 @@ public class HelpWriter extends HtmlDocletWriter {
} }
// Tree // Tree
if (configuration.createtree) { if (options.createTree) {
Content treeHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, Content treeHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.getContent("doclet.help.tree.head")); contents.getContent("doclet.help.tree.head"));
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, treeHead); htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, treeHead);
@ -275,7 +275,7 @@ public class HelpWriter extends HtmlDocletWriter {
} }
// Deprecated // Deprecated
if (!(configuration.nodeprecatedlist || configuration.nodeprecated)) { if (!(options.noDeprecatedList || options.noDeprecated)) {
Content dHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, Content dHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
contents.deprecatedAPI); contents.deprecatedAPI);
htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, dHead); htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, dHead);
@ -288,9 +288,9 @@ public class HelpWriter extends HtmlDocletWriter {
} }
// Index // Index
if (configuration.createindex) { if (options.createIndex) {
Content indexlink; Content indexlink;
if (configuration.splitindex) { if (options.splitIndex) {
indexlink = links.createLink(DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)), indexlink = links.createLink(DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)),
resources.getText("doclet.Index")); resources.getText("doclet.Index"));
} else { } else {

View File

@ -25,7 +25,6 @@
package jdk.javadoc.internal.doclets.formats.html; package jdk.javadoc.internal.doclets.formats.html;
import java.net.*;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -37,7 +36,6 @@ import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager; import javax.tools.StandardJavaFileManager;
import com.sun.source.util.DocTreePath; import com.sun.source.util.DocTreePath;
import com.sun.tools.doclint.DocLint;
import jdk.javadoc.doclet.Doclet; import jdk.javadoc.doclet.Doclet;
import jdk.javadoc.doclet.DocletEnvironment; import jdk.javadoc.doclet.DocletEnvironment;
@ -53,9 +51,9 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import static javax.tools.Diagnostic.Kind.*; import static javax.tools.Diagnostic.Kind.*;
/** /**
* Configure the output based on the command line options. * Configure the output based on the command-line options.
* <p> * <p>
* Also determine the length of the command line option. For example, * Also determine the length of the command-line option. For example,
* for a option "-header" there will be a string argument associated, then the * for a option "-header" there will be a string argument associated, then the
* the length of option "-header" is two. But for option "-nohelp" no argument * the length of option "-header" is two. But for option "-nohelp" no argument
* is needed so it's length is 1. * is needed so it's length is 1.
@ -77,125 +75,6 @@ public class HtmlConfiguration extends BaseConfiguration {
*/ */
public static final String HTML_DEFAULT_CHARSET = "utf-8"; public static final String HTML_DEFAULT_CHARSET = "utf-8";
/**
* Argument for command line option "-header".
*/
public String header = "";
/**
* Argument for command line option "-packagesheader".
*/
public String packagesheader = "";
/**
* Argument for command line option "-footer".
*/
public String footer = "";
/**
* Argument for command line option "-doctitle".
*/
public String doctitle = "";
/**
* Argument for command line option "-windowtitle".
*/
public String windowtitle = "";
/**
* Argument for command line option "-top".
*/
public String top = "";
/**
* Argument for command line option "-bottom".
*/
public String bottom = "";
/**
* Argument for command line option "-helpfile".
*/
public String helpfile = "";
/**
* Argument for command line option "-stylesheetfile".
*/
public String stylesheetfile = "";
/**
* Argument for command line option "--add-stylesheet".
*/
public List<String> additionalStylesheets = new ArrayList<>();
/**
* Argument for command line option "-Xdocrootparent".
*/
public String docrootparent = "";
/**
* True if command line option "-nohelp" is used. Default value is false.
*/
public boolean nohelp = false;
/**
* True if command line option "-splitindex" is used. Default value is
* false.
*/
public boolean splitindex = false;
/**
* False if command line option "-noindex" is used. Default value is true.
*/
public boolean createindex = true;
/**
* True if command line option "-use" is used. Default value is false.
*/
public boolean classuse = false;
/**
* False if command line option "-notree" is used. Default value is true.
*/
public boolean createtree = true;
/**
* The META charset tag used for cross-platform viewing.
*/
public String charset = null;
/**
* True if command line option "-nodeprecated" is used. Default value is
* false.
*/
public boolean nodeprecatedlist = false;
/**
* True if command line option "-nonavbar" is used. Default value is false.
*/
public boolean nonavbar = false;
/**
* True if command line option "-nooverview" is used. Default value is
* false
*/
private boolean nooverview = false;
/**
* The overview path specified with "-overview" flag.
*/
public String overviewpath = null;
/**
* This is true if option "-overview" is used or option "-overview" is not
* used and number of packages is more than one.
*/
public boolean createoverview = false;
/**
* Collected set of doclint options
*/
public Map<Doclet.Option, String> doclintOpts = new LinkedHashMap<>();
public final Resources resources; public final Resources resources;
/** /**
@ -231,6 +110,8 @@ public class HtmlConfiguration extends BaseConfiguration {
public Map<Element, List<DocPath>> localStylesheetMap = new HashMap<>(); public Map<Element, List<DocPath>> localStylesheetMap = new HashMap<>();
private final HtmlOptions options;
/** /**
* Creates an object to hold the configuration for a doclet. * Creates an object to hold the configuration for a doclet.
* *
@ -244,6 +125,7 @@ public class HtmlConfiguration extends BaseConfiguration {
messages = new Messages(this); messages = new Messages(this);
contents = new Contents(this); contents = new Contents(this);
options = new HtmlOptions(this);
String v; String v;
try { try {
@ -283,54 +165,14 @@ public class HtmlConfiguration extends BaseConfiguration {
return messages; return messages;
} }
protected boolean validateOptions() { @Override
// check shared options public HtmlOptions getOptions() {
if (!generalValidOptions()) { return options;
return false;
}
// check if helpfile exists
if (!helpfile.isEmpty()) {
DocFile help = DocFile.createFileForInput(this, helpfile);
if (!help.exists()) {
reporter.print(ERROR, resources.getText("doclet.File_not_found", helpfile));
return false;
}
}
// check if stylesheetfile exists
if (!stylesheetfile.isEmpty()) {
DocFile stylesheet = DocFile.createFileForInput(this, stylesheetfile);
if (!stylesheet.exists()) {
reporter.print(ERROR, resources.getText("doclet.File_not_found", stylesheetfile));
return false;
}
}
// check if additional stylesheets exists
for (String ssheet : additionalStylesheets) {
DocFile ssfile = DocFile.createFileForInput(this, ssheet);
if (!ssfile.exists()) {
reporter.print(ERROR, resources.getText("doclet.File_not_found", ssheet));
return false;
}
}
// In a more object-oriented world, this would be done by methods on the Option objects.
// Note that -windowtitle silently removes any and all HTML elements, and so does not need
// to be handled here.
utils.checkJavaScriptInOption("-header", header);
utils.checkJavaScriptInOption("-footer", footer);
utils.checkJavaScriptInOption("-top", top);
utils.checkJavaScriptInOption("-bottom", bottom);
utils.checkJavaScriptInOption("-doctitle", doctitle);
utils.checkJavaScriptInOption("-packagesheader", packagesheader);
return true;
} }
@Override @Override
public boolean finishOptionSettings() { public boolean finishOptionSettings() {
if (!validateOptions()) { if (!options.validateOptions()) {
return false; return false;
} }
if (!getSpecifiedTypeElements().isEmpty()) { if (!getSpecifiedTypeElements().isEmpty()) {
@ -346,7 +188,7 @@ public class HtmlConfiguration extends BaseConfiguration {
docPaths = new DocPaths(utils); docPaths = new DocPaths(utils);
setCreateOverview(); setCreateOverview();
setTopFile(docEnv); setTopFile(docEnv);
workArounds.initDocLint(doclintOpts.values(), tagletManager.getAllTagletNames()); workArounds.initDocLint(options.doclintOpts.values(), tagletManager.getAllTagletNames());
return true; return true;
} }
@ -364,7 +206,7 @@ public class HtmlConfiguration extends BaseConfiguration {
if (!checkForDeprecation(docEnv)) { if (!checkForDeprecation(docEnv)) {
return; return;
} }
if (createoverview) { if (options.createOverview) {
topFile = DocPaths.INDEX; topFile = DocPaths.INDEX;
} else { } else {
if (showModules) { if (showModules) {
@ -382,7 +224,7 @@ public class HtmlConfiguration extends BaseConfiguration {
} }
protected TypeElement getValidClass(List<TypeElement> classes) { protected TypeElement getValidClass(List<TypeElement> classes) {
if (!nodeprecated) { if (!options.noDeprecated) {
return classes.get(0); return classes.get(0);
} }
for (TypeElement te : classes) { for (TypeElement te : classes) {
@ -404,14 +246,14 @@ public class HtmlConfiguration extends BaseConfiguration {
/** /**
* Generate "overview.html" page if option "-overview" is used or number of * Generate "overview.html" page if option "-overview" is used or number of
* packages is more than one. Sets {@link #createoverview} field to true. * packages is more than one. Sets {@link HtmlOptions#createOverview} field to true.
*/ */
protected void setCreateOverview() { protected void setCreateOverview() {
if (!nooverview) { if (!options.noOverview) {
if (overviewpath != null if (options.overviewPath != null
|| modules.size() > 1 || modules.size() > 1
|| (modules.isEmpty() && packages.size() > 1)) { || (modules.isEmpty() && packages.size() > 1)) {
createoverview = true; options.createOverview = true;
} }
} }
} }
@ -441,6 +283,7 @@ public class HtmlConfiguration extends BaseConfiguration {
*/ */
@Override @Override
public JavaFileObject getOverviewPath() { public JavaFileObject getOverviewPath() {
String overviewpath = options.overviewPath;
if (overviewpath != null && getFileManager() instanceof StandardJavaFileManager) { if (overviewpath != null && getFileManager() instanceof StandardJavaFileManager) {
StandardJavaFileManager fm = (StandardJavaFileManager) getFileManager(); StandardJavaFileManager fm = (StandardJavaFileManager) getFileManager();
return fm.getJavaFileObjects(overviewpath).iterator().next(); return fm.getJavaFileObjects(overviewpath).iterator().next();
@ -449,6 +292,7 @@ public class HtmlConfiguration extends BaseConfiguration {
} }
public DocPath getMainStylesheet() { public DocPath getMainStylesheet() {
String stylesheetfile = options.stylesheetFile;
if(!stylesheetfile.isEmpty()){ if(!stylesheetfile.isEmpty()){
DocFile docFile = DocFile.createFileForInput(this, stylesheetfile); DocFile docFile = DocFile.createFileForInput(this, stylesheetfile);
return DocPath.create(docFile.getName()); return DocPath.create(docFile.getName());
@ -457,7 +301,7 @@ public class HtmlConfiguration extends BaseConfiguration {
} }
public List<DocPath> getAdditionalStylesheets() { public List<DocPath> getAdditionalStylesheets() {
return additionalStylesheets.stream() return options.additionalStylesheets.stream()
.map(ssf -> DocFile.createFileForInput(this, ssf)).map(file -> DocPath.create(file.getName())) .map(ssf -> DocFile.createFileForInput(this, ssf)).map(file -> DocPath.create(file.getName()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@ -496,265 +340,18 @@ public class HtmlConfiguration extends BaseConfiguration {
tagSearchIndexKeys = tagSearchIndexMap.keySet(); tagSearchIndexKeys = tagSearchIndexMap.keySet();
} }
@Override
public Set<Doclet.Option> getSupportedOptions() {
Resources resources = getResources();
Doclet.Option[] options = {
new Option(resources, "--add-stylesheet", 1) {
@Override
public boolean process(String opt, List<String> args) {
additionalStylesheets.add(args.get(0));
return true;
}
},
new Option(resources, "-bottom", 1) {
@Override
public boolean process(String opt, List<String> args) {
bottom = args.get(0);
return true;
}
},
new Option(resources, "-charset", 1) {
@Override
public boolean process(String opt, List<String> args) {
charset = args.get(0);
return true;
}
},
new Option(resources, "-doctitle", 1) {
@Override
public boolean process(String opt, List<String> args) {
doctitle = args.get(0);
return true;
}
},
new Option(resources, "-footer", 1) {
@Override
public boolean process(String opt, List<String> args) {
footer = args.get(0);
return true;
}
},
new Option(resources, "-header", 1) {
@Override
public boolean process(String opt, List<String> args) {
header = args.get(0);
return true;
}
},
new Option(resources, "-helpfile", 1) {
@Override
public boolean process(String opt, List<String> args) {
if (nohelp == true) {
reporter.print(ERROR, resources.getText("doclet.Option_conflict",
"-helpfile", "-nohelp"));
return false;
}
if (!helpfile.isEmpty()) {
reporter.print(ERROR, resources.getText("doclet.Option_reuse",
"-helpfile"));
return false;
}
helpfile = args.get(0);
return true;
}
},
new Option(resources, "-html5") {
@Override
public boolean process(String opt, List<String> args) {
return true;
}
},
new Option(resources, "-nohelp") {
@Override
public boolean process(String opt, List<String> args) {
nohelp = true;
if (!helpfile.isEmpty()) {
reporter.print(ERROR, resources.getText("doclet.Option_conflict",
"-nohelp", "-helpfile"));
return false;
}
return true;
}
},
new Option(resources, "-nodeprecatedlist") {
@Override
public boolean process(String opt, List<String> args) {
nodeprecatedlist = true;
return true;
}
},
new Option(resources, "-noindex") {
@Override
public boolean process(String opt, List<String> args) {
createindex = false;
if (splitindex == true) {
reporter.print(ERROR, resources.getText("doclet.Option_conflict",
"-noindex", "-splitindex"));
return false;
}
return true;
}
},
new Option(resources, "-nonavbar") {
@Override
public boolean process(String opt, List<String> args) {
nonavbar = true;
return true;
}
},
new Hidden(resources, "-nooverview") {
@Override
public boolean process(String opt, List<String> args) {
nooverview = true;
if (overviewpath != null) {
reporter.print(ERROR, resources.getText("doclet.Option_conflict",
"-nooverview", "-overview"));
return false;
}
return true;
}
},
new Option(resources, "-notree") {
@Override
public boolean process(String opt, List<String> args) {
createtree = false;
return true;
}
},
new Option(resources, "-overview", 1) {
@Override
public boolean process(String opt, List<String> args) {
overviewpath = args.get(0);
if (nooverview == true) {
reporter.print(ERROR, resources.getText("doclet.Option_conflict",
"-overview", "-nooverview"));
return false;
}
return true;
}
},
new Hidden(resources, "-packagesheader", 1) {
@Override
public boolean process(String opt, List<String> args) {
packagesheader = args.get(0);
return true;
}
},
new Option(resources, "-splitindex") {
@Override
public boolean process(String opt, List<String> args) {
splitindex = true;
if (createindex == false) {
reporter.print(ERROR, resources.getText("doclet.Option_conflict",
"-splitindex", "-noindex"));
return false;
}
return true;
}
},
new Option(resources, "--main-stylesheet -stylesheetfile", 1) {
@Override
public boolean process(String opt, List<String> args) {
stylesheetfile = args.get(0);
return true;
}
},
new Option(resources, "-top", 1) {
@Override
public boolean process(String opt, List<String> args) {
top = args.get(0);
return true;
}
},
new Option(resources, "-use") {
@Override
public boolean process(String opt, List<String> args) {
classuse = true;
return true;
}
},
new Option(resources, "-windowtitle", 1) {
@Override
public boolean process(String opt, List<String> args) {
windowtitle = args.get(0).replaceAll("\\<.*?>", "");
return true;
}
},
new XOption(resources, "-Xdoclint") {
@Override
public boolean process(String opt, List<String> args) {
doclintOpts.put(this, DocLint.XMSGS_OPTION);
return true;
}
},
new XOption(resources, "-Xdocrootparent", 1) {
@Override
public boolean process(String opt, List<String> args) {
docrootparent = args.get(0);
try {
URL ignored = new URL(docrootparent);
} catch (MalformedURLException e) {
reporter.print(ERROR, resources.getText("doclet.MalformedURL", docrootparent));
return false;
}
return true;
}
},
new XOption(resources, "doclet.usage.xdoclint-extended", "-Xdoclint:", 0) {
@Override
public boolean process(String opt, List<String> args) {
String dopt = opt.replace("-Xdoclint:", DocLint.XMSGS_CUSTOM_PREFIX);
doclintOpts.put(this, dopt);
if (dopt.contains("/")) {
reporter.print(ERROR, resources.getText("doclet.Option_doclint_no_qualifiers"));
return false;
}
if (!DocLint.isValidOption(dopt)) {
reporter.print(ERROR, resources.getText("doclet.Option_doclint_invalid_arg"));
return false;
}
return true;
}
},
new XOption(resources, "doclet.usage.xdoclint-package", "-Xdoclint/package:", 0) {
@Override
public boolean process(String opt, List<String> args) {
String dopt = opt.replace("-Xdoclint/package:", DocLint.XCHECK_PACKAGE);
doclintOpts.put(this, dopt);
if (!DocLint.isValidOption(dopt)) {
reporter.print(ERROR, resources.getText("doclet.Option_doclint_package_invalid_arg"));
return false;
}
return true;
}
},
new XOption(resources, "--no-frames") {
@Override
public boolean process(String opt, List<String> args) {
reporter.print(WARNING, resources.getText("doclet.NoFrames_specified"));
return true;
}
}
};
Set<Doclet.Option> oset = new TreeSet<>();
oset.addAll(Arrays.asList(options));
oset.addAll(super.getSupportedOptions());
return oset;
}
@Override @Override
protected boolean finishOptionSettings0() throws DocletException { protected boolean finishOptionSettings0() throws DocletException {
if (docencoding == null) { if (options.docEncoding == null) {
if (charset == null) { if (options.charset == null) {
docencoding = charset = (encoding == null) ? HTML_DEFAULT_CHARSET : encoding; options.docEncoding = options.charset = (options.encoding == null) ? HTML_DEFAULT_CHARSET : options.encoding;
} else { } else {
docencoding = charset; options.docEncoding = options.charset;
} }
} else { } else {
if (charset == null) { if (options.charset == null) {
charset = docencoding; options.charset = options.docEncoding;
} else if (!charset.equals(docencoding)) { } else if (!options.charset.equals(options.docEncoding)) {
reporter.print(ERROR, resources.getText("doclet.Option_conflict", "-charset", "-docencoding")); reporter.print(ERROR, resources.getText("doclet.Option_conflict", "-charset", "-docencoding"));
return false; return false;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -108,7 +108,8 @@ public class HtmlDoclet extends AbstractDoclet {
protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree) protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree)
throws DocletException { throws DocletException {
super.generateOtherFiles(docEnv, classtree); super.generateOtherFiles(docEnv, classtree);
if (configuration.linksource) { HtmlOptions options = configuration.getOptions();
if (options.linkSource) {
SourceToHTMLConverter.convertRoot(configuration, SourceToHTMLConverter.convertRoot(configuration,
docEnv, DocPaths.SOURCE_OUTPUT); docEnv, DocPaths.SOURCE_OUTPUT);
} }
@ -119,27 +120,27 @@ public class HtmlDoclet extends AbstractDoclet {
messages.error("doclet.No_Non_Deprecated_Classes_To_Document"); messages.error("doclet.No_Non_Deprecated_Classes_To_Document");
return; return;
} }
boolean nodeprecated = configuration.nodeprecated; boolean nodeprecated = options.noDeprecated;
performCopy(configuration.helpfile); performCopy(options.helpFile);
performCopy(configuration.stylesheetfile); performCopy(options.stylesheetFile);
for (String stylesheet : configuration.additionalStylesheets) { for (String stylesheet : options.additionalStylesheets) {
performCopy(stylesheet); performCopy(stylesheet);
} }
// do early to reduce memory footprint // do early to reduce memory footprint
if (configuration.classuse) { if (options.classUse) {
ClassUseWriter.generate(configuration, classtree); ClassUseWriter.generate(configuration, classtree);
} }
IndexBuilder indexbuilder = new IndexBuilder(configuration, nodeprecated); IndexBuilder indexbuilder = new IndexBuilder(configuration, nodeprecated);
if (configuration.createtree) { if (options.createTree) {
TreeWriter.generate(configuration, classtree); TreeWriter.generate(configuration, classtree);
} }
if (!(configuration.nodeprecatedlist || nodeprecated)) { if (!(options.noDeprecatedList || nodeprecated)) {
DeprecatedListWriter.generate(configuration); DeprecatedListWriter.generate(configuration);
} }
if (configuration.createoverview) { if (options.createOverview) {
if (configuration.showModules) { if (configuration.showModules) {
ModuleIndexWriter.generate(configuration); ModuleIndexWriter.generate(configuration);
} else { } else {
@ -147,9 +148,9 @@ public class HtmlDoclet extends AbstractDoclet {
} }
} }
if (configuration.createindex) { if (options.createIndex) {
configuration.buildSearchTagIndex(); configuration.buildSearchTagIndex();
if (configuration.splitindex) { if (options.splitIndex) {
SplitIndexWriter.generate(configuration, indexbuilder); SplitIndexWriter.generate(configuration, indexbuilder);
} else { } else {
SingleIndexWriter.generate(configuration, indexbuilder); SingleIndexWriter.generate(configuration, indexbuilder);
@ -162,25 +163,25 @@ public class HtmlDoclet extends AbstractDoclet {
SystemPropertiesWriter.generate(configuration); SystemPropertiesWriter.generate(configuration);
} }
if (configuration.createoverview) { if (options.createOverview) {
IndexRedirectWriter.generate(configuration, DocPaths.OVERVIEW_SUMMARY, DocPaths.INDEX); IndexRedirectWriter.generate(configuration, DocPaths.OVERVIEW_SUMMARY, DocPaths.INDEX);
} else { } else {
IndexRedirectWriter.generate(configuration); IndexRedirectWriter.generate(configuration);
} }
if (configuration.helpfile.isEmpty() && !configuration.nohelp) { if (options.helpFile.isEmpty() && !options.noHelp) {
HelpWriter.generate(configuration); HelpWriter.generate(configuration);
} }
// If a stylesheet file is not specified, copy the default stylesheet // If a stylesheet file is not specified, copy the default stylesheet
// and replace newline with platform-specific newline. // and replace newline with platform-specific newline.
DocFile f; DocFile f;
if (configuration.stylesheetfile.length() == 0) { if (options.stylesheetFile.length() == 0) {
f = DocFile.createFileForOutput(configuration, DocPaths.STYLESHEET); f = DocFile.createFileForOutput(configuration, DocPaths.STYLESHEET);
f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.STYLESHEET), true, true); f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.STYLESHEET), true, true);
} }
f = DocFile.createFileForOutput(configuration, DocPaths.JAVASCRIPT); f = DocFile.createFileForOutput(configuration, DocPaths.JAVASCRIPT);
f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.JAVASCRIPT), true, true); f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.JAVASCRIPT), true, true);
if (configuration.createindex) { if (options.createIndex) {
f = DocFile.createFileForOutput(configuration, DocPaths.SEARCH_JS); f = DocFile.createFileForOutput(configuration, DocPaths.SEARCH_JS);
f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.SEARCH_JS), true, true); f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.SEARCH_JS), true, true);
@ -272,26 +273,27 @@ public class HtmlDoclet extends AbstractDoclet {
*/ */
@Override // defined by AbstractDoclet @Override // defined by AbstractDoclet
protected void generatePackageFiles(ClassTree classtree) throws DocletException { protected void generatePackageFiles(ClassTree classtree) throws DocletException {
HtmlOptions options = configuration.getOptions();
Set<PackageElement> packages = configuration.packages; Set<PackageElement> packages = configuration.packages;
List<PackageElement> pList = new ArrayList<>(packages); List<PackageElement> pList = new ArrayList<>(packages);
for (PackageElement pkg : pList) { for (PackageElement pkg : pList) {
// if -nodeprecated option is set and the package is marked as // if -nodeprecated option is set and the package is marked as
// deprecated, do not generate the package-summary.html, package-frame.html // deprecated, do not generate the package-summary.html, package-frame.html
// and package-tree.html pages for that package. // and package-tree.html pages for that package.
if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) { if (!(options.noDeprecated && utils.isDeprecated(pkg))) {
AbstractBuilder packageSummaryBuilder = AbstractBuilder packageSummaryBuilder =
configuration.getBuilderFactory().getPackageSummaryBuilder(pkg); configuration.getBuilderFactory().getPackageSummaryBuilder(pkg);
packageSummaryBuilder.build(); packageSummaryBuilder.build();
if (configuration.createtree) { if (options.createTree) {
PackageTreeWriter.generate(configuration, pkg, configuration.nodeprecated); PackageTreeWriter.generate(configuration, pkg, options.noDeprecated);
} }
} }
} }
} }
@Override // defined by Doclet @Override // defined by Doclet
public Set<Option> getSupportedOptions() { public Set<? extends Option> getSupportedOptions() {
return configuration.getSupportedOptions(); return configuration.getOptions().getSupportedOptions();
} }
private void performCopy(String filename) throws DocFileIOException { private void performCopy(String filename) throws DocFileIOException {

View File

@ -153,6 +153,8 @@ public class HtmlDocletWriter {
*/ */
public final HtmlConfiguration configuration; public final HtmlConfiguration configuration;
protected final HtmlOptions options;
protected final Utils utils; protected final Utils utils;
protected final Contents contents; protected final Contents contents;
@ -208,6 +210,7 @@ public class HtmlDocletWriter {
*/ */
public HtmlDocletWriter(HtmlConfiguration configuration, DocPath path) { public HtmlDocletWriter(HtmlConfiguration configuration, DocPath path) {
this.configuration = configuration; this.configuration = configuration;
this.options = configuration.getOptions();
this.contents = configuration.contents; this.contents = configuration.contents;
this.messages = configuration.messages; this.messages = configuration.messages;
this.resources = configuration.resources; this.resources = configuration.resources;
@ -259,9 +262,9 @@ public class HtmlDocletWriter {
// append htmlstr up to start of next {@docroot} // append htmlstr up to start of next {@docroot}
buf.append(htmlstr.substring(prevEnd, match)); buf.append(htmlstr.substring(prevEnd, match));
prevEnd = docrootMatcher.end(); prevEnd = docrootMatcher.end();
if (configuration.docrootparent.length() > 0 && htmlstr.startsWith("/..", prevEnd)) { if (options.docrootParent.length() > 0 && htmlstr.startsWith("/..", prevEnd)) {
// Insert the absolute link if {@docRoot} is followed by "/..". // Insert the absolute link if {@docRoot} is followed by "/..".
buf.append(configuration.docrootparent); buf.append(options.docrootParent);
prevEnd += 3; prevEnd += 3;
} else { } else {
// Insert relative path where {@docRoot} was located // Insert relative path where {@docRoot} was located
@ -276,7 +279,7 @@ public class HtmlDocletWriter {
return buf.toString(); return buf.toString();
} }
//where: //where:
// Note: {@docRoot} is not case sensitive when passed in w/command line option: // Note: {@docRoot} is not case sensitive when passed in with a command-line option:
private static final Pattern docrootPattern = private static final Pattern docrootPattern =
Pattern.compile(Pattern.quote("{@docroot}"), Pattern.CASE_INSENSITIVE); Pattern.compile(Pattern.quote("{@docroot}"), Pattern.CASE_INSENSITIVE);
@ -339,7 +342,7 @@ public class HtmlDocletWriter {
* @param htmltree the documentation tree to which the tags will be added * @param htmltree the documentation tree to which the tags will be added
*/ */
protected void addTagsInfo(Element e, Content htmltree) { protected void addTagsInfo(Element e, Content htmltree) {
if (configuration.nocomment) { if (options.noComment) {
return; return;
} }
Content dl = new HtmlTree(HtmlTag.DL); Content dl = new HtmlTree(HtmlTag.DL);
@ -448,14 +451,14 @@ public class HtmlDocletWriter {
List<DocPath> additionalStylesheets = configuration.getAdditionalStylesheets(); List<DocPath> additionalStylesheets = configuration.getAdditionalStylesheets();
additionalStylesheets.addAll(localStylesheets); additionalStylesheets.addAll(localStylesheets);
Head head = new Head(path, configuration.docletVersion, configuration.startTime) Head head = new Head(path, configuration.docletVersion, configuration.startTime)
.setTimestamp(!configuration.notimestamp) .setTimestamp(!options.noTimestamp)
.setDescription(description) .setDescription(description)
.setGenerator(getGenerator(getClass())) .setGenerator(getGenerator(getClass()))
.setTitle(winTitle) .setTitle(winTitle)
.setCharset(configuration.charset) .setCharset(options.charset)
.addKeywords(metakeywords) .addKeywords(metakeywords)
.setStylesheets(configuration.getMainStylesheet(), additionalStylesheets) .setStylesheets(configuration.getMainStylesheet(), additionalStylesheets)
.setIndex(configuration.createindex, mainBodyScript) .setIndex(options.createIndex, mainBodyScript)
.addContent(extraHeadContent); .addContent(extraHeadContent);
Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), head.toContent(), body); Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), head.toContent(), body);
@ -470,8 +473,8 @@ public class HtmlDocletWriter {
* @return the window title string * @return the window title string
*/ */
public String getWindowTitle(String title) { public String getWindowTitle(String title) {
if (configuration.windowtitle.length() > 0) { if (options.windowTitle.length() > 0) {
title += " (" + configuration.windowtitle + ")"; title += " (" + options.windowTitle + ")";
} }
return title; return title;
} }
@ -485,12 +488,12 @@ public class HtmlDocletWriter {
public Content getUserHeaderFooter(boolean header) { public Content getUserHeaderFooter(boolean header) {
String content; String content;
if (header) { if (header) {
content = replaceDocRootDir(configuration.header); content = replaceDocRootDir(options.header);
} else { } else {
if (configuration.footer.length() != 0) { if (options.footer.length() != 0) {
content = replaceDocRootDir(configuration.footer); content = replaceDocRootDir(options.footer);
} else { } else {
content = replaceDocRootDir(configuration.header); content = replaceDocRootDir(options.header);
} }
} }
Content rawContent = new RawHtml(content); Content rawContent = new RawHtml(content);
@ -503,7 +506,7 @@ public class HtmlDocletWriter {
* @param htmlTree the content tree to which user specified top will be added * @param htmlTree the content tree to which user specified top will be added
*/ */
public void addTop(Content htmlTree) { public void addTop(Content htmlTree) {
Content top = new RawHtml(replaceDocRootDir(configuration.top)); Content top = new RawHtml(replaceDocRootDir(options.top));
htmlTree.add(top); htmlTree.add(top);
} }
@ -513,7 +516,7 @@ public class HtmlDocletWriter {
* @param htmlTree the content tree to which user specified bottom will be added * @param htmlTree the content tree to which user specified bottom will be added
*/ */
public void addBottom(Content htmlTree) { public void addBottom(Content htmlTree) {
Content bottom = new RawHtml(replaceDocRootDir(configuration.bottom)); Content bottom = new RawHtml(replaceDocRootDir(options.bottom));
Content small = HtmlTree.SMALL(bottom); Content small = HtmlTree.SMALL(bottom);
Content p = HtmlTree.P(HtmlStyle.legalCopy, small); Content p = HtmlTree.P(HtmlStyle.legalCopy, small);
htmlTree.add(p); htmlTree.add(p);
@ -1259,7 +1262,7 @@ public class HtmlDocletWriter {
*/ */
private void addCommentTags(Element element, DocTree holderTag, List<? extends DocTree> tags, boolean depr, private void addCommentTags(Element element, DocTree holderTag, List<? extends DocTree> tags, boolean depr,
boolean first, boolean inSummary, Content htmltree) { boolean first, boolean inSummary, Content htmltree) {
if(configuration.nocomment){ if (options.noComment){
return; return;
} }
Content div; Content div;
@ -1420,8 +1423,8 @@ public class HtmlDocletWriter {
for (DocTree dt : node.getValue()) { for (DocTree dt : node.getValue()) {
if (utils.isText(dt) && isHRef) { if (utils.isText(dt) && isHRef) {
String text = ((TextTree) dt).getBody(); String text = ((TextTree) dt).getBody();
if (text.startsWith("/..") && !configuration.docrootparent.isEmpty()) { if (text.startsWith("/..") && !options.docrootParent.isEmpty()) {
result.add(configuration.docrootparent); result.add(options.docrootParent);
docRootContent = new ContentBuilder(); docRootContent = new ContentBuilder();
result.add(textCleanup(text.substring(3), isLastNode)); result.add(textCleanup(text.substring(3), isLastNode));
} else { } else {

View File

@ -0,0 +1,519 @@
/*
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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.doclets.formats.html;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import com.sun.tools.doclint.DocLint;
import jdk.javadoc.doclet.Doclet;
import jdk.javadoc.doclet.Reporter;
import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.Resources;
import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import static javax.tools.Diagnostic.Kind.ERROR;
import static javax.tools.Diagnostic.Kind.WARNING;
/**
* Storage for all options supported by the
* {@link jdk.javadoc.doclet.StandardDoclet standard doclet},
* including the format-independent options handled
* by {@link BaseOptions}.
*
*/
public class HtmlOptions extends BaseOptions {
//<editor-fold desc="Option values">
/**
* Argument for command-line option {@code --add-stylesheet}.
*/
public List<String> additionalStylesheets = new ArrayList<>();
/**
* Argument for command-line option {@code -bottom}.
*/
public String bottom = "";
/**
* Argument for command-line option {@code -charset}.
* The META charset tag used for cross-platform viewing.
*/
public String charset = null;
/**
* Argument for command-line option {@code -use}.
* True if command-line option "-use" is used. Default value is false.
*/
public boolean classUse = false;
/**
* Argument for command-line option {@code -noindex}.
* False if command-line option "-noindex" is used. Default value is true.
*/
public boolean createIndex = true;
/**
* Argument for command-line option {@code -overview}.
* This is true if option "-overview" is used or option "-overview" is not
* used and number of packages is more than one.
*/
public boolean createOverview = false;
/**
* Argument for command-line option {@code -notree}.
* False if command-line option "-notree" is used. Default value is true.
*/
public boolean createTree = true;
/**
* Arguments for command-line option {@code -Xdoclint} and friends.
* Collected set of doclint options.
*/
public Map<Doclet.Option, String> doclintOpts = new LinkedHashMap<>();
/**
* Argument for command-line option {@code -Xdocrootparent}.
*/
public String docrootParent = "";
/**
* Argument for command-line option {@code -doctitle}.
*/
public String docTitle = "";
/**
* Argument for command-line option {@code -footer}.
*/
public String footer = "";
/**
* Argument for command-line option {@code -header}.
*/
public String header = "";
/**
* Argument for command-line option {@code -helpfile}.
*/
public String helpFile = "";
/**
* Argument for command-line option {@code -nodeprecated}.
* True if command-line option "-nodeprecated" is used. Default value is
* false.
*/
public boolean noDeprecatedList = false;
/**
* Argument for command-line option {@code -nohelp}.
* True if command-line option "-nohelp" is used. Default value is false.
*/
public boolean noHelp = false;
/**
* Argument for command-line option {@code -nonavbar}.
* True if command-line option "-nonavbar" is used. Default value is false.
*/
public boolean noNavbar = false;
/**
* Argument for command-line option {@code -nooverview}.
* True if command-line option "-nooverview" is used. Default value is
* false
*/
boolean noOverview = false;
/**
* Argument for command-line option {@code -overview}.
* The overview path specified with "-overview" flag.
*/
public String overviewPath = null;
/**
* Argument for command-line option {@code -packagesheader}.
*/
public String packagesHeader = "";
/**
* Argument for command-line option {@code -splitindex}.
* True if command-line option "-splitindex" is used. Default value is
* false.
*/
public boolean splitIndex = false;
/**
* Argument for command-line option {@code -stylesheetfile}.
*/
public String stylesheetFile = "";
/**
* Argument for command-line option {@code -top}.
*/
public String top = "";
/**
* Argument for command-line option {@code -windowtitle}.
*/
public String windowTitle = "";
//</editor-fold>
private HtmlConfiguration config;
HtmlOptions(HtmlConfiguration config) {
super(config);
this.config = config;
}
@Override
public Set<? extends Option> getSupportedOptions() {
Resources resources = config.getResources();
Reporter reporter = config.getReporter();
List<Option> options = List.of(
new Option(resources, "--add-stylesheet", 1) {
@Override
public boolean process(String opt, List<String> args) {
additionalStylesheets.add(args.get(0));
return true;
}
},
new Option(resources, "-bottom", 1) {
@Override
public boolean process(String opt, List<String> args) {
bottom = args.get(0);
return true;
}
},
new Option(resources, "-charset", 1) {
@Override
public boolean process(String opt, List<String> args) {
charset = args.get(0);
return true;
}
},
new Option(resources, "-doctitle", 1) {
@Override
public boolean process(String opt, List<String> args) {
docTitle = args.get(0);
return true;
}
},
new Option(resources, "-footer", 1) {
@Override
public boolean process(String opt, List<String> args) {
footer = args.get(0);
return true;
}
},
new Option(resources, "-header", 1) {
@Override
public boolean process(String opt, List<String> args) {
header = args.get(0);
return true;
}
},
new Option(resources, "-helpfile", 1) {
@Override
public boolean process(String opt, List<String> args) {
if (noHelp) {
reporter.print(ERROR, resources.getText("doclet.Option_conflict",
"-helpfile", "-nohelp"));
return false;
}
if (!helpFile.isEmpty()) {
reporter.print(ERROR, resources.getText("doclet.Option_reuse",
"-helpfile"));
return false;
}
helpFile = args.get(0);
return true;
}
},
new Option(resources, "-html5") {
@Override
public boolean process(String opt, List<String> args) {
return true;
}
},
new Option(resources, "-nohelp") {
@Override
public boolean process(String opt, List<String> args) {
noHelp = true;
if (!helpFile.isEmpty()) {
reporter.print(ERROR, resources.getText("doclet.Option_conflict",
"-nohelp", "-helpfile"));
return false;
}
return true;
}
},
new Option(resources, "-nodeprecatedlist") {
@Override
public boolean process(String opt, List<String> args) {
noDeprecatedList = true;
return true;
}
},
new Option(resources, "-noindex") {
@Override
public boolean process(String opt, List<String> args) {
createIndex = false;
if (splitIndex) {
reporter.print(ERROR, resources.getText("doclet.Option_conflict",
"-noindex", "-splitindex"));
return false;
}
return true;
}
},
new Option(resources, "-nonavbar") {
@Override
public boolean process(String opt, List<String> args) {
noNavbar = true;
return true;
}
},
new Hidden(resources, "-nooverview") {
@Override
public boolean process(String opt, List<String> args) {
noOverview = true;
if (overviewPath != null) {
reporter.print(ERROR, resources.getText("doclet.Option_conflict",
"-nooverview", "-overview"));
return false;
}
return true;
}
},
new Option(resources, "-notree") {
@Override
public boolean process(String opt, List<String> args) {
createTree = false;
return true;
}
},
new Option(resources, "-overview", 1) {
@Override
public boolean process(String opt, List<String> args) {
overviewPath = args.get(0);
if (noOverview) {
reporter.print(ERROR, resources.getText("doclet.Option_conflict",
"-overview", "-nooverview"));
return false;
}
return true;
}
},
new Hidden(resources, "-packagesheader", 1) {
@Override
public boolean process(String opt, List<String> args) {
packagesHeader = args.get(0);
return true;
}
},
new Option(resources, "-splitindex") {
@Override
public boolean process(String opt, List<String> args) {
splitIndex = true;
if (!createIndex) {
reporter.print(ERROR, resources.getText("doclet.Option_conflict",
"-splitindex", "-noindex"));
return false;
}
return true;
}
},
new Option(resources, "--main-stylesheet -stylesheetfile", 1) {
@Override
public boolean process(String opt, List<String> args) {
stylesheetFile = args.get(0);
return true;
}
},
new Option(resources, "-top", 1) {
@Override
public boolean process(String opt, List<String> args) {
top = args.get(0);
return true;
}
},
new Option(resources, "-use") {
@Override
public boolean process(String opt, List<String> args) {
classUse = true;
return true;
}
},
new Option(resources, "-windowtitle", 1) {
@Override
public boolean process(String opt, List<String> args) {
windowTitle = args.get(0).replaceAll("<.*?>", "");
return true;
}
},
new XOption(resources, "-Xdoclint") {
@Override
public boolean process(String opt, List<String> args) {
doclintOpts.put(this, DocLint.XMSGS_OPTION);
return true;
}
},
new XOption(resources, "-Xdocrootparent", 1) {
@Override
public boolean process(String opt, List<String> args) {
docrootParent = args.get(0);
try {
new URL(docrootParent);
} catch (MalformedURLException e) {
reporter.print(ERROR, resources.getText("doclet.MalformedURL", docrootParent));
return false;
}
return true;
}
},
new XOption(resources, "doclet.usage.xdoclint-extended", "-Xdoclint:", 0) {
@Override
public boolean process(String opt, List<String> args) {
String dopt = opt.replace("-Xdoclint:", DocLint.XMSGS_CUSTOM_PREFIX);
doclintOpts.put(this, dopt);
if (dopt.contains("/")) {
reporter.print(ERROR, resources.getText("doclet.Option_doclint_no_qualifiers"));
return false;
}
if (!DocLint.isValidOption(dopt)) {
reporter.print(ERROR, resources.getText("doclet.Option_doclint_invalid_arg"));
return false;
}
return true;
}
},
new XOption(resources, "doclet.usage.xdoclint-package", "-Xdoclint/package:", 0) {
@Override
public boolean process(String opt, List<String> args) {
String dopt = opt.replace("-Xdoclint/package:", DocLint.XCHECK_PACKAGE);
doclintOpts.put(this, dopt);
if (!DocLint.isValidOption(dopt)) {
reporter.print(ERROR, resources.getText("doclet.Option_doclint_package_invalid_arg"));
return false;
}
return true;
}
},
new XOption(resources, "--no-frames") {
@Override
public boolean process(String opt, List<String> args) {
reporter.print(WARNING, resources.getText("doclet.NoFrames_specified"));
return true;
}
}
);
Set<BaseOptions.Option> allOptions = new TreeSet<>();
allOptions.addAll(options);
allOptions.addAll(super.getSupportedOptions());
return allOptions;
}
protected boolean validateOptions() {
// check shared options
if (!generalValidOptions()) {
return false;
}
Resources resources = config.getResources();
Reporter reporter = config.getReporter();
// check if helpfile exists
if (!helpFile.isEmpty()) {
DocFile help = DocFile.createFileForInput(config, helpFile);
if (!help.exists()) {
reporter.print(ERROR, resources.getText("doclet.File_not_found", helpFile));
return false;
}
}
// check if stylesheetFile exists
if (!stylesheetFile.isEmpty()) {
DocFile stylesheet = DocFile.createFileForInput(config, stylesheetFile);
if (!stylesheet.exists()) {
reporter.print(ERROR, resources.getText("doclet.File_not_found", stylesheetFile));
return false;
}
}
// check if additional stylesheets exists
for (String ssheet : additionalStylesheets) {
DocFile ssfile = DocFile.createFileForInput(config, ssheet);
if (!ssfile.exists()) {
reporter.print(ERROR, resources.getText("doclet.File_not_found", ssheet));
return false;
}
}
// In a more object-oriented world, this would be done by methods on the Option objects.
// Note that -windowtitle silently removes any and all HTML elements, and so does not need
// to be handled here.
Utils utils = config.utils;
utils.checkJavaScriptInOption("-header", header);
utils.checkJavaScriptInOption("-footer", footer);
utils.checkJavaScriptInOption("-top", top);
utils.checkJavaScriptInOption("-bottom", bottom);
utils.checkJavaScriptInOption("-doctitle", docTitle);
utils.checkJavaScriptInOption("-packagesheader", packagesHeader);
return true;
}
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -207,7 +207,7 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
* @return true if overview details need to be printed * @return true if overview details need to be printed
*/ */
public boolean shouldPrintOverview(VariableElement field) { public boolean shouldPrintOverview(VariableElement field) {
if (!configuration.nocomment) { if (!options.noComment) {
if(!utils.getFullBody(field).isEmpty() || if(!utils.getFullBody(field).isEmpty() ||
writer.hasSerializationOverviewTags(field)) writer.hasSerializationOverviewTags(field))
return true; return true;

View File

@ -75,18 +75,18 @@ public class IndexRedirectWriter extends HtmlDocletWriter {
private void generateIndexFile() throws DocFileIOException { private void generateIndexFile() throws DocFileIOException {
Content htmlComment = contents.newPage; Content htmlComment = contents.newPage;
Head head = new Head(path, configuration.docletVersion, configuration.startTime) Head head = new Head(path, configuration.docletVersion, configuration.startTime)
.setTimestamp(!configuration.notimestamp) .setTimestamp(!options.noTimestamp)
.setDescription("index redirect") .setDescription("index redirect")
.setGenerator(getGenerator(getClass())) .setGenerator(getGenerator(getClass()))
.setStylesheets(configuration.getMainStylesheet(), Collections.emptyList()) // avoid reference to default stylesheet .setStylesheets(configuration.getMainStylesheet(), Collections.emptyList()) // avoid reference to default stylesheet
.addDefaultScript(false); .addDefaultScript(false);
String title = (configuration.windowtitle.length() > 0) String title = (options.windowTitle.length() > 0)
? configuration.windowtitle ? options.windowTitle
: resources.getText("doclet.Generated_Docs_Untitled"); : resources.getText("doclet.Generated_Docs_Untitled");
head.setTitle(title) head.setTitle(title)
.setCharset(configuration.charset) .setCharset(options.charset)
.setCanonicalLink(target); .setCanonicalLink(target);
String targetPath = target.getPath(); String targetPath = target.getPath();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -253,7 +253,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
Content classLink = writer.getPreQualifiedClassLink( Content classLink = writer.getPreQualifiedClassLink(
LinkInfoImpl.Kind.MEMBER, typeElement, false); LinkInfoImpl.Kind.MEMBER, typeElement, false);
Content label; Content label;
if (configuration.summarizeOverriddenMethods) { if (options.summarizeOverriddenMethods) {
label = new StringContent(utils.isClass(typeElement) label = new StringContent(utils.isClass(typeElement)
? resources.getText("doclet.Methods_Declared_In_Class") ? resources.getText("doclet.Methods_Declared_In_Class")
: resources.getText("doclet.Methods_Declared_In_Interface")); : resources.getText("doclet.Methods_Declared_In_Interface"));
@ -285,7 +285,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
*/ */
protected static void addOverridden(HtmlDocletWriter writer, protected static void addOverridden(HtmlDocletWriter writer,
TypeMirror overriddenType, ExecutableElement method, Content dl) { TypeMirror overriddenType, ExecutableElement method, Content dl) {
if (writer.configuration.nocomment) { if (writer.options.noComment) {
return; return;
} }
Utils utils = writer.utils; Utils utils = writer.utils;
@ -336,7 +336,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
protected static void addImplementsInfo(HtmlDocletWriter writer, protected static void addImplementsInfo(HtmlDocletWriter writer,
ExecutableElement method, Content dl) { ExecutableElement method, Content dl) {
Utils utils = writer.utils; Utils utils = writer.utils;
if (utils.isStatic(method) || writer.configuration.nocomment) { if (utils.isStatic(method) || writer.options.noComment) {
return; return;
} }
Contents contents = writer.contents; Contents contents = writer.contents;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,11 +31,9 @@ import jdk.javadoc.internal.doclets.formats.html.markup.TableHeader;
import java.util.*; import java.util.*;
import javax.lang.model.element.ModuleElement; import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.PackageElement;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.Content;
@ -110,7 +108,7 @@ public class ModuleIndexWriter extends AbstractOverviewIndexWriter {
for (ModuleElement mdle : modules) { for (ModuleElement mdle : modules) {
if (!mdle.isUnnamed()) { if (!mdle.isUnnamed()) {
if (!(configuration.nodeprecated && utils.isDeprecated(mdle))) { if (!(options.noDeprecated && utils.isDeprecated(mdle))) {
Content moduleLinkContent = getModuleLink(mdle, new StringContent(mdle.getQualifiedName().toString())); Content moduleLinkContent = getModuleLink(mdle, new StringContent(mdle.getQualifiedName().toString()));
Content summaryContent = new ContentBuilder(); Content summaryContent = new ContentBuilder();
addSummaryComment(mdle, summaryContent); addSummaryComment(mdle, summaryContent);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -188,7 +188,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
HtmlTree bodyTree = getBody(getWindowTitle(mdle.getQualifiedName().toString())); HtmlTree bodyTree = getBody(getWindowTitle(mdle.getQualifiedName().toString()));
Content headerContent = new ContentBuilder(); Content headerContent = new ContentBuilder();
addTop(headerContent); addTop(headerContent);
navBar.setDisplaySummaryModuleDescLink(!utils.getFullBody(mdle).isEmpty() && !configuration.nocomment); navBar.setDisplaySummaryModuleDescLink(!utils.getFullBody(mdle).isEmpty() && !options.noComment);
navBar.setDisplaySummaryModulesLink(display(requires) || display(indirectModules)); navBar.setDisplaySummaryModulesLink(display(requires) || display(indirectModules));
navBar.setDisplaySummaryPackagesLink(display(packages) || display(indirectPackages) navBar.setDisplaySummaryPackagesLink(display(packages) || display(indirectPackages)
|| display(indirectOpenPackages)); || display(indirectOpenPackages));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -122,7 +122,7 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
Content classLink = writer.getPreQualifiedClassLink( Content classLink = writer.getPreQualifiedClassLink(
LinkInfoImpl.Kind.MEMBER, typeElement, false); LinkInfoImpl.Kind.MEMBER, typeElement, false);
Content label; Content label;
if (configuration.summarizeOverriddenMethods) { if (options.summarizeOverriddenMethods) {
label = new StringContent(utils.isInterface(typeElement) label = new StringContent(utils.isInterface(typeElement)
? resources.getText("doclet.Nested_Classes_Interfaces_Declared_In_Interface") ? resources.getText("doclet.Nested_Classes_Interfaces_Declared_In_Interface")
: resources.getText("doclet.Nested_Classes_Interfaces_Declared_In_Class")); : resources.getText("doclet.Nested_Classes_Interfaces_Declared_In_Class"));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -33,7 +33,6 @@ import javax.lang.model.element.PackageElement;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
@ -110,7 +109,7 @@ public class PackageIndexWriter extends AbstractOverviewIndexWriter {
for (PackageElement pkg : configuration.packages) { for (PackageElement pkg : configuration.packages) {
if (!pkg.isUnnamed()) { if (!pkg.isUnnamed()) {
if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) { if (!(options.noDeprecated && utils.isDeprecated(pkg))) {
Content packageLinkContent = getPackageLink(pkg, getPackageName(pkg)); Content packageLinkContent = getPackageLink(pkg, getPackageName(pkg));
Content summaryContent = new ContentBuilder(); Content summaryContent = new ContentBuilder();
addSummaryComment(pkg, summaryContent); addSummaryComment(pkg, summaryContent);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -213,7 +213,7 @@ public class PropertyWriterImpl extends AbstractMemberWriter
Content classLink = writer.getPreQualifiedClassLink( Content classLink = writer.getPreQualifiedClassLink(
LinkInfoImpl.Kind.MEMBER, typeElement, false); LinkInfoImpl.Kind.MEMBER, typeElement, false);
Content label; Content label;
if (configuration.summarizeOverriddenMethods) { if (options.summarizeOverriddenMethods) {
label = new StringContent(utils.isClass(typeElement) label = new StringContent(utils.isClass(typeElement)
? resources.getText("doclet.Properties_Declared_In_Class") ? resources.getText("doclet.Properties_Declared_In_Class")
: resources.getText("doclet.Properties_Declared_In_Interface")); : resources.getText("doclet.Properties_Declared_In_Interface"));

View File

@ -77,6 +77,7 @@ public class SourceToHTMLConverter {
private static final String NEW_LINE = DocletConstants.NL; private static final String NEW_LINE = DocletConstants.NL;
private final HtmlConfiguration configuration; private final HtmlConfiguration configuration;
private final HtmlOptions options;
private final Messages messages; private final Messages messages;
private final Resources resources; private final Resources resources;
private final Utils utils; private final Utils utils;
@ -94,6 +95,7 @@ public class SourceToHTMLConverter {
private SourceToHTMLConverter(HtmlConfiguration configuration, DocletEnvironment rd, private SourceToHTMLConverter(HtmlConfiguration configuration, DocletEnvironment rd,
DocPath outputdir) { DocPath outputdir) {
this.configuration = configuration; this.configuration = configuration;
this.options = configuration.getOptions();
this.messages = configuration.getMessages(); this.messages = configuration.getMessages();
this.resources = configuration.resources; this.resources = configuration.resources;
this.utils = configuration.utils; this.utils = configuration.utils;
@ -122,20 +124,20 @@ public class SourceToHTMLConverter {
for (ModuleElement mdl : configuration.getSpecifiedModuleElements()) { for (ModuleElement mdl : configuration.getSpecifiedModuleElements()) {
// If -nodeprecated option is set and the module is marked as deprecated, // If -nodeprecated option is set and the module is marked as deprecated,
// do not convert the module files to HTML. // do not convert the module files to HTML.
if (!(configuration.nodeprecated && utils.isDeprecated(mdl))) if (!(options.noDeprecated && utils.isDeprecated(mdl)))
convertModule(mdl, outputdir); convertModule(mdl, outputdir);
} }
for (PackageElement pkg : configuration.getSpecifiedPackageElements()) { for (PackageElement pkg : configuration.getSpecifiedPackageElements()) {
// If -nodeprecated option is set and the package is marked as deprecated, // If -nodeprecated option is set and the package is marked as deprecated,
// do not convert the package files to HTML. // do not convert the package files to HTML.
if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) if (!(options.noDeprecated && utils.isDeprecated(pkg)))
convertPackage(pkg, outputdir); convertPackage(pkg, outputdir);
} }
for (TypeElement te : configuration.getSpecifiedTypeElements()) { for (TypeElement te : configuration.getSpecifiedTypeElements()) {
// If -nodeprecated option is set and the class is marked as deprecated // If -nodeprecated option is set and the class is marked as deprecated
// or the containing package is deprecated, do not convert the // or the containing package is deprecated, do not convert the
// package files to HTML. // package files to HTML.
if (!(configuration.nodeprecated && if (!(options.noDeprecated &&
(utils.isDeprecated(te) || utils.isDeprecated(utils.containingPackage(te))))) (utils.isDeprecated(te) || utils.isDeprecated(utils.containingPackage(te)))))
convertClass(te, outputdir); convertClass(te, outputdir);
} }
@ -159,7 +161,7 @@ public class SourceToHTMLConverter {
// do not convert the package files to HTML. We do not check for // do not convert the package files to HTML. We do not check for
// containing package deprecation since it is already check in // containing package deprecation since it is already check in
// the calling method above. // the calling method above.
if (!(configuration.nodeprecated && utils.isDeprecated(te))) if (!(options.noDeprecated && utils.isDeprecated(te)))
convertClass((TypeElement)te, outputdir); convertClass((TypeElement)te, outputdir);
} }
} }
@ -179,7 +181,7 @@ public class SourceToHTMLConverter {
} }
for (Element elem : mdl.getEnclosedElements()) { for (Element elem : mdl.getEnclosedElements()) {
if (elem instanceof PackageElement && configuration.docEnv.isIncluded(elem) if (elem instanceof PackageElement && configuration.docEnv.isIncluded(elem)
&& !(configuration.nodeprecated && utils.isDeprecated(elem))) { && !(options.noDeprecated && utils.isDeprecated(elem))) {
convertPackage((PackageElement) elem, outputdir); convertPackage((PackageElement) elem, outputdir);
} }
} }
@ -236,9 +238,9 @@ public class SourceToHTMLConverter {
*/ */
private void writeToFile(Content body, DocPath path, TypeElement te) throws DocFileIOException { private void writeToFile(Content body, DocPath path, TypeElement te) throws DocFileIOException {
Head head = new Head(path, configuration.docletVersion, configuration.startTime) Head head = new Head(path, configuration.docletVersion, configuration.startTime)
// .setTimestamp(!configuration.notimestamp) // temporary: compatibility! // .setTimestamp(!options.notimestamp) // temporary: compatibility!
.setTitle(resources.getText("doclet.Window_Source_title")) .setTitle(resources.getText("doclet.Window_Source_title"))
// .setCharset(configuration.charset) // temporary: compatibility! // .setCharset(options.charset) // temporary: compatibility!
.setDescription(HtmlDocletWriter.getDescription("source", te)) .setDescription(HtmlDocletWriter.getDescription("source", te))
.setGenerator(HtmlDocletWriter.getGenerator(getClass())) .setGenerator(HtmlDocletWriter.getGenerator(getClass()))
.addDefaultScript(false) .addDefaultScript(false)
@ -256,7 +258,7 @@ public class SourceToHTMLConverter {
* @param head an HtmlTree to which the stylesheet links will be added * @param head an HtmlTree to which the stylesheet links will be added
*/ */
public void addStyleSheetProperties(Content head) { public void addStyleSheetProperties(Content head) {
String filename = configuration.stylesheetfile; String filename = options.stylesheetFile;
DocPath stylesheet; DocPath stylesheet;
if (filename.length() > 0) { if (filename.length() > 0) {
DocFile file = DocFile.createFileForInput(configuration, filename); DocFile file = DocFile.createFileForInput(configuration, filename);
@ -271,7 +273,7 @@ public class SourceToHTMLConverter {
} }
protected void addStylesheets(Content tree) { protected void addStylesheets(Content tree) {
List<String> stylesheets = configuration.additionalStylesheets; List<String> stylesheets = options.additionalStylesheets;
if (!stylesheets.isEmpty()) { if (!stylesheets.isEmpty()) {
stylesheets.forEach((ssheet) -> { stylesheets.forEach((ssheet) -> {
DocFile file = DocFile.createFileForInput(configuration, ssheet); DocFile file = DocFile.createFileForInput(configuration, ssheet);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -72,6 +72,7 @@ public class TagletWriterImpl extends TagletWriter {
private final HtmlDocletWriter htmlWriter; private final HtmlDocletWriter htmlWriter;
private final HtmlConfiguration configuration; private final HtmlConfiguration configuration;
private final HtmlOptions options;
private final Utils utils; private final Utils utils;
private final boolean inSummary; private final boolean inSummary;
private final Resources resources; private final Resources resources;
@ -83,9 +84,10 @@ public class TagletWriterImpl extends TagletWriter {
public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence, boolean inSummary) { public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence, boolean inSummary) {
super(isFirstSentence); super(isFirstSentence);
this.htmlWriter = htmlWriter; this.htmlWriter = htmlWriter;
configuration = htmlWriter.configuration;
this.utils = configuration.utils;
this.inSummary = inSummary; this.inSummary = inSummary;
configuration = htmlWriter.configuration;
options = configuration.getOptions();
utils = configuration.utils;
resources = configuration.getResources(); resources = configuration.getResources();
} }
@ -438,7 +440,7 @@ public class TagletWriterImpl extends TagletWriter {
anchorName += "-" + count; anchorName += "-" + count;
} }
result = HtmlTree.SPAN(anchorName, HtmlStyle.searchTagResult, new StringContent(tagText)); result = HtmlTree.SPAN(anchorName, HtmlStyle.searchTagResult, new StringContent(tagText));
if (configuration.createindex && !tagText.isEmpty()) { if (options.createIndex && !tagText.isEmpty()) {
SearchIndexItem si = new SearchIndexItem(); SearchIndexItem si = new SearchIndexItem();
si.setSystemProperty(isSystemProperty); si.setSystemProperty(isSystemProperty);
si.setLabel(tagText); si.setLabel(tagText);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -155,7 +155,7 @@ public class TreeWriter extends AbstractTreeWriter {
// is set and the package is marked as deprecated, do not include // is set and the package is marked as deprecated, do not include
// the page in the list of package hierarchies. // the page in the list of package hierarchies.
if (pkg.isUnnamed() || if (pkg.isUnnamed() ||
(configuration.nodeprecated && utils.isDeprecated(pkg))) { (options.noDeprecated && utils.isDeprecated(pkg))) {
i++; i++;
continue; continue;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,7 +25,6 @@
package jdk.javadoc.internal.doclets.formats.html.markup; package jdk.javadoc.internal.doclets.formats.html.markup;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Deque;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
@ -39,6 +38,7 @@ import javax.lang.model.element.TypeElement;
import jdk.javadoc.internal.doclets.formats.html.AbstractMemberWriter; import jdk.javadoc.internal.doclets.formats.html.AbstractMemberWriter;
import jdk.javadoc.internal.doclets.formats.html.Contents; import jdk.javadoc.internal.doclets.formats.html.Contents;
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
import jdk.javadoc.internal.doclets.formats.html.HtmlOptions;
import jdk.javadoc.internal.doclets.formats.html.MarkerComments; import jdk.javadoc.internal.doclets.formats.html.MarkerComments;
import jdk.javadoc.internal.doclets.formats.html.SectionName; import jdk.javadoc.internal.doclets.formats.html.SectionName;
import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.Content;
@ -62,6 +62,7 @@ import static jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable.Kind.
public class Navigation { public class Navigation {
private final HtmlConfiguration configuration; private final HtmlConfiguration configuration;
private final HtmlOptions options;
private final Element element; private final Element element;
private final Contents contents; private final Contents contents;
private final DocPath path; private final DocPath path;
@ -133,6 +134,7 @@ public class Navigation {
*/ */
public Navigation(Element element, HtmlConfiguration configuration, PageMode page, DocPath path) { public Navigation(Element element, HtmlConfiguration configuration, PageMode page, DocPath path) {
this.configuration = configuration; this.configuration = configuration;
this.options = configuration.getOptions();
this.element = element; this.element = element;
this.contents = configuration.contents; this.contents = configuration.contents;
this.documentedPage = page; this.documentedPage = page;
@ -201,11 +203,11 @@ public class Navigation {
private void addMainNavLinks(Content tree) { private void addMainNavLinks(Content tree) {
switch (documentedPage) { switch (documentedPage) {
case OVERVIEW: case OVERVIEW:
addActivePageLink(tree, contents.overviewLabel, configuration.createoverview); addActivePageLink(tree, contents.overviewLabel, options.createOverview);
addModuleLink(tree); addModuleLink(tree);
addPackageLink(tree); addPackageLink(tree);
addPageLabel(tree, contents.classLabel, true); addPageLabel(tree, contents.classLabel, true);
addPageLabel(tree, contents.useLabel, configuration.classuse); addPageLabel(tree, contents.useLabel, options.classUse);
addTreeLink(tree); addTreeLink(tree);
addDeprecatedLink(tree); addDeprecatedLink(tree);
addIndexLink(tree); addIndexLink(tree);
@ -216,7 +218,7 @@ public class Navigation {
addActivePageLink(tree, contents.moduleLabel, configuration.showModules); addActivePageLink(tree, contents.moduleLabel, configuration.showModules);
addPackageLink(tree); addPackageLink(tree);
addPageLabel(tree, contents.classLabel, true); addPageLabel(tree, contents.classLabel, true);
addPageLabel(tree, contents.useLabel, configuration.classuse); addPageLabel(tree, contents.useLabel, options.classUse);
addTreeLink(tree); addTreeLink(tree);
addDeprecatedLink(tree); addDeprecatedLink(tree);
addIndexLink(tree); addIndexLink(tree);
@ -227,11 +229,11 @@ public class Navigation {
addModuleOfElementLink(tree); addModuleOfElementLink(tree);
addActivePageLink(tree, contents.packageLabel, true); addActivePageLink(tree, contents.packageLabel, true);
addPageLabel(tree, contents.classLabel, true); addPageLabel(tree, contents.classLabel, true);
if (configuration.classuse) { if (options.classUse) {
addContentToTree(tree, links.createLink(DocPaths.PACKAGE_USE, addContentToTree(tree, links.createLink(DocPaths.PACKAGE_USE,
contents.useLabel, "", "")); contents.useLabel, "", ""));
} }
if (configuration.createtree) { if (options.createTree) {
addContentToTree(tree, links.createLink(DocPaths.PACKAGE_TREE, addContentToTree(tree, links.createLink(DocPaths.PACKAGE_TREE,
contents.treeLabel, "", "")); contents.treeLabel, "", ""));
} }
@ -244,11 +246,11 @@ public class Navigation {
addModuleOfElementLink(tree); addModuleOfElementLink(tree);
addPackageSummaryLink(tree); addPackageSummaryLink(tree);
addActivePageLink(tree, contents.classLabel, true); addActivePageLink(tree, contents.classLabel, true);
if (configuration.classuse) { if (options.classUse) {
addContentToTree(tree, links.createLink(DocPaths.CLASS_USE.resolve(path.basename()), addContentToTree(tree, links.createLink(DocPaths.CLASS_USE.resolve(path.basename()),
contents.useLabel)); contents.useLabel));
} }
if (configuration.createtree) { if (options.createTree) {
addContentToTree(tree, links.createLink(DocPaths.PACKAGE_TREE, addContentToTree(tree, links.createLink(DocPaths.PACKAGE_TREE,
contents.treeLabel, "", "")); contents.treeLabel, "", ""));
} }
@ -266,7 +268,7 @@ public class Navigation {
addPackageOfElementLink(tree); addPackageOfElementLink(tree);
addContentToTree(tree, navLinkClass); addContentToTree(tree, navLinkClass);
} }
addActivePageLink(tree, contents.useLabel, configuration.classuse); addActivePageLink(tree, contents.useLabel, options.classUse);
if (element instanceof PackageElement) { if (element instanceof PackageElement) {
addContentToTree(tree, links.createLink(DocPaths.PACKAGE_TREE, contents.treeLabel)); addContentToTree(tree, links.createLink(DocPaths.PACKAGE_TREE, contents.treeLabel));
} else { } else {
@ -288,8 +290,8 @@ public class Navigation {
addPackageSummaryLink(tree); addPackageSummaryLink(tree);
} }
addPageLabel(tree, contents.classLabel, true); addPageLabel(tree, contents.classLabel, true);
addPageLabel(tree, contents.useLabel, configuration.classuse); addPageLabel(tree, contents.useLabel, options.classUse);
addActivePageLink(tree, contents.treeLabel, configuration.createtree); addActivePageLink(tree, contents.treeLabel, options.createTree);
addDeprecatedLink(tree); addDeprecatedLink(tree);
addIndexLink(tree); addIndexLink(tree);
addHelpLink(tree); addHelpLink(tree);
@ -301,21 +303,21 @@ public class Navigation {
addModuleLink(tree); addModuleLink(tree);
addPackageLink(tree); addPackageLink(tree);
addPageLabel(tree, contents.classLabel, true); addPageLabel(tree, contents.classLabel, true);
addPageLabel(tree, contents.useLabel, configuration.classuse); addPageLabel(tree, contents.useLabel, options.classUse);
addTreeLink(tree); addTreeLink(tree);
if (documentedPage == PageMode.DEPRECATED) { if (documentedPage == PageMode.DEPRECATED) {
addActivePageLink(tree, contents.deprecatedLabel, !(configuration.nodeprecated addActivePageLink(tree, contents.deprecatedLabel, !(options.noDeprecated
|| configuration.nodeprecatedlist)); || options.noDeprecatedList));
} else { } else {
addDeprecatedLink(tree); addDeprecatedLink(tree);
} }
if (documentedPage == PageMode.INDEX) { if (documentedPage == PageMode.INDEX) {
addActivePageLink(tree, contents.indexLabel, configuration.createindex); addActivePageLink(tree, contents.indexLabel, options.createIndex);
} else { } else {
addIndexLink(tree); addIndexLink(tree);
} }
if (documentedPage == PageMode.HELP) { if (documentedPage == PageMode.HELP) {
addActivePageLink(tree, contents.helpLabel, !configuration.nohelp); addActivePageLink(tree, contents.helpLabel, !options.noHelp);
} else { } else {
addHelpLink(tree); addHelpLink(tree);
} }
@ -329,7 +331,7 @@ public class Navigation {
addModuleLink(tree); addModuleLink(tree);
addPackageLink(tree); addPackageLink(tree);
addPageLabel(tree, contents.classLabel, true); addPageLabel(tree, contents.classLabel, true);
addPageLabel(tree, contents.useLabel, configuration.classuse); addPageLabel(tree, contents.useLabel, options.classUse);
addTreeLink(tree); addTreeLink(tree);
addDeprecatedLink(tree); addDeprecatedLink(tree);
addIndexLink(tree); addIndexLink(tree);
@ -340,7 +342,7 @@ public class Navigation {
addModuleOfElementLink(tree); addModuleOfElementLink(tree);
addContentToTree(tree, navLinkPackage); addContentToTree(tree, navLinkPackage);
addPageLabel(tree, contents.classLabel, true); addPageLabel(tree, contents.classLabel, true);
addPageLabel(tree, contents.useLabel, configuration.classuse); addPageLabel(tree, contents.useLabel, options.classUse);
addTreeLink(tree); addTreeLink(tree);
addDeprecatedLink(tree); addDeprecatedLink(tree);
addIndexLink(tree); addIndexLink(tree);
@ -783,7 +785,7 @@ public class Navigation {
} }
private void addOverviewLink(Content tree) { private void addOverviewLink(Content tree) {
if (configuration.createoverview) { if (options.createOverview) {
tree.add(HtmlTree.LI(links.createLink(pathToRoot.resolve(DocPaths.INDEX), tree.add(HtmlTree.LI(links.createLink(pathToRoot.resolve(DocPaths.INDEX),
contents.overviewLabel, "", ""))); contents.overviewLabel, "", "")));
} }
@ -849,7 +851,7 @@ public class Navigation {
} }
private void addTreeLink(Content tree) { private void addTreeLink(Content tree) {
if (configuration.createtree) { if (options.createTree) {
List<PackageElement> packages = new ArrayList<>(configuration.getSpecifiedPackageElements()); List<PackageElement> packages = new ArrayList<>(configuration.getSpecifiedPackageElements());
DocPath docPath = packages.size() == 1 && configuration.getSpecifiedTypeElements().isEmpty() DocPath docPath = packages.size() == 1 && configuration.getSpecifiedTypeElements().isEmpty()
? pathToRoot.resolve(configuration.docPaths.forPackage(packages.get(0)).resolve(DocPaths.PACKAGE_TREE)) ? pathToRoot.resolve(configuration.docPaths.forPackage(packages.get(0)).resolve(DocPaths.PACKAGE_TREE))
@ -859,16 +861,16 @@ public class Navigation {
} }
private void addDeprecatedLink(Content tree) { private void addDeprecatedLink(Content tree) {
if (!(configuration.nodeprecated || configuration.nodeprecatedlist)) { if (!(options.noDeprecated || options.noDeprecatedList)) {
tree.add(HtmlTree.LI(links.createLink(pathToRoot.resolve(DocPaths.DEPRECATED_LIST), tree.add(HtmlTree.LI(links.createLink(pathToRoot.resolve(DocPaths.DEPRECATED_LIST),
contents.deprecatedLabel, "", ""))); contents.deprecatedLabel, "", "")));
} }
} }
private void addIndexLink(Content tree) { private void addIndexLink(Content tree) {
if (configuration.createindex) { if (options.createIndex) {
tree.add(HtmlTree.LI(links.createLink(pathToRoot.resolve( tree.add(HtmlTree.LI(links.createLink(pathToRoot.resolve(
(configuration.splitindex (options.splitIndex
? DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)) ? DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1))
: DocPaths.INDEX_ALL)), : DocPaths.INDEX_ALL)),
contents.indexLabel, "", ""))); contents.indexLabel, "", "")));
@ -876,8 +878,8 @@ public class Navigation {
} }
private void addHelpLink(Content tree) { private void addHelpLink(Content tree) {
if (!configuration.nohelp) { if (!options.noHelp) {
String helpfile = configuration.helpfile; String helpfile = options.helpFile;
DocPath helpfilenm; DocPath helpfilenm;
if (helpfile.isEmpty()) { if (helpfile.isEmpty()) {
helpfilenm = DocPaths.HELP_DOC; helpfilenm = DocPaths.HELP_DOC;
@ -908,7 +910,7 @@ public class Navigation {
* @return the navigation contents * @return the navigation contents
*/ */
public Content getContent(boolean top) { public Content getContent(boolean top) {
if (configuration.nonavbar) { if (options.noNavbar) {
return new ContentBuilder(); return new ContentBuilder();
} }
Content tree = HtmlTree.NAV(); Content tree = HtmlTree.NAV();
@ -953,7 +955,7 @@ public class Navigation {
addDetailLinks(ulNavDetail); addDetailLinks(ulNavDetail);
div.add(ulNavDetail); div.add(ulNavDetail);
subDiv.add(div); subDiv.add(div);
if (top && configuration.createindex) { if (top && options.createIndex) {
addSearch(subDiv); addSearch(subDiv);
} }
tree.add(subDiv); tree.add(subDiv);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -102,6 +102,7 @@ public abstract class AbstractDoclet implements Doclet {
configuration.initConfiguration(docEnv); configuration.initConfiguration(docEnv);
utils = configuration.utils; utils = configuration.utils;
messages = configuration.getMessages(); messages = configuration.getMessages();
BaseOptions options = configuration.getOptions();
if (!isValidDoclet()) { if (!isValidDoclet()) {
return false; return false;
@ -125,16 +126,16 @@ public abstract class AbstractDoclet implements Doclet {
messages.error("doclet.exception.write.file", messages.error("doclet.exception.write.file",
e.fileName.getPath(), e.getCause()); e.fileName.getPath(), e.getCause());
} }
dumpStack(configuration.dumpOnError, e); dumpStack(options.dumpOnError, e);
} catch (ResourceIOException e) { } catch (ResourceIOException e) {
messages.error("doclet.exception.read.resource", messages.error("doclet.exception.read.resource",
e.resource.getPath(), e.getCause()); e.resource.getPath(), e.getCause());
dumpStack(configuration.dumpOnError, e); dumpStack(options.dumpOnError, e);
} catch (SimpleDocletException e) { } catch (SimpleDocletException e) {
configuration.reporter.print(ERROR, e.getMessage()); configuration.reporter.print(ERROR, e.getMessage());
dumpStack(configuration.dumpOnError, e); dumpStack(options.dumpOnError, e);
} catch (InternalException e) { } catch (InternalException e) {
configuration.reporter.print(ERROR, e.getMessage()); configuration.reporter.print(ERROR, e.getMessage());
@ -200,7 +201,7 @@ public abstract class AbstractDoclet implements Doclet {
} }
messages.notice("doclet.build_version", messages.notice("doclet.build_version",
configuration.getDocletVersion()); configuration.getDocletVersion());
ClassTree classtree = new ClassTree(configuration, configuration.nodeprecated); ClassTree classtree = new ClassTree(configuration, configuration.getOptions().noDeprecated);
generateClassFiles(docEnv, classtree); generateClassFiles(docEnv, classtree);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,7 +26,6 @@
package jdk.javadoc.internal.doclets.toolkit; package jdk.javadoc.internal.doclets.toolkit;
import java.io.*; import java.io.*;
import java.lang.ref.*;
import java.util.*; import java.util.*;
import javax.lang.model.element.Element; import javax.lang.model.element.Element;
@ -51,7 +50,6 @@ import jdk.javadoc.internal.doclets.toolkit.taglets.TagletManager;
import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileFactory; import jdk.javadoc.internal.doclets.toolkit.util.DocFileFactory;
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
import jdk.javadoc.internal.doclets.toolkit.util.Extern; import jdk.javadoc.internal.doclets.toolkit.util.Extern;
import jdk.javadoc.internal.doclets.toolkit.util.Group; import jdk.javadoc.internal.doclets.toolkit.util.Group;
import jdk.javadoc.internal.doclets.toolkit.util.MetaKeywords; import jdk.javadoc.internal.doclets.toolkit.util.MetaKeywords;
@ -100,66 +98,15 @@ public abstract class BaseConfiguration {
*/ */
public static final String DEFAULT_BUILDER_XML = "resources/doclet.xml"; public static final String DEFAULT_BUILDER_XML = "resources/doclet.xml";
/**
* The path to Taglets
*/
public String tagletpath = null;
/**
* This is true if option "-serialwarn" is used. Default value is false to
* suppress excessive warnings about serial tag.
*/
public boolean serialwarn = false;
/**
* The specified amount of space between tab stops.
*/
public int sourcetab;
public String tabSpaces;
/**
* True if we should generate browsable sources.
*/
public boolean linksource = false;
/**
* True if command line option "-nosince" is used. Default value is
* false.
*/
public boolean nosince = false;
/**
* True if we should recursively copy the doc-file subdirectories
*/
public boolean copydocfilesubdirs = false;
/** /**
* Maintain backward compatibility with previous javadoc version * Maintain backward compatibility with previous javadoc version
*/ */
public boolean backwardCompatibility = true; public boolean backwardCompatibility = true;
/**
* True if user wants to add member names as meta keywords.
* Set to false because meta keywords are ignored in general
* by most Internet search engines.
*/
public boolean keywords = false;
/** /**
* The meta tag keywords instance. * The meta tag keywords instance.
*/ */
public final MetaKeywords metakeywords; public MetaKeywords metakeywords;
/**
* The set of doc-file subdirectories to exclude
*/
protected Set<String> excludedDocFileDirs;
/**
* The set of qualifiers to exclude
*/
protected Set<String> excludedQualifiers;
/** /**
* The doclet environment. * The doclet environment.
@ -176,61 +123,6 @@ public abstract class BaseConfiguration {
*/ */
public WorkArounds workArounds; public WorkArounds workArounds;
/**
* Destination directory name, in which doclet will generate the entire
* documentation. Default is current directory.
*/
public String destDirName = "";
/**
* Destination directory name, in which doclet will copy the doc-files to.
*/
public String docFileDestDirName = "";
/**
* Encoding for this document. Default is default encoding for this
* platform.
*/
public String docencoding = null;
/**
* True if user wants to suppress descriptions and tags.
*/
public boolean nocomment = false;
/**
* Encoding for this document. Default is default encoding for this
* platform.
*/
public String encoding = null;
/**
* Generate author specific information for all the classes if @author
* tag is used in the doc comment and if -author option is used.
* <code>showauthor</code> is set to true if -author option is used.
* Default is don't show author information.
*/
public boolean showauthor = false;
/**
* Generate documentation for JavaFX getters and setters automatically
* by copying it from the appropriate property definition.
*/
public boolean javafx = false;
/**
* Generate version specific information for the all the classes
* if @version tag is used in the doc comment and if -version option is
* used. <code>showversion</code> is set to true if -version option is
* used.Default is don't show version information.
*/
public boolean showversion = false;
/**
* Allow JavaScript in doc comments.
*/
private boolean allowScriptInComments = false;
/** /**
* Sourcepath from where to read the source files. Default is classpath. * Sourcepath from where to read the source files. Default is classpath.
*/ */
@ -241,25 +133,11 @@ public abstract class BaseConfiguration {
*/ */
public boolean showModules = false; public boolean showModules = false;
/**
* Don't generate deprecated API information at all, if -nodeprecated
* option is used. <code>nodeprecated</code> is set to true if
* -nodeprecated option is used. Default is generate deprecated API
* information.
*/
public boolean nodeprecated = false;
/** /**
* The catalog of classes specified on the command-line * The catalog of classes specified on the command-line
*/ */
public TypeElementCatalog typeElementCatalog; public TypeElementCatalog typeElementCatalog;
/**
* True if user wants to suppress time stamp in output.
* Default is false.
*/
public boolean notimestamp = false;
/** /**
* The package grouping instance. * The package grouping instance.
*/ */
@ -274,28 +152,6 @@ public abstract class BaseConfiguration {
public Locale locale; public Locale locale;
/**
* Suppress all messages
*/
public boolean quiet = false;
/**
* Specifies whether those methods that override a super-type's method
* with no changes to the API contract should be summarized in the
* footnote section.
*/
public boolean summarizeOverriddenMethods = false;
// A list containing urls
private final List<String> linkList = new ArrayList<>();
// A list of pairs containing urls and package list
private final List<Pair<String, String>> linkOfflineList = new ArrayList<>();
public boolean dumpOnError = false;
private List<Pair<String, String>> groupPairs;
public abstract Messages getMessages(); public abstract Messages getMessages();
public abstract Resources getResources(); public abstract Resources getResources();
@ -341,18 +197,6 @@ public abstract class BaseConfiguration {
protected static final String sharedResourceBundleName = protected static final String sharedResourceBundleName =
"jdk.javadoc.internal.doclets.toolkit.resources.doclets"; "jdk.javadoc.internal.doclets.toolkit.resources.doclets";
/**
* Primarily used to disable strict checks in the regression
* tests allowing those tests to be executed successfully, for
* instance, with OpenJDK builds which may not contain FX libraries.
*/
public boolean disableJavaFxStrictChecks = false;
/**
* Show taglets (internal debug switch)
*/
public boolean showTaglets = false;
VisibleMemberCache visibleMemberCache = null; VisibleMemberCache visibleMemberCache = null;
public PropertyUtils propertyUtils = null; public PropertyUtils propertyUtils = null;
@ -372,13 +216,10 @@ public abstract class BaseConfiguration {
*/ */
public BaseConfiguration(Doclet doclet) { public BaseConfiguration(Doclet doclet) {
this.doclet = doclet; this.doclet = doclet;
excludedDocFileDirs = new HashSet<>();
excludedQualifiers = new HashSet<>();
setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
metakeywords = new MetaKeywords(this);
groupPairs = new ArrayList<>(0);
} }
public abstract BaseOptions getOptions();
private boolean initialized = false; private boolean initialized = false;
protected void initConfiguration(DocletEnvironment docEnv) { protected void initConfiguration(DocletEnvironment docEnv) {
@ -390,11 +231,13 @@ public abstract class BaseConfiguration {
// Utils needs docEnv, safe to init now. // Utils needs docEnv, safe to init now.
utils = new Utils(this); utils = new Utils(this);
if (!javafx) { BaseOptions options = getOptions();
javafx = isJavaFXMode(); if (!options.javafx) {
options.javafx = isJavaFXMode();
} }
// Once docEnv and Utils have been initialized, others should be safe. // Once docEnv and Utils have been initialized, others should be safe.
metakeywords = new MetaKeywords(this);
cmtUtils = new CommentUtils(this); cmtUtils = new CommentUtils(this);
workArounds = new WorkArounds(this); workArounds = new WorkArounds(this);
visibleMemberCache = new VisibleMemberCache(this); visibleMemberCache = new VisibleMemberCache(this);
@ -505,265 +348,23 @@ public abstract class BaseConfiguration {
packages.addAll(includedPackageElements); packages.addAll(includedPackageElements);
} }
public Set<Doclet.Option> getSupportedOptions() {
Resources resources = getResources();
Doclet.Option[] options = {
new Option(resources, "-author") {
@Override
public boolean process(String opt, List<String> args) {
showauthor = true;
return true;
}
},
new Option(resources, "-d", 1) {
@Override
public boolean process(String opt, List<String> args) {
destDirName = addTrailingFileSep(args.get(0));
return true;
}
},
new Option(resources, "-docencoding", 1) {
@Override
public boolean process(String opt, List<String> args) {
docencoding = args.get(0);
return true;
}
},
new Option(resources, "-docfilessubdirs") {
@Override
public boolean process(String opt, List<String> args) {
copydocfilesubdirs = true;
return true;
}
},
new Hidden(resources, "-encoding", 1) {
@Override
public boolean process(String opt, List<String> args) {
encoding = args.get(0);
return true;
}
},
new Option(resources, "-excludedocfilessubdir", 1) {
@Override
public boolean process(String opt, List<String> args) {
addToSet(excludedDocFileDirs, args.get(0));
return true;
}
},
new Option(resources, "-group", 2) {
@Override
public boolean process(String opt, List<String> args) {
groupPairs.add(new Pair<>(args.get(0), args.get(1)));
return true;
}
},
new Option(resources, "--javafx -javafx") {
@Override
public boolean process(String opt, List<String> args) {
javafx = true;
return true;
}
},
new Option(resources, "-keywords") {
@Override
public boolean process(String opt, List<String> args) {
keywords = true;
return true;
}
},
new Option(resources, "-link", 1) {
@Override
public boolean process(String opt, List<String> args) {
linkList.add(args.get(0));
return true;
}
},
new Option(resources, "-linksource") {
@Override
public boolean process(String opt, List<String> args) {
linksource = true;
return true;
}
},
new Option(resources, "-linkoffline", 2) {
@Override
public boolean process(String opt, List<String> args) {
linkOfflineList.add(new Pair<>(args.get(0), args.get(1)));
return true;
}
},
new Option(resources, "-nocomment") {
@Override
public boolean process(String opt, List<String> args) {
nocomment = true;
return true;
}
},
new Option(resources, "-nodeprecated") {
@Override
public boolean process(String opt, List<String> args) {
nodeprecated = true;
return true;
}
},
new Option(resources, "-nosince") {
@Override
public boolean process(String opt, List<String> args) {
nosince = true;
return true;
}
},
new Option(resources, "-notimestamp") {
@Override
public boolean process(String opt, List<String> args) {
notimestamp = true;
return true;
}
},
new Option(resources, "-noqualifier", 1) {
@Override
public boolean process(String opt, List<String> args) {
addToSet(excludedQualifiers, args.get(0));
return true;
}
},
new Option(resources, "--override-methods", 1) {
@Override
public boolean process(String opt, List<String> args) {
String o = args.get(0);
switch (o) {
case "summary":
summarizeOverriddenMethods = true;
break;
case "detail":
summarizeOverriddenMethods = false;
break;
default:
reporter.print(ERROR,
getResources().getText("doclet.Option_invalid",o, "--override-methods"));
return false;
}
return true;
}
},
new Hidden(resources, "-quiet") {
@Override
public boolean process(String opt, List<String> args) {
quiet = true;
return true;
}
},
new Option(resources, "-serialwarn") {
@Override
public boolean process(String opt, List<String> args) {
serialwarn = true;
return true;
}
},
new Option(resources, "-sourcetab", 1) {
@Override
public boolean process(String opt, List<String> args) {
linksource = true;
try {
setTabWidth(Integer.parseInt(args.get(0)));
} catch (NumberFormatException e) {
//Set to -1 so that warning will be printed
//to indicate what is valid argument.
sourcetab = -1;
}
if (sourcetab <= 0) {
getMessages().warning("doclet.sourcetab_warning");
setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
}
return true;
}
},
new Option(resources, "-tag", 1) {
@Override
public boolean process(String opt, List<String> args) {
ArrayList<String> list = new ArrayList<>();
list.add(opt);
list.add(args.get(0));
customTagStrs.add(list);
return true;
}
},
new Option(resources, "-taglet", 1) {
@Override
public boolean process(String opt, List<String> args) {
ArrayList<String> list = new ArrayList<>();
list.add(opt);
list.add(args.get(0));
customTagStrs.add(list);
return true;
}
},
new Option(resources, "-tagletpath", 1) {
@Override
public boolean process(String opt, List<String> args) {
tagletpath = args.get(0);
return true;
}
},
new Option(resources, "-version") {
@Override
public boolean process(String opt, List<String> args) {
showversion = true;
return true;
}
},
new Hidden(resources, "--dump-on-error") {
@Override
public boolean process(String opt, List<String> args) {
dumpOnError = true;
return true;
}
},
new Option(resources, "--allow-script-in-comments") {
@Override
public boolean process(String opt, List<String> args) {
allowScriptInComments = true;
return true;
}
},
new Hidden(resources, "--disable-javafx-strict-checks") {
@Override
public boolean process(String opt, List<String> args) {
disableJavaFxStrictChecks = true;
return true;
}
},
new Hidden(resources, "--show-taglets") {
@Override
public boolean process(String opt, List<String> args) {
showTaglets = true;
return true;
}
}
};
Set<Doclet.Option> set = new TreeSet<>();
set.addAll(Arrays.asList(options));
return set;
}
final LinkedHashSet<List<String>> customTagStrs = new LinkedHashSet<>();
/* /*
* when this is called all the option have been set, this method, * when this is called all the option have been set, this method,
* initializes certain components before anything else is started. * initializes certain components before anything else is started.
*/ */
protected boolean finishOptionSettings0() throws DocletException { protected boolean finishOptionSettings0() throws DocletException {
BaseOptions options = getOptions();
extern = new Extern(this); extern = new Extern(this);
initDestDirectory(); initDestDirectory();
for (String link : linkList) { for (String link : options.linkList) {
extern.link(link, reporter); extern.link(link, reporter);
} }
for (Pair<String, String> linkOfflinePair : linkOfflineList) { for (Pair<String, String> linkOfflinePair : options.linkOfflineList) {
extern.link(linkOfflinePair.first, linkOfflinePair.second, reporter); extern.link(linkOfflinePair.first, linkOfflinePair.second, reporter);
} }
typeElementCatalog = new TypeElementCatalog(includedTypeElements, this); typeElementCatalog = new TypeElementCatalog(includedTypeElements, this);
initTagletManager(customTagStrs); initTagletManager(options.customTagStrs);
groupPairs.stream().forEach((grp) -> { options.groupPairs.stream().forEach((grp) -> {
if (showModules) { if (showModules) {
group.checkModuleGroups(grp.first, grp.second); group.checkModuleGroups(grp.first, grp.second);
} else { } else {
@ -775,7 +376,7 @@ public abstract class BaseConfiguration {
} }
/** /**
* Set the command line options supported by this configuration. * Set the command-line options supported by this configuration.
* *
* @return true if the options are set successfully * @return true if the options are set successfully
* @throws DocletException if there is a problem while setting the options * @throws DocletException if there is a problem while setting the options
@ -790,6 +391,7 @@ public abstract class BaseConfiguration {
} }
private void initDestDirectory() throws DocletException { private void initDestDirectory() throws DocletException {
String destDirName = getOptions().destDirName;
if (!destDirName.isEmpty()) { if (!destDirName.isEmpty()) {
Resources resources = getResources(); Resources resources = getResources();
DocFile destDir = DocFile.createFileForDirectory(this, destDirName); DocFile destDir = DocFile.createFileForDirectory(this, destDirName);
@ -818,13 +420,11 @@ public abstract class BaseConfiguration {
* either -tag or -taglet arguments. * either -tag or -taglet arguments.
*/ */
private void initTagletManager(Set<List<String>> customTagStrs) { private void initTagletManager(Set<List<String>> customTagStrs) {
tagletManager = tagletManager == null ? tagletManager = tagletManager != null ? tagletManager : new TagletManager(this);
new TagletManager(nosince, showversion, showauthor, javafx, this) :
tagletManager;
JavaFileManager fileManager = getFileManager(); JavaFileManager fileManager = getFileManager();
Messages messages = getMessages(); Messages messages = getMessages();
try { try {
tagletManager.initTagletPath(fileManager, tagletpath); tagletManager.initTagletPath(fileManager);
tagletManager.loadTaglets(fileManager); tagletManager.loadTaglets(fileManager);
for (List<String> args : customTagStrs) { for (List<String> args : customTagStrs) {
@ -905,81 +505,6 @@ public abstract class BaseConfiguration {
return tokens; return tokens;
} }
private void addToSet(Set<String> s, String str) {
StringTokenizer st = new StringTokenizer(str, ":");
String current;
while (st.hasMoreTokens()) {
current = st.nextToken();
s.add(current);
}
}
/**
* Add a trailing file separator, if not found. Remove superfluous
* file separators if any. Preserve the front double file separator for
* UNC paths.
*
* @param path Path under consideration.
* @return String Properly constructed path string.
*/
public static String addTrailingFileSep(String path) {
String fs = System.getProperty("file.separator");
String dblfs = fs + fs;
int indexDblfs;
while ((indexDblfs = path.indexOf(dblfs, 1)) >= 0) {
path = path.substring(0, indexDblfs) +
path.substring(indexDblfs + fs.length());
}
if (!path.endsWith(fs))
path += fs;
return path;
}
/**
* This checks for the validity of the options used by the user.
* As of this writing, this checks only docencoding.
*
* @return true if all the options are valid.
*/
public boolean generalValidOptions() {
if (docencoding != null) {
if (!checkOutputFileEncoding(docencoding)) {
return false;
}
}
if (docencoding == null && (encoding != null && !encoding.isEmpty())) {
if (!checkOutputFileEncoding(encoding)) {
return false;
}
}
return true;
}
/**
* Check the validity of the given Source or Output File encoding on this
* platform.
*
* @param docencoding output file encoding.
*/
private boolean checkOutputFileEncoding(String docencoding) {
OutputStream ost = new ByteArrayOutputStream();
OutputStreamWriter osw = null;
try {
osw = new OutputStreamWriter(ost, docencoding);
} catch (UnsupportedEncodingException exc) {
reporter.print(ERROR, getResources().getText("doclet.Encoding_not_supported", docencoding));
return false;
} finally {
try {
if (osw != null) {
osw.close();
}
} catch (IOException exc) {
}
}
return true;
}
/** /**
* Return true if the given doc-file subdirectory should be excluded and * Return true if the given doc-file subdirectory should be excluded and
* false otherwise. * false otherwise.
@ -988,6 +513,7 @@ public abstract class BaseConfiguration {
* @return true if the directory is excluded. * @return true if the directory is excluded.
*/ */
public boolean shouldExcludeDocFileDir(String docfilesubdir) { public boolean shouldExcludeDocFileDir(String docfilesubdir) {
Set<String> excludedDocFileDirs = getOptions().excludedDocFileDirs;
return excludedDocFileDirs.contains(docfilesubdir); return excludedDocFileDirs.contains(docfilesubdir);
} }
@ -998,6 +524,7 @@ public abstract class BaseConfiguration {
* @return true if the qualifier should be excluded * @return true if the qualifier should be excluded
*/ */
public boolean shouldExcludeQualifier(String qualifier) { public boolean shouldExcludeQualifier(String qualifier) {
Set<String> excludedQualifiers = getOptions().excludedQualifiers;
if (excludedQualifiers.contains("all") || if (excludedQualifiers.contains("all") ||
excludedQualifiers.contains(qualifier) || excludedQualifiers.contains(qualifier) ||
excludedQualifiers.contains(qualifier + ".*")) { excludedQualifiers.contains(qualifier + ".*")) {
@ -1037,6 +564,7 @@ public abstract class BaseConfiguration {
* @return true if it is a generated doc. * @return true if it is a generated doc.
*/ */
public boolean isGeneratedDoc(TypeElement te) { public boolean isGeneratedDoc(TypeElement te) {
boolean nodeprecated = getOptions().noDeprecated;
if (!nodeprecated) { if (!nodeprecated) {
return true; return true;
} }
@ -1083,138 +611,10 @@ public abstract class BaseConfiguration {
*/ */
public abstract JavaFileManager getFileManager(); public abstract JavaFileManager getFileManager();
private void setTabWidth(int n) {
sourcetab = n;
tabSpaces = String.format("%" + n + "s", "");
}
public abstract boolean showMessage(DocTreePath path, String key); public abstract boolean showMessage(DocTreePath path, String key);
public abstract boolean showMessage(Element e, String key); public abstract boolean showMessage(Element e, String key);
public abstract static class Option implements Doclet.Option, Comparable<Option> {
private final String[] names;
private final String parameters;
private final String description;
private final int argCount;
protected Option(Resources resources, String name, int argCount) {
this(resources, null, name, argCount);
}
protected Option(Resources resources, String keyBase, String name, int argCount) {
this.names = name.trim().split("\\s+");
if (keyBase == null) {
keyBase = "doclet.usage." + names[0].toLowerCase().replaceAll("^-+", "");
}
String desc = getOptionsMessage(resources, keyBase + ".description");
if (desc.isEmpty()) {
this.description = "<MISSING KEY>";
this.parameters = "<MISSING KEY>";
} else {
this.description = desc;
this.parameters = getOptionsMessage(resources, keyBase + ".parameters");
}
this.argCount = argCount;
}
protected Option(Resources resources, String name) {
this(resources, name, 0);
}
private String getOptionsMessage(Resources resources, String key) {
try {
return resources.getText(key);
} catch (MissingResourceException ignore) {
return "";
}
}
@Override
public String getDescription() {
return description;
}
@Override
public Option.Kind getKind() {
return Doclet.Option.Kind.STANDARD;
}
@Override
public List<String> getNames() {
return Arrays.asList(names);
}
@Override
public String getParameters() {
return parameters;
}
@Override
public String toString() {
return Arrays.toString(names);
}
@Override
public int getArgumentCount() {
return argCount;
}
public boolean matches(String option) {
for (String name : names) {
boolean matchCase = name.startsWith("--");
if (option.startsWith("--") && option.contains("=")) {
return name.equals(option.substring(option.indexOf("=") + 1));
} else if (matchCase) {
return name.equals(option);
}
return name.toLowerCase().equals(option.toLowerCase());
}
return false;
}
@Override
public int compareTo(Option that) {
return this.getNames().get(0).compareTo(that.getNames().get(0));
}
}
public abstract class XOption extends Option {
public XOption(Resources resources, String prefix, String name, int argCount) {
super(resources, prefix, name, argCount);
}
public XOption(Resources resources, String name, int argCount) {
super(resources, name, argCount);
}
public XOption(Resources resources, String name) {
this(resources, name, 0);
}
@Override
public Option.Kind getKind() {
return Doclet.Option.Kind.EXTENDED;
}
}
public abstract class Hidden extends Option {
public Hidden(Resources resources, String name, int argCount) {
super(resources, name, argCount);
}
public Hidden(Resources resources, String name) {
this(resources, name, 0);
}
@Override
public Option.Kind getKind() {
return Doclet.Option.Kind.OTHER;
}
}
/* /*
* Splits the elements in a collection to its individual * Splits the elements in a collection to its individual
* collection. * collection.
@ -1268,12 +668,12 @@ public abstract class BaseConfiguration {
/** /**
* Returns whether or not to allow JavaScript in comments. * Returns whether or not to allow JavaScript in comments.
* Default is off; can be set true from a command line option. * Default is off; can be set true from a command-line option.
* *
* @return the allowScriptInComments * @return the allowScriptInComments
*/ */
public boolean isAllowScriptInComments() { public boolean isAllowScriptInComments() {
return allowScriptInComments; return getOptions().allowScriptInComments;
} }
public synchronized VisibleMemberTable getVisibleMemberTable(TypeElement te) { public synchronized VisibleMemberTable getVisibleMemberTable(TypeElement te) {

View File

@ -0,0 +1,734 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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.doclets.toolkit;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.MissingResourceException;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
import jdk.javadoc.doclet.Doclet;
import jdk.javadoc.doclet.Reporter;
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import static javax.tools.Diagnostic.Kind.ERROR;
/**
* Storage for the format-independent options supported by the toolkit.
* The objects to handle command-line options, and to initialize this
* object, are all subtypes of {@link BaseOptions.Option},
* returned by {@link BaseOptions#getSupportedOptions()}.
*/
public abstract class BaseOptions {
//<editor-fold desc="Option values">
/**
* Argument for command-line option {@code --allow-script-in-comments}.
* Allow JavaScript in doc comments.
*/
public boolean allowScriptInComments = false;
/**
* Argument for command-line option {@code -docfilessubdirs}.
* True if we should recursively copy the doc-file subdirectories
*/
public boolean copyDocfileSubdirs = false;
/**
* Arguments for command-line option {@code -tag} and {@code -taglet}.
*/
final LinkedHashSet<List<String>> customTagStrs = new LinkedHashSet<>();
/**
* Argument for command-line option {@code -d}.
* Destination directory name, in which doclet will generate the entire
* documentation. Default is current directory.
*/
public String destDirName = "";
/**
* Argument for command-line option {@code --disable-javafx-strict-checks}.
* Primarily used to disable strict checks in the regression
* tests allowing those tests to be executed successfully, for
* instance, with OpenJDK builds which may not contain FX libraries.
*/
public boolean disableJavaFxStrictChecks = false;
/**
* Argument for command-line option {@code -docencoding}.
* Encoding for this document. Default is default encoding for this
* platform.
*/
public String docEncoding = null;
/**
* Argument for command-line option {@code ???}.
* Destination directory name, in which doclet will copy the doc-files to.
*/
public String docFileDestDirName = "";
/**
* Argument for hidden command-line option {@code --dump-on-error}.
*/
public boolean dumpOnError = false;
/**
* Argument for command-line option {@code -encoding}.
* Encoding for this document. Default is default encoding for this
* platform.
*/
public String encoding = null;
/**
* Argument for command-line option {@code -excludedocfilessubdir}.
* The set of doc-file subdirectories to exclude.
*/
protected Set<String> excludedDocFileDirs;
/**
* Argument for command-line option {@code -noqualifier}.
* The set of qualifiers to exclude.
*/
protected Set<String> excludedQualifiers;
/**
* Arguments for command-line option {@code -group}
*/
List<Utils.Pair<String, String>> groupPairs;
/**
* Argument for command-line option {@code --javafx} or {@code -javafx}.
* Generate documentation for JavaFX getters and setters automatically
* by copying it from the appropriate property definition.
*/
public boolean javafx = false;
/**
* Argument for command-line option {@code -keywords}.
* True if user wants to add member names as meta keywords.
* Set to false because meta keywords are ignored in general
* by most Internet search engines.
*/
public boolean keywords = false;
/**
* Arguments for command-line option {@code -link}.
*/
// A list containing urls
final List<String> linkList = new ArrayList<>();
/**
* Arguments for command-line option {@code -linkoffline}.
*/
// A list of pairs containing urls and package list
final List<Utils.Pair<String, String>> linkOfflineList = new ArrayList<>();
/**
* Argument for command-line option {@code -linksource}.
* True if we should generate browsable sources.
*/
public boolean linkSource = false;
/**
* Argument for command-line option {@code -nocomment}.
* True if user wants to suppress descriptions and tags.
*/
public boolean noComment = false;
/**
* Argument for command-line option {@code -nodeprecated}.
* Don't generate deprecated API information at all, if -nodeprecated
* option is used. <code>nodeprecated</code> is set to true if
* -nodeprecated option is used. Default is generate deprecated API
* information.
*/
public boolean noDeprecated = false;
/**
* Argument for command-line option {@code -nosince}.
* True if command-line option "-nosince" is used. Default value is
* false.
*/
public boolean noSince = false;
/**
* Argument for command-line option {@code -notimestamp}.
* True if user wants to suppress time stamp in output.
* Default is false.
*/
public boolean noTimestamp = false;
/**
* Argument for command-line option {@code -quiet}.
* Suppress all messages
*/
public boolean quiet = false;
/**
* Argument for command-line option {@code -serialwarn}.
* This is true if option "-serialwarn" is used. Default value is false to
* suppress excessive warnings about serial tag.
*/
public boolean serialWarn = false;
/**
* Argument for command-line option {@code -author}.
* Generate author specific information for all the classes if @author
* tag is used in the doc comment and if -author option is used.
* <code>showauthor</code> is set to true if -author option is used.
* Default is don't show author information.
*/
public boolean showAuthor = false;
/**
* Argument for command-line option {@code --show-taglets}.
* Show taglets (internal debug switch)
*/
public boolean showTaglets = false;
/**
* Argument for command-line option {@code -version}.
* Generate version specific information for the all the classes
* if @version tag is used in the doc comment and if -version option is
* used. {@code showVersion} is set to true if -version option is
* used. Default is don't show version information.
*/
public boolean showVersion = false;
/**
* Argument for command-line option {@code -sourcetab}.
* The specified amount of space between tab stops.
*/
public int sourceTabSize;
/**
* Value for command-line option {@code --override-methods summary}
* or {@code --override-methods detail}.
* Specifies whether those methods that override a super-type's method
* with no changes to the API contract should be summarized in the
* footnote section.
*/
public boolean summarizeOverriddenMethods = false;
/**
* Argument for command-line option {@code -tagletpath}.
* The path to Taglets
*/
public String tagletPath = null;
//</editor-fold>
private final BaseConfiguration config;
protected BaseOptions(BaseConfiguration config) {
this.config = config;
excludedDocFileDirs = new HashSet<>();
excludedQualifiers = new HashSet<>();
sourceTabSize = DocletConstants.DEFAULT_TAB_STOP_LENGTH;
groupPairs = new ArrayList<>(0);
}
public Set<? extends Option> getSupportedOptions() {
Resources resources = config.getResources();
Messages messages = config.getMessages();
Reporter reporter = config.getReporter();
List<Option> options = List.of(
new Option(resources, "-author") {
@Override
public boolean process(String opt, List<String> args) {
showAuthor = true;
return true;
}
},
new Option(resources, "-d", 1) {
@Override
public boolean process(String opt, List<String> args) {
destDirName = addTrailingFileSep(args.get(0));
return true;
}
},
new Option(resources, "-docencoding", 1) {
@Override
public boolean process(String opt, List<String> args) {
docEncoding = args.get(0);
return true;
}
},
new Option(resources, "-docfilessubdirs") {
@Override
public boolean process(String opt, List<String> args) {
copyDocfileSubdirs = true;
return true;
}
},
new Hidden(resources, "-encoding", 1) {
@Override
public boolean process(String opt, List<String> args) {
encoding = args.get(0);
return true;
}
},
new Option(resources, "-excludedocfilessubdir", 1) {
@Override
public boolean process(String opt, List<String> args) {
addToSet(excludedDocFileDirs, args.get(0));
return true;
}
},
new Option(resources, "-group", 2) {
@Override
public boolean process(String opt, List<String> args) {
groupPairs.add(new Utils.Pair<>(args.get(0), args.get(1)));
return true;
}
},
new Option(resources, "--javafx -javafx") {
@Override
public boolean process(String opt, List<String> args) {
javafx = true;
return true;
}
},
new Option(resources, "-keywords") {
@Override
public boolean process(String opt, List<String> args) {
keywords = true;
return true;
}
},
new Option(resources, "-link", 1) {
@Override
public boolean process(String opt, List<String> args) {
linkList.add(args.get(0));
return true;
}
},
new Option(resources, "-linksource") {
@Override
public boolean process(String opt, List<String> args) {
linkSource = true;
return true;
}
},
new Option(resources, "-linkoffline", 2) {
@Override
public boolean process(String opt, List<String> args) {
linkOfflineList.add(new Utils.Pair<>(args.get(0), args.get(1)));
return true;
}
},
new Option(resources, "-nocomment") {
@Override
public boolean process(String opt, List<String> args) {
noComment = true;
return true;
}
},
new Option(resources, "-nodeprecated") {
@Override
public boolean process(String opt, List<String> args) {
noDeprecated = true;
return true;
}
},
new Option(resources, "-nosince") {
@Override
public boolean process(String opt, List<String> args) {
noSince = true;
return true;
}
},
new Option(resources, "-notimestamp") {
@Override
public boolean process(String opt, List<String> args) {
noTimestamp = true;
return true;
}
},
new Option(resources, "-noqualifier", 1) {
@Override
public boolean process(String opt, List<String> args) {
addToSet(excludedQualifiers, args.get(0));
return true;
}
},
new Option(resources, "--override-methods", 1) {
@Override
public boolean process(String opt, List<String> args) {
String o = args.get(0);
switch (o) {
case "summary":
summarizeOverriddenMethods = true;
break;
case "detail":
summarizeOverriddenMethods = false;
break;
default:
reporter.print(ERROR,
resources.getText("doclet.Option_invalid",o, "--override-methods"));
return false;
}
return true;
}
},
new Hidden(resources, "-quiet") {
@Override
public boolean process(String opt, List<String> args) {
quiet = true;
return true;
}
},
new Option(resources, "-serialwarn") {
@Override
public boolean process(String opt, List<String> args) {
serialWarn = true;
return true;
}
},
new Option(resources, "-sourcetab", 1) {
@Override
public boolean process(String opt, List<String> args) {
linkSource = true;
try {
sourceTabSize = Integer.parseInt(args.get(0));
} catch (NumberFormatException e) {
//Set to -1 so that warning will be printed
//to indicate what is valid argument.
sourceTabSize = -1;
}
if (sourceTabSize <= 0) {
messages.warning("doclet.sourcetab_warning");
sourceTabSize = DocletConstants.DEFAULT_TAB_STOP_LENGTH;
}
return true;
}
},
new Option(resources, "-tag", 1) {
@Override
public boolean process(String opt, List<String> args) {
ArrayList<String> list = new ArrayList<>();
list.add(opt);
list.add(args.get(0));
customTagStrs.add(list);
return true;
}
},
new Option(resources, "-taglet", 1) {
@Override
public boolean process(String opt, List<String> args) {
ArrayList<String> list = new ArrayList<>();
list.add(opt);
list.add(args.get(0));
customTagStrs.add(list);
return true;
}
},
new Option(resources, "-tagletpath", 1) {
@Override
public boolean process(String opt, List<String> args) {
tagletPath = args.get(0);
return true;
}
},
new Option(resources, "-version") {
@Override
public boolean process(String opt, List<String> args) {
showVersion = true;
return true;
}
},
new Hidden(resources, "--dump-on-error") {
@Override
public boolean process(String opt, List<String> args) {
dumpOnError = true;
return true;
}
},
new Option(resources, "--allow-script-in-comments") {
@Override
public boolean process(String opt, List<String> args) {
allowScriptInComments = true;
return true;
}
},
new Hidden(resources, "--disable-javafx-strict-checks") {
@Override
public boolean process(String opt, List<String> args) {
disableJavaFxStrictChecks = true;
return true;
}
},
new Hidden(resources, "--show-taglets") {
@Override
public boolean process(String opt, List<String> args) {
showTaglets = true;
return true;
}
}
);
return new TreeSet<>(options);
}
/**
* This checks for the validity of the options used by the user.
* As of this writing, this checks only docencoding.
*
* @return true if all the options are valid.
*/
protected boolean generalValidOptions() {
if (docEncoding != null) {
if (!checkOutputFileEncoding(docEncoding)) {
return false;
}
}
if (docEncoding == null && (encoding != null && !encoding.isEmpty())) {
if (!checkOutputFileEncoding(encoding)) {
return false;
}
}
return true;
}
/**
* Check the validity of the given Source or Output File encoding on this
* platform.
*
* @param docencoding output file encoding.
*/
private boolean checkOutputFileEncoding(String docencoding) {
OutputStream ost = new ByteArrayOutputStream();
OutputStreamWriter osw = null;
try {
osw = new OutputStreamWriter(ost, docencoding);
} catch (UnsupportedEncodingException exc) {
config.reporter.print(ERROR,
config.getResources().getText("doclet.Encoding_not_supported", docencoding));
return false;
} finally {
try {
if (osw != null) {
osw.close();
}
} catch (IOException exc) {
}
}
return true;
}
private void addToSet(Set<String> s, String str) {
StringTokenizer st = new StringTokenizer(str, ":");
String current;
while (st.hasMoreTokens()) {
current = st.nextToken();
s.add(current);
}
}
/**
* Add a trailing file separator, if not found. Remove superfluous
* file separators if any. Preserve the front double file separator for
* UNC paths.
*
* @param path Path under consideration.
* @return String Properly constructed path string.
*/
protected static String addTrailingFileSep(String path) {
String fs = System.getProperty("file.separator");
String dblfs = fs + fs;
int indexDblfs;
while ((indexDblfs = path.indexOf(dblfs, 1)) >= 0) {
path = path.substring(0, indexDblfs) +
path.substring(indexDblfs + fs.length());
}
if (!path.endsWith(fs))
path += fs;
return path;
}
protected abstract static class Option implements Doclet.Option, Comparable<Option> {
private final String[] names;
private final String parameters;
private final String description;
private final int argCount;
protected Option(Resources resources, String name, int argCount) {
this(resources, null, name, argCount);
}
protected Option(Resources resources, String keyBase, String name, int argCount) {
this.names = name.trim().split("\\s+");
if (keyBase == null) {
keyBase = "doclet.usage." + names[0].toLowerCase().replaceAll("^-+", "");
}
String desc = getOptionsMessage(resources, keyBase + ".description");
if (desc.isEmpty()) {
this.description = "<MISSING KEY>";
this.parameters = "<MISSING KEY>";
} else {
this.description = desc;
this.parameters = getOptionsMessage(resources, keyBase + ".parameters");
}
this.argCount = argCount;
}
protected Option(Resources resources, String name) {
this(resources, name, 0);
}
private String getOptionsMessage(Resources resources, String key) {
try {
return resources.getText(key);
} catch (MissingResourceException ignore) {
return "";
}
}
@Override
public String getDescription() {
return description;
}
@Override
public Kind getKind() {
return Kind.STANDARD;
}
@Override
public List<String> getNames() {
return Arrays.asList(names);
}
@Override
public String getParameters() {
return parameters;
}
@Override
public String toString() {
return Arrays.toString(names);
}
@Override
public int getArgumentCount() {
return argCount;
}
public boolean matches(String option) {
for (String name : names) {
boolean matchCase = name.startsWith("--");
if (option.startsWith("--") && option.contains("=")) {
return name.equals(option.substring(option.indexOf("=") + 1));
} else if (matchCase) {
return name.equals(option);
}
return name.toLowerCase().equals(option.toLowerCase());
}
return false;
}
@Override
public int compareTo(Option that) {
return this.getNames().get(0).compareTo(that.getNames().get(0));
}
}
protected abstract static class XOption extends Option {
public XOption(Resources resources, String prefix, String name, int argCount) {
super(resources, prefix, name, argCount);
}
public XOption(Resources resources, String name, int argCount) {
super(resources, name, argCount);
}
public XOption(Resources resources, String name) {
this(resources, name, 0);
}
@Override
public Option.Kind getKind() {
return Kind.EXTENDED;
}
}
protected abstract static class Hidden extends Option {
public Hidden(Resources resources, String name, int argCount) {
super(resources, name, argCount);
}
public Hidden(Resources resources, String name) {
this(resources, name, 0);
}
@Override
public Option.Kind getKind() {
return Kind.OTHER;
}
}
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -132,7 +132,7 @@ public class Messages {
* @param args optional arguments to be replaced in the message. * @param args optional arguments to be replaced in the message.
*/ */
public void notice(String key, Object... args) { public void notice(String key, Object... args) {
if (!configuration.quiet) { if (!configuration.getOptions().quiet) {
report(NOTE, resources.getText(key, args)); report(NOTE, resources.getText(key, args));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,6 +31,8 @@ import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Types; import javax.lang.model.util.Types;
import jdk.javadoc.internal.doclets.formats.html.HtmlOptions;
/** /**
* This class provides basic JavaFX property related utility methods. * This class provides basic JavaFX property related utility methods.
* Refer to the JavaFX conventions in the VisibleMemberTable comments. * Refer to the JavaFX conventions in the VisibleMemberTable comments.
@ -46,13 +48,13 @@ public class PropertyUtils {
final Types typeUtils; final Types typeUtils;
PropertyUtils(BaseConfiguration configuration) { PropertyUtils(BaseConfiguration configuration) {
BaseOptions options = configuration.getOptions();
javafx = configuration.javafx; javafx = options.javafx;
typeUtils = configuration.docEnv.getTypeUtils(); typeUtils = configuration.docEnv.getTypeUtils();
// Disable strict check for JDK's without FX. // Disable strict check for JDK's without FX.
TypeMirror jboType = configuration.disableJavaFxStrictChecks TypeMirror jboType = options.disableJavaFxStrictChecks
? null ? null
: configuration.utils.getSymbol("javafx.beans.Observable"); : configuration.utils.getSymbol("javafx.beans.Observable");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,6 +30,7 @@ import java.util.*;
import javax.lang.model.element.PackageElement; import javax.lang.model.element.PackageElement;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.DocletException;
import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.Messages;
import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.Resources;
@ -76,6 +77,7 @@ public abstract class AbstractBuilder {
* The configuration used in this run of the doclet. * The configuration used in this run of the doclet.
*/ */
protected final BaseConfiguration configuration; protected final BaseConfiguration configuration;
protected final BaseOptions options;
protected final BuilderFactory builderFactory; protected final BuilderFactory builderFactory;
protected final Messages messages; protected final Messages messages;
@ -95,6 +97,7 @@ public abstract class AbstractBuilder {
*/ */
public AbstractBuilder(Context c) { public AbstractBuilder(Context c) {
this.configuration = c.configuration; this.configuration = c.configuration;
this.options = configuration.getOptions();
this.builderFactory = configuration.getBuilderFactory(); this.builderFactory = configuration.getBuilderFactory();
this.messages = configuration.getMessages(); this.messages = configuration.getMessages();
this.resources = configuration.getResources(); this.resources = configuration.getResources();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,7 +31,7 @@ import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeFieldWriter; import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeFieldWriter;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.DocletException;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
@ -176,12 +176,12 @@ public class AnnotationTypeFieldBuilder extends AbstractMemberBuilder {
/** /**
* Build the comments for the member. Do nothing if * Build the comments for the member. Do nothing if
* {@link BaseConfiguration#nocomment} is set to true. * {@link BaseOptions#noComment} is set to true.
* *
* @param annotationDocTree the content tree to which the documentation will be added * @param annotationDocTree the content tree to which the documentation will be added
*/ */
protected void buildMemberComments(Content annotationDocTree) { protected void buildMemberComments(Content annotationDocTree) {
if (!configuration.nocomment) { if (!options.noComment) {
writer.addComments(currentMember, annotationDocTree); writer.addComments(currentMember, annotationDocTree);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,7 +31,7 @@ import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeRequiredMemberWriter; import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeRequiredMemberWriter;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.DocletException;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
@ -181,12 +181,12 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder {
/** /**
* Build the comments for the member. Do nothing if * Build the comments for the member. Do nothing if
* {@link BaseConfiguration#nocomment} is set to true. * {@link BaseOptions#noComment} is set to true.
* *
* @param annotationDocTree the content tree to which the documentation will be added * @param annotationDocTree the content tree to which the documentation will be added
*/ */
protected void buildMemberComments(Content annotationDocTree) { protected void buildMemberComments(Content annotationDocTree) {
if (!configuration.nocomment) { if (!options.noComment) {
writer.addComments(currentMember, annotationDocTree); writer.addComments(currentMember, annotationDocTree);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,7 +31,7 @@ import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.ConstructorWriter; import jdk.javadoc.internal.doclets.toolkit.ConstructorWriter;
import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.DocletException;
@ -171,12 +171,12 @@ public class ConstructorBuilder extends AbstractMemberBuilder {
/** /**
* Build the comments for the constructor. Do nothing if * Build the comments for the constructor. Do nothing if
* {@link BaseConfiguration#nocomment} is set to true. * {@link BaseOptions#noComment} is set to true.
* *
* @param constructorDocTree the content tree to which the documentation will be added * @param constructorDocTree the content tree to which the documentation will be added
*/ */
protected void buildConstructorComments(Content constructorDocTree) { protected void buildConstructorComments(Content constructorDocTree) {
if (!configuration.nocomment) { if (!options.noComment) {
writer.addComments(currentConstructor, constructorDocTree); writer.addComments(currentConstructor, constructorDocTree);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,7 +31,7 @@ import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement; import javax.lang.model.element.VariableElement;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.DocletException;
import jdk.javadoc.internal.doclets.toolkit.EnumConstantWriter; import jdk.javadoc.internal.doclets.toolkit.EnumConstantWriter;
@ -161,12 +161,12 @@ public class EnumConstantBuilder extends AbstractMemberBuilder {
/** /**
* Build the comments for the enum constant. Do nothing if * Build the comments for the enum constant. Do nothing if
* {@link BaseConfiguration#nocomment} is set to true. * {@link BaseOptions#noComment} is set to true.
* *
* @param enumConstantsTree the content tree to which the documentation will be added * @param enumConstantsTree the content tree to which the documentation will be added
*/ */
protected void buildEnumConstantComments(Content enumConstantsTree) { protected void buildEnumConstantComments(Content enumConstantsTree) {
if (!configuration.nocomment) { if (!options.noComment) {
writer.addComments(currentElement, enumConstantsTree); writer.addComments(currentElement, enumConstantsTree);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,7 +31,7 @@ import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement; import javax.lang.model.element.VariableElement;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.DocletException;
import jdk.javadoc.internal.doclets.toolkit.FieldWriter; import jdk.javadoc.internal.doclets.toolkit.FieldWriter;
@ -161,12 +161,12 @@ public class FieldBuilder extends AbstractMemberBuilder {
/** /**
* Build the comments for the field. Do nothing if * Build the comments for the field. Do nothing if
* {@link BaseConfiguration#nocomment} is set to true. * {@link BaseOptions#noComment} is set to true.
* *
* @param fieldDocTree the content tree to which the documentation will be added * @param fieldDocTree the content tree to which the documentation will be added
*/ */
protected void buildFieldComments(Content fieldDocTree) { protected void buildFieldComments(Content fieldDocTree) {
if (!configuration.nocomment) { if (!options.noComment) {
writer.addComments(currentElement, fieldDocTree); writer.addComments(currentElement, fieldDocTree);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -32,7 +32,7 @@ import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeMirror;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.DocletException;
import jdk.javadoc.internal.doclets.toolkit.MethodWriter; import jdk.javadoc.internal.doclets.toolkit.MethodWriter;
@ -161,12 +161,12 @@ public class MethodBuilder extends AbstractMemberBuilder {
/** /**
* Build the comments for the method. Do nothing if * Build the comments for the method. Do nothing if
* {@link BaseConfiguration#nocomment} is set to true. * {@link BaseOptions#noComment} is set to true.
* *
* @param methodDocTree the content tree to which the documentation will be added * @param methodDocTree the content tree to which the documentation will be added
*/ */
protected void buildMethodComments(Content methodDocTree) { protected void buildMethodComments(Content methodDocTree) {
if (!configuration.nocomment) { if (!options.noComment) {
ExecutableElement method = currentMethod; ExecutableElement method = currentMethod;
if (utils.getFullBody(currentMethod).isEmpty()) { if (utils.getFullBody(currentMethod).isEmpty()) {
DocFinder.Output docs = DocFinder.search(configuration, DocFinder.Output docs = DocFinder.search(configuration,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -180,7 +180,7 @@ public class ModuleSummaryBuilder extends AbstractBuilder {
* be added * be added
*/ */
protected void buildModuleDescription(Content moduleContentTree) { protected void buildModuleDescription(Content moduleContentTree) {
if (!configuration.nocomment) { if (!options.noComment) {
moduleWriter.addModuleDescription(moduleContentTree); moduleWriter.addModuleDescription(moduleContentTree);
} }
} }
@ -191,7 +191,7 @@ public class ModuleSummaryBuilder extends AbstractBuilder {
* @param moduleContentTree the tree to which the module tags will be added * @param moduleContentTree the tree to which the module tags will be added
*/ */
protected void buildModuleTags(Content moduleContentTree) { protected void buildModuleTags(Content moduleContentTree) {
if (!configuration.nocomment) { if (!options.noComment) {
moduleWriter.addModuleTags(moduleContentTree); moduleWriter.addModuleTags(moduleContentTree);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -166,7 +166,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
SortedSet<TypeElement> ilist = utils.isSpecified(packageElement) SortedSet<TypeElement> ilist = utils.isSpecified(packageElement)
? utils.getTypeElementsAsSortedSet(utils.getInterfaces(packageElement)) ? utils.getTypeElementsAsSortedSet(utils.getInterfaces(packageElement))
: configuration.typeElementCatalog.interfaces(packageElement); : configuration.typeElementCatalog.interfaces(packageElement);
SortedSet<TypeElement> interfaces = utils.filterOutPrivateClasses(ilist, configuration.javafx); SortedSet<TypeElement> interfaces = utils.filterOutPrivateClasses(ilist, options.javafx);
if (!interfaces.isEmpty()) { if (!interfaces.isEmpty()) {
packageWriter.addInterfaceSummary(interfaces, summaryContentTree); packageWriter.addInterfaceSummary(interfaces, summaryContentTree);
} }
@ -182,7 +182,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
SortedSet<TypeElement> clist = utils.isSpecified(packageElement) SortedSet<TypeElement> clist = utils.isSpecified(packageElement)
? utils.getTypeElementsAsSortedSet(utils.getOrdinaryClasses(packageElement)) ? utils.getTypeElementsAsSortedSet(utils.getOrdinaryClasses(packageElement))
: configuration.typeElementCatalog.ordinaryClasses(packageElement); : configuration.typeElementCatalog.ordinaryClasses(packageElement);
SortedSet<TypeElement> classes = utils.filterOutPrivateClasses(clist, configuration.javafx); SortedSet<TypeElement> classes = utils.filterOutPrivateClasses(clist, options.javafx);
if (!classes.isEmpty()) { if (!classes.isEmpty()) {
packageWriter.addClassSummary(classes, summaryContentTree); packageWriter.addClassSummary(classes, summaryContentTree);
} }
@ -198,7 +198,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
SortedSet<TypeElement> elist = utils.isSpecified(packageElement) SortedSet<TypeElement> elist = utils.isSpecified(packageElement)
? utils.getTypeElementsAsSortedSet(utils.getEnums(packageElement)) ? utils.getTypeElementsAsSortedSet(utils.getEnums(packageElement))
: configuration.typeElementCatalog.enums(packageElement); : configuration.typeElementCatalog.enums(packageElement);
SortedSet<TypeElement> enums = utils.filterOutPrivateClasses(elist, configuration.javafx); SortedSet<TypeElement> enums = utils.filterOutPrivateClasses(elist, options.javafx);
if (!enums.isEmpty()) { if (!enums.isEmpty()) {
packageWriter.addEnumSummary(enums, summaryContentTree); packageWriter.addEnumSummary(enums, summaryContentTree);
} }
@ -214,7 +214,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
SortedSet<TypeElement> rlist = utils.isSpecified(packageElement) SortedSet<TypeElement> rlist = utils.isSpecified(packageElement)
? utils.getTypeElementsAsSortedSet(utils.getRecords(packageElement)) ? utils.getTypeElementsAsSortedSet(utils.getRecords(packageElement))
: configuration.typeElementCatalog.records(packageElement); : configuration.typeElementCatalog.records(packageElement);
SortedSet<TypeElement> records = utils.filterOutPrivateClasses(rlist, configuration.javafx); SortedSet<TypeElement> records = utils.filterOutPrivateClasses(rlist, options.javafx);
if (!records.isEmpty()) { if (!records.isEmpty()) {
packageWriter.addRecordSummary(records, summaryContentTree); packageWriter.addRecordSummary(records, summaryContentTree);
} }
@ -232,7 +232,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
? utils.getTypeElementsAsSortedSet(utils.getExceptions(packageElement)) ? utils.getTypeElementsAsSortedSet(utils.getExceptions(packageElement))
: configuration.typeElementCatalog.exceptions(packageElement); : configuration.typeElementCatalog.exceptions(packageElement);
SortedSet<TypeElement> exceptions = utils.filterOutPrivateClasses(iexceptions, SortedSet<TypeElement> exceptions = utils.filterOutPrivateClasses(iexceptions,
configuration.javafx); options.javafx);
if (!exceptions.isEmpty()) { if (!exceptions.isEmpty()) {
packageWriter.addExceptionSummary(exceptions, summaryContentTree); packageWriter.addExceptionSummary(exceptions, summaryContentTree);
} }
@ -249,7 +249,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
utils.isSpecified(packageElement) utils.isSpecified(packageElement)
? utils.getTypeElementsAsSortedSet(utils.getErrors(packageElement)) ? utils.getTypeElementsAsSortedSet(utils.getErrors(packageElement))
: configuration.typeElementCatalog.errors(packageElement); : configuration.typeElementCatalog.errors(packageElement);
SortedSet<TypeElement> errors = utils.filterOutPrivateClasses(ierrors, configuration.javafx); SortedSet<TypeElement> errors = utils.filterOutPrivateClasses(ierrors, options.javafx);
if (!errors.isEmpty()) { if (!errors.isEmpty()) {
packageWriter.addErrorSummary(errors, summaryContentTree); packageWriter.addErrorSummary(errors, summaryContentTree);
} }
@ -267,7 +267,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
? utils.getTypeElementsAsSortedSet(utils.getAnnotationTypes(packageElement)) ? utils.getTypeElementsAsSortedSet(utils.getAnnotationTypes(packageElement))
: configuration.typeElementCatalog.annotationTypes(packageElement); : configuration.typeElementCatalog.annotationTypes(packageElement);
SortedSet<TypeElement> annotationTypes = utils.filterOutPrivateClasses(iannotationTypes, SortedSet<TypeElement> annotationTypes = utils.filterOutPrivateClasses(iannotationTypes,
configuration.javafx); options.javafx);
if (!annotationTypes.isEmpty()) { if (!annotationTypes.isEmpty()) {
packageWriter.addAnnotationTypeSummary(annotationTypes, summaryContentTree); packageWriter.addAnnotationTypeSummary(annotationTypes, summaryContentTree);
} }
@ -280,7 +280,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
* be added * be added
*/ */
protected void buildPackageDescription(Content packageContentTree) { protected void buildPackageDescription(Content packageContentTree) {
if (configuration.nocomment) { if (options.noComment) {
return; return;
} }
packageWriter.addPackageDescription(packageContentTree); packageWriter.addPackageDescription(packageContentTree);
@ -292,7 +292,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
* @param packageContentTree the tree to which the package tags will be added * @param packageContentTree the tree to which the package tags will be added
*/ */
protected void buildPackageTags(Content packageContentTree) { protected void buildPackageTags(Content packageContentTree) {
if (configuration.nocomment) { if (options.noComment) {
return; return;
} }
packageWriter.addPackageTags(packageContentTree); packageWriter.addPackageTags(packageContentTree);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,7 +31,7 @@ import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.DocletException;
import jdk.javadoc.internal.doclets.toolkit.PropertyWriter; import jdk.javadoc.internal.doclets.toolkit.PropertyWriter;
@ -160,12 +160,12 @@ public class PropertyBuilder extends AbstractMemberBuilder {
/** /**
* Build the comments for the property. Do nothing if * Build the comments for the property. Do nothing if
* {@link BaseConfiguration#nocomment} is set to true. * {@link BaseOptions#noComment} is set to true.
* *
* @param propertyDocTree the content tree to which the documentation will be added * @param propertyDocTree the content tree to which the documentation will be added
*/ */
protected void buildPropertyComments(Content propertyDocTree) { protected void buildPropertyComments(Content propertyDocTree) {
if (!configuration.nocomment) { if (!options.noComment) {
writer.addComments(currentProperty, propertyDocTree); writer.addComments(currentProperty, propertyDocTree);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -324,7 +324,7 @@ public class SerializedFormBuilder extends AbstractBuilder {
* @throws DocletException if there is a problem while building the documentation * @throws DocletException if there is a problem while building the documentation
*/ */
protected void buildMethodInfo(Content methodsContentTree) throws DocletException { protected void buildMethodInfo(Content methodsContentTree) throws DocletException {
if (configuration.nocomment) { if (options.noComment) {
return; return;
} }
@ -351,7 +351,7 @@ public class SerializedFormBuilder extends AbstractBuilder {
ExecutableElement method = (ExecutableElement)currentMember; ExecutableElement method = (ExecutableElement)currentMember;
if (method.getSimpleName().toString().compareTo("writeExternal") == 0 if (method.getSimpleName().toString().compareTo("writeExternal") == 0
&& utils.getSerialDataTrees(method).isEmpty()) { && utils.getSerialDataTrees(method).isEmpty()) {
if (configuration.serialwarn) { if (options.serialWarn) {
TypeElement encl = (TypeElement) method.getEnclosingElement(); TypeElement encl = (TypeElement) method.getEnclosingElement();
messages.warning(currentMember, messages.warning(currentMember,
"doclet.MissingSerialDataTag", encl.getQualifiedName().toString(), "doclet.MissingSerialDataTag", encl.getQualifiedName().toString(),
@ -386,7 +386,7 @@ public class SerializedFormBuilder extends AbstractBuilder {
Content serializableFieldsTree = fieldWriter.getSerializableFieldsHeader(); Content serializableFieldsTree = fieldWriter.getSerializableFieldsHeader();
Content fieldsOverviewContentTree = fieldWriter.getFieldsContentHeader(true); Content fieldsOverviewContentTree = fieldWriter.getFieldsContentHeader(true);
fieldWriter.addMemberDeprecatedInfo(ve, fieldsOverviewContentTree); fieldWriter.addMemberDeprecatedInfo(ve, fieldsOverviewContentTree);
if (!configuration.nocomment) { if (!options.noComment) {
fieldWriter.addMemberDescription(ve, fieldsOverviewContentTree); fieldWriter.addMemberDescription(ve, fieldsOverviewContentTree);
fieldWriter.addMemberTags(ve, fieldsOverviewContentTree); fieldWriter.addMemberTags(ve, fieldsOverviewContentTree);
} }
@ -462,7 +462,7 @@ public class SerializedFormBuilder extends AbstractBuilder {
* @param serializableFieldsTree content tree to which the documentation will be added * @param serializableFieldsTree content tree to which the documentation will be added
*/ */
protected void buildSerialFieldTagsInfo(Content serializableFieldsTree) { protected void buildSerialFieldTagsInfo(Content serializableFieldsTree) {
if (configuration.nocomment) { if (options.noComment) {
return; return;
} }
VariableElement field = (VariableElement)currentMember; VariableElement field = (VariableElement)currentMember;
@ -509,14 +509,14 @@ public class SerializedFormBuilder extends AbstractBuilder {
* @param fieldsContentTree content tree to which the documentation will be added * @param fieldsContentTree content tree to which the documentation will be added
*/ */
protected void buildFieldInfo(Content fieldsContentTree) { protected void buildFieldInfo(Content fieldsContentTree) {
if (configuration.nocomment) { if (options.noComment) {
return; return;
} }
VariableElement field = (VariableElement)currentMember; VariableElement field = (VariableElement)currentMember;
TypeElement te = utils.getEnclosingTypeElement(currentMember); TypeElement te = utils.getEnclosingTypeElement(currentMember);
// Process default Serializable field. // Process default Serializable field.
if ((utils.getSerialTrees(field).isEmpty()) /*&& !field.isSynthetic()*/ if ((utils.getSerialTrees(field).isEmpty()) /*&& !field.isSynthetic()*/
&& configuration.serialwarn) { && options.serialWarn) {
messages.warning(field, messages.warning(field,
"doclet.MissingSerialTag", utils.getFullyQualifiedName(te), "doclet.MissingSerialTag", utils.getFullyQualifiedName(te),
utils.getSimpleName(field)); utils.getSimpleName(field));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -58,6 +58,7 @@ import jdk.javadoc.doclet.Doclet;
import jdk.javadoc.doclet.DocletEnvironment; import jdk.javadoc.doclet.DocletEnvironment;
import jdk.javadoc.doclet.Taglet.Location; import jdk.javadoc.doclet.Taglet.Location;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.DocletElement; import jdk.javadoc.internal.doclets.toolkit.DocletElement;
import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.Messages;
import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.Resources;
@ -177,33 +178,31 @@ public class TagletManager {
*/ */
private final boolean showTaglets; private final boolean showTaglets;
private final String tagletPath;
/** /**
* Construct a new {@code TagletManager}. * Construct a new {@code TagletManager}.
* @param nosince true if we do not want to use @since tags.
* @param showversion true if we want to use @version tags.
* @param showauthor true if we want to use @author tags.
* @param javafx indicates whether javafx is active.
* @param configuration the configuration for this taglet manager * @param configuration the configuration for this taglet manager
*/ */
public TagletManager(boolean nosince, boolean showversion, public TagletManager(BaseConfiguration configuration) {
boolean showauthor, boolean javafx,
BaseConfiguration configuration) {
overriddenStandardTags = new HashSet<>(); overriddenStandardTags = new HashSet<>();
potentiallyConflictingTags = new HashSet<>(); potentiallyConflictingTags = new HashSet<>();
standardTags = new HashSet<>(); standardTags = new HashSet<>();
standardTagsLowercase = new HashSet<>(); standardTagsLowercase = new HashSet<>();
unseenCustomTags = new HashSet<>(); unseenCustomTags = new HashSet<>();
allTaglets = new LinkedHashMap<>(); allTaglets = new LinkedHashMap<>();
this.nosince = nosince; BaseOptions options = configuration.getOptions();
this.showversion = showversion; this.nosince = options.noSince;
this.showauthor = showauthor; this.showversion = options.showVersion;
this.javafx = javafx; this.showauthor = options.showAuthor;
this.javafx = options.javafx;
this.docEnv = configuration.docEnv; this.docEnv = configuration.docEnv;
this.doclet = configuration.doclet; this.doclet = configuration.doclet;
this.messages = configuration.getMessages(); this.messages = configuration.getMessages();
this.resources = configuration.getResources(); this.resources = configuration.getResources();
this.showTaglets = configuration.showTaglets; this.showTaglets = options.showTaglets;
this.utils = configuration.utils; this.utils = configuration.utils;
this.tagletPath = options.tagletPath;
initStandardTaglets(); initStandardTaglets();
} }
@ -230,10 +229,9 @@ public class TagletManager {
/** /**
* Initializes the location TAGLET_PATH which is used to locate the custom taglets. * Initializes the location TAGLET_PATH which is used to locate the custom taglets.
* @param fileManager the file manager to load classes and resources. * @param fileManager the file manager to load classes and resources.
* @param tagletPath the path to the custom taglet.
* @throws IOException if an error occurs while setting the location. * @throws IOException if an error occurs while setting the location.
*/ */
public void initTagletPath(JavaFileManager fileManager, String tagletPath) throws IOException { public void initTagletPath(JavaFileManager fileManager) throws IOException {
if (fileManager instanceof StandardJavaFileManager) { if (fileManager instanceof StandardJavaFileManager) {
StandardJavaFileManager sfm = (StandardJavaFileManager)fileManager; StandardJavaFileManager sfm = (StandardJavaFileManager)fileManager;
if (tagletPath != null) { if (tagletPath != null) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -166,7 +166,7 @@ public class ClassTree {
// In the tree page (e.g overview-tree.html) do not include // In the tree page (e.g overview-tree.html) do not include
// information of classes which are deprecated or are a part of a // information of classes which are deprecated or are a part of a
// deprecated package. // deprecated package.
if (configuration.nodeprecated && if (configuration.getOptions().noDeprecated &&
(utils.isDeprecated(aClass) || (utils.isDeprecated(aClass) ||
utils.isDeprecated(utils.containingPackage(aClass)))) { utils.isDeprecated(utils.containingPackage(aClass)))) {
continue; continue;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -32,6 +32,7 @@ import javax.lang.model.element.PackageElement;
import jdk.javadoc.doclet.DocletEnvironment; import jdk.javadoc.doclet.DocletEnvironment;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
/** /**
@ -45,6 +46,7 @@ import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
public class ElementListWriter { public class ElementListWriter {
private final BaseConfiguration configuration; private final BaseConfiguration configuration;
private final BaseOptions options;
private final Utils utils; private final Utils utils;
private final DocFile file; private final DocFile file;
@ -56,6 +58,7 @@ public class ElementListWriter {
public ElementListWriter(BaseConfiguration configuration) { public ElementListWriter(BaseConfiguration configuration) {
file = DocFile.createFileForOutput(configuration, DocPaths.ELEMENT_LIST); file = DocFile.createFileForOutput(configuration, DocPaths.ELEMENT_LIST);
this.configuration = configuration; this.configuration = configuration;
this.options = configuration.getOptions();
this.utils = configuration.utils; this.utils = configuration.utils;
} }
@ -74,7 +77,7 @@ public class ElementListWriter {
try (BufferedWriter out = new BufferedWriter(file.openWriter())) { try (BufferedWriter out = new BufferedWriter(file.openWriter())) {
if (configuration.showModules) { if (configuration.showModules) {
for (ModuleElement mdle : configuration.modulePackages.keySet()) { for (ModuleElement mdle : configuration.modulePackages.keySet()) {
if (!(configuration.nodeprecated && utils.isDeprecated(mdle))) { if (!(options.noDeprecated && utils.isDeprecated(mdle))) {
out.write(DocletConstants.MODULE_PREFIX + mdle.toString()); out.write(DocletConstants.MODULE_PREFIX + mdle.toString());
out.newLine(); out.newLine();
for (PackageElement pkg : configuration.modulePackages.get(mdle)) { for (PackageElement pkg : configuration.modulePackages.get(mdle)) {
@ -87,7 +90,7 @@ public class ElementListWriter {
for (PackageElement pkg : configuration.packages) { for (PackageElement pkg : configuration.packages) {
// if the -nodeprecated option is set and the package is marked as // if the -nodeprecated option is set and the package is marked as
// deprecated, do not include it in the packages list. // deprecated, do not include it in the packages list.
if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) { if (!(options.noDeprecated && utils.isDeprecated(pkg))) {
out.write(pkg.toString()); out.write(pkg.toString());
out.newLine(); out.newLine();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -111,7 +111,7 @@ public class IndexBuilder {
this.noDeprecated = noDeprecated; this.noDeprecated = noDeprecated;
this.classesOnly = classesOnly; this.classesOnly = classesOnly;
this.javafx = configuration.javafx; this.javafx = configuration.getOptions().javafx;
this.indexmap = new TreeMap<>(); this.indexmap = new TreeMap<>();
comparator = classesOnly comparator = classesOnly
? utils.makeAllClassesComparator() ? utils.makeAllClassesComparator()

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -33,6 +33,8 @@ import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.Resources;
/** /**
* Provides methods for creating an array of class, method and * Provides methods for creating an array of class, method and
@ -47,16 +49,17 @@ import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
*/ */
public class MetaKeywords { public class MetaKeywords {
/** private final BaseOptions options;
* The global configuration information for this run. private final Resources resources;
*/ private final Utils utils;
private final BaseConfiguration config;
/** /**
* Constructor * Constructor
*/ */
public MetaKeywords(BaseConfiguration configuration) { public MetaKeywords(BaseConfiguration configuration) {
config = configuration; options = configuration.getOptions();
resources = configuration.getResources();
utils = configuration.utils;
} }
/** /**
@ -75,10 +78,10 @@ public class MetaKeywords {
ArrayList<String> results = new ArrayList<>(); ArrayList<String> results = new ArrayList<>();
// Add field and method keywords only if -keywords option is used // Add field and method keywords only if -keywords option is used
if (config.keywords) { if (options.keywords) {
results.addAll(getClassKeyword(typeElement)); results.addAll(getClassKeyword(typeElement));
results.addAll(getMemberKeywords(config.utils.getFields(typeElement))); results.addAll(getMemberKeywords(utils.getFields(typeElement)));
results.addAll(getMemberKeywords(config.utils.getMethods(typeElement))); results.addAll(getMemberKeywords(utils.getMethods(typeElement)));
} }
((ArrayList)results).trimToSize(); ((ArrayList)results).trimToSize();
return results; return results;
@ -90,8 +93,8 @@ public class MetaKeywords {
*/ */
protected List<String> getClassKeyword(TypeElement typeElement) { protected List<String> getClassKeyword(TypeElement typeElement) {
ArrayList<String> metakeywords = new ArrayList<>(1); ArrayList<String> metakeywords = new ArrayList<>(1);
String cltypelower = config.utils.isInterface(typeElement) ? "interface" : "class"; String cltypelower = utils.isInterface(typeElement) ? "interface" : "class";
metakeywords.add(config.utils.getFullyQualifiedName(typeElement) + " " + cltypelower); metakeywords.add(utils.getFullyQualifiedName(typeElement) + " " + cltypelower);
return metakeywords; return metakeywords;
} }
@ -100,8 +103,8 @@ public class MetaKeywords {
*/ */
public List<String> getMetaKeywords(PackageElement packageElement) { public List<String> getMetaKeywords(PackageElement packageElement) {
List<String> result = new ArrayList<>(1); List<String> result = new ArrayList<>(1);
if (config.keywords) { if (options.keywords) {
String pkgName = config.utils.getPackageName(packageElement); String pkgName = utils.getPackageName(packageElement);
result.add(pkgName + " " + "package"); result.add(pkgName + " " + "package");
} }
return result; return result;
@ -113,7 +116,7 @@ public class MetaKeywords {
* @param mdle the module being documented * @param mdle the module being documented
*/ */
public List<String> getMetaKeywordsForModule(ModuleElement mdle) { public List<String> getMetaKeywordsForModule(ModuleElement mdle) {
if (config.keywords) { if (options.keywords) {
return Arrays.asList(mdle.getQualifiedName() + " " + "module"); return Arrays.asList(mdle.getQualifiedName() + " " + "module");
} else { } else {
return Collections.emptyList(); return Collections.emptyList();
@ -125,8 +128,8 @@ public class MetaKeywords {
*/ */
public List<String> getOverviewMetaKeywords(String title, String docTitle) { public List<String> getOverviewMetaKeywords(String title, String docTitle) {
List<String> result = new ArrayList<>(1); List<String> result = new ArrayList<>(1);
if (config.keywords) { if (options.keywords) {
String windowOverview = config.getResources().getText(title); String windowOverview = resources.getText(title);
if (docTitle.length() > 0) { if (docTitle.length() > 0) {
result.add(windowOverview + ", " + docTitle); result.add(windowOverview + ", " + docTitle);
} else { } else {
@ -148,9 +151,9 @@ public class MetaKeywords {
protected List<String> getMemberKeywords(List<? extends Element> members) { protected List<String> getMemberKeywords(List<? extends Element> members) {
ArrayList<String> results = new ArrayList<>(); ArrayList<String> results = new ArrayList<>();
for (Element member : members) { for (Element member : members) {
String membername = config.utils.isMethod(member) String membername = utils.isMethod(member)
? config.utils.getSimpleName(member) + "()" ? utils.getSimpleName(member) + "()"
: config.utils.getSimpleName(member); : utils.getSimpleName(member);
if (!results.contains(membername)) { if (!results.contains(membername)) {
results.add(membername); results.add(membername);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -207,7 +207,8 @@ class StandardDocFileFactory extends DocFileFactory {
try { try {
OutputStream out = getFileObjectForOutput(path).openOutputStream(); OutputStream out = getFileObjectForOutput(path).openOutputStream();
return new BufferedWriter(new OutputStreamWriter(out, configuration.docencoding)); String docencoding = configuration.getOptions().docEncoding;
return new BufferedWriter(new OutputStreamWriter(out, docencoding));
} catch (IOException e) { } catch (IOException e) {
throw new DocFileIOException(this, DocFileIOException.Mode.WRITE, e); throw new DocFileIOException(this, DocFileIOException.Mode.WRITE, e);
} }
@ -328,7 +329,7 @@ class StandardDocFileFactory extends DocFileFactory {
/** /**
* Resolve a relative file against the given output location. * Resolve a relative file against the given output location.
* @param locn Currently, only * @param locn Currently, only
* {@link DocumentationTool.Location.DOCUMENTATION_OUTPUT} is supported. * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} is supported.
*/ */
@Override @Override
public DocFile resolveAgainst(Location locn) { public DocFile resolveAgainst(Location locn) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -162,7 +162,7 @@ public class TypeElementCatalog {
private void addTypeElement(TypeElement typeElement, Map<PackageElement, SortedSet<TypeElement>> map) { private void addTypeElement(TypeElement typeElement, Map<PackageElement, SortedSet<TypeElement>> map) {
PackageElement pkg = utils.containingPackage(typeElement); PackageElement pkg = utils.containingPackage(typeElement);
if (utils.isSpecified(pkg) || configuration.nodeprecated && utils.isDeprecated(pkg)) { if (utils.isSpecified(pkg) || configuration.getOptions().noDeprecated && utils.isDeprecated(pkg)) {
// No need to catalog this class if it's package is // No need to catalog this class if it's package is
// specified on the command line or if -nodeprecated option is set // specified on the command line or if -nodeprecated option is set
return; return;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -87,6 +87,7 @@ import com.sun.source.util.TreePath;
import com.sun.tools.javac.model.JavacTypes; import com.sun.tools.javac.model.JavacTypes;
import jdk.javadoc.internal.doclets.formats.html.SearchIndexItem; import jdk.javadoc.internal.doclets.formats.html.SearchIndexItem;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.CommentUtils.DocCommentDuo; import jdk.javadoc.internal.doclets.toolkit.CommentUtils.DocCommentDuo;
import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.Messages;
import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.Resources;
@ -112,15 +113,17 @@ import static jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuil
*/ */
public class Utils { public class Utils {
public final BaseConfiguration configuration; public final BaseConfiguration configuration;
public final Messages messages; private final BaseOptions options;
public final Resources resources; private final Messages messages;
private final Resources resources;
public final DocTrees docTrees; public final DocTrees docTrees;
public final Elements elementUtils; public final Elements elementUtils;
public final Types typeUtils; public final Types typeUtils;
public final JavaScriptScanner javaScriptScanner; private final JavaScriptScanner javaScriptScanner;
public Utils(BaseConfiguration c) { public Utils(BaseConfiguration c) {
configuration = c; configuration = c;
options = configuration.getOptions();
messages = configuration.getMessages(); messages = configuration.getMessages();
resources = configuration.getResources(); resources = configuration.getResources();
elementUtils = c.docEnv.getElementUtils(); elementUtils = c.docEnv.getElementUtils();
@ -390,7 +393,7 @@ public class Utils {
} }
public boolean isProperty(String name) { public boolean isProperty(String name) {
return configuration.javafx && name.endsWith("Property"); return options.javafx && name.endsWith("Property");
} }
public String getPropertyName(String name) { public String getPropertyName(String name) {
@ -1387,8 +1390,8 @@ public class Utils {
if (!text.contains("\t")) if (!text.contains("\t"))
return text; return text;
final int tabLength = configuration.sourcetab; final int tabLength = options.sourceTabSize;
final String whitespace = configuration.tabSpaces; final String whitespace = " ".repeat(tabLength);
final int textLength = text.length(); final int textLength = text.length();
StringBuilder result = new StringBuilder(textLength); StringBuilder result = new StringBuilder(textLength);
int pos = 0; int pos = 0;
@ -1520,7 +1523,7 @@ public class Utils {
if (!isIncluded(e)) { if (!isIncluded(e)) {
return false; return false;
} }
if (configuration.javafx && if (options.javafx &&
hasBlockTag(e, DocTree.Kind.UNKNOWN_BLOCK_TAG, "treatAsPrivate")) { hasBlockTag(e, DocTree.Kind.UNKNOWN_BLOCK_TAG, "treatAsPrivate")) {
return true; return true;
} }
@ -1533,7 +1536,7 @@ public class Utils {
* @return true if there are no comments, false otherwise * @return true if there are no comments, false otherwise
*/ */
public boolean isSimpleOverride(ExecutableElement m) { public boolean isSimpleOverride(ExecutableElement m) {
if (!configuration.summarizeOverriddenMethods || if (!options.summarizeOverriddenMethods ||
!isIncluded(m)) { !isIncluded(m)) {
return false; return false;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -48,6 +48,7 @@ import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.PropertyUtils; import jdk.javadoc.internal.doclets.toolkit.PropertyUtils;
/** /**
@ -106,6 +107,7 @@ public class VisibleMemberTable {
final TypeElement parent; final TypeElement parent;
final BaseConfiguration config; final BaseConfiguration config;
final BaseOptions options;
final Utils utils; final Utils utils;
final VisibleMemberCache mcache; final VisibleMemberCache mcache;
@ -126,6 +128,7 @@ public class VisibleMemberTable {
VisibleMemberCache mcache) { VisibleMemberCache mcache) {
config = configuration; config = configuration;
utils = configuration.utils; utils = configuration.utils;
options = configuration.getOptions();
te = typeElement; te = typeElement;
parent = utils.getSuperClass(te); parent = utils.getSuperClass(te);
this.mcache = mcache; this.mcache = mcache;
@ -658,7 +661,7 @@ public class VisibleMemberTable {
List<? extends Element> elements = te.getEnclosedElements(); List<? extends Element> elements = te.getEnclosedElements();
for (Element e : elements) { for (Element e : elements) {
if (config.nodeprecated && utils.isDeprecated(e)) { if (options.noDeprecated && utils.isDeprecated(e)) {
continue; continue;
} }
switch (e.getKind()) { switch (e.getKind()) {
@ -800,7 +803,7 @@ public class VisibleMemberTable {
* {@code boolean isFoo()} * {@code boolean isFoo()}
*/ */
private void computeVisibleProperties(LocalMemberTable lmt) { private void computeVisibleProperties(LocalMemberTable lmt) {
if (!config.javafx) if (!options.javafx)
return; return;
PropertyUtils pUtils = config.propertyUtils; PropertyUtils pUtils = config.propertyUtils;

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
@ -91,7 +91,7 @@ main.opt.expand.requires.desc=\
all dependencies of those modules. all dependencies of those modules.
main.opt.help.desc=\ main.opt.help.desc=\
Display command line options and exit Display command-line options and exit
main.opt.module.arg=\ main.opt.module.arg=\
<module>(,<module>)* <module>(,<module>)*

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,15 +25,16 @@
* @test * @test
* @bug 4696488 * @bug 4696488
* @summary javadoc doesn't handle UNC paths for destination directory * @summary javadoc doesn't handle UNC paths for destination directory
* @modules jdk.javadoc/jdk.javadoc.internal.doclets.toolkit * @modules jdk.javadoc/jdk.javadoc.internal.doclets.toolkit:+open
* @run main T4696488 T4696488.java * @run main T4696488 T4696488.java
*/ */
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import java.lang.reflect.Method;
import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
public class T4696488 { public class T4696488 {
public static void main(String... args) { public static void main(String... args) throws Exception {
System.setProperty("file.separator", "/"); System.setProperty("file.separator", "/");
assertAddTrailingFileSep("/path/to/dir", "/path/to/dir/"); assertAddTrailingFileSep("/path/to/dir", "/path/to/dir/");
assertAddTrailingFileSep("/path/to/dir/", "/path/to/dir/"); assertAddTrailingFileSep("/path/to/dir/", "/path/to/dir/");
@ -47,8 +48,11 @@ public class T4696488 {
assertAddTrailingFileSep("\\\\server\\share\\path\\to\\dir\\\\", "\\\\server\\share\\path\\to\\dir\\"); assertAddTrailingFileSep("\\\\server\\share\\path\\to\\dir\\\\", "\\\\server\\share\\path\\to\\dir\\");
} }
private static void assertAddTrailingFileSep(String input, String expectedOutput) { private static void assertAddTrailingFileSep(String input, String expectedOutput) throws Exception {
String output = BaseConfiguration.addTrailingFileSep(input); //String output = BaseOptions.addTrailingFileSep(input);
Method m = BaseOptions.class.getDeclaredMethod("addTrailingFileSep", String.class);
m.setAccessible(true);
String output = (String) m.invoke(null, input);
if (!expectedOutput.equals(output)) { if (!expectedOutput.equals(output)) {
throw new Error("expected " + expectedOutput + " but was " + output); throw new Error("expected " + expectedOutput + " but was " + output);
} }