mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-07 00:48:38 +00:00
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
Reviewed-by: ksrini, bpatel
This commit is contained in:
parent
33b751c3d4
commit
799f344fcc
@ -425,8 +425,7 @@ public enum Option {
|
||||
J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO, ArgKind.ADJACENT) {
|
||||
@Override
|
||||
public boolean process(OptionHelper helper, String option) {
|
||||
throw new AssertionError
|
||||
("the -J flag should be caught by the launcher.");
|
||||
throw new AssertionError("the -J flag should be caught by the launcher.");
|
||||
}
|
||||
},
|
||||
|
||||
@ -691,7 +690,7 @@ public enum Option {
|
||||
* This option takes an argument.
|
||||
* If the name of option ends with ':' or '=', the argument must be provided directly
|
||||
* after that separator.
|
||||
* Otherwise, if may appear after an '=' or in the following argument position.
|
||||
* Otherwise, it may appear after an '=' or in the following argument position.
|
||||
*/
|
||||
REQUIRED,
|
||||
|
||||
|
||||
@ -165,9 +165,11 @@ public class JavadocTool implements DocumentationTool {
|
||||
public int isSupportedOption(String option) {
|
||||
if (option == null)
|
||||
throw new NullPointerException();
|
||||
for (ToolOption o: ToolOption.values()) {
|
||||
if (o.opt.equals(option))
|
||||
return o.hasArg ? 1 : 0;
|
||||
for (ToolOption o : ToolOption.values()) {
|
||||
for (String name : o.names) {
|
||||
if (name.equals(option))
|
||||
return o.hasArg ? 1 : 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -595,8 +595,9 @@ public class ConfigurationImpl extends Configuration {
|
||||
|
||||
@Override
|
||||
public Set<Doclet.Option> getSupportedOptions() {
|
||||
Resources resources = getResources();
|
||||
Doclet.Option[] options = {
|
||||
new Option(this, "-bottom", 1) {
|
||||
new Option(resources, "-bottom", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -604,7 +605,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-charset", 1) {
|
||||
new Option(resources, "-charset", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -612,7 +613,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-doctitle", 1) {
|
||||
new Option(resources, "-doctitle", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -620,7 +621,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-footer", 1) {
|
||||
new Option(resources, "-footer", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -628,7 +629,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-header", 1) {
|
||||
new Option(resources, "-header", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -636,7 +637,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-helpfile", 1) {
|
||||
new Option(resources, "-helpfile", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -644,7 +645,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-html4") {
|
||||
new Option(resources, "-html4") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -652,7 +653,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-html5") {
|
||||
new Option(resources, "-html5") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -660,7 +661,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-nohelp") {
|
||||
new Option(resources, "-nohelp") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -668,7 +669,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-nodeprecatedlist") {
|
||||
new Option(resources, "-nodeprecatedlist") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -676,7 +677,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-noindex") {
|
||||
new Option(resources, "-noindex") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -684,7 +685,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-nonavbar") {
|
||||
new Option(resources, "-nonavbar") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -692,7 +693,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Hidden(this, "-nooverview") {
|
||||
new Hidden(resources, "-nooverview") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -700,7 +701,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-notree") {
|
||||
new Option(resources, "-notree") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -708,7 +709,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-overview", 1) {
|
||||
new Option(resources, "-overview", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -716,7 +717,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "--frames") {
|
||||
new Option(resources, "--frames") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -724,7 +725,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "--no-frames") {
|
||||
new Option(resources, "--no-frames") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -732,7 +733,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Hidden(this, "-packagesheader", 1) {
|
||||
new Hidden(resources, "-packagesheader", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -740,7 +741,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-splitindex") {
|
||||
new Option(resources, "-splitindex") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -748,7 +749,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-stylesheetfile", 1) {
|
||||
new Option(resources, "-stylesheetfile", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -756,7 +757,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-top", 1) {
|
||||
new Option(resources, "-top", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -764,7 +765,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-use") {
|
||||
new Option(resources, "-use") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -772,7 +773,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-windowtitle", 1) {
|
||||
new Option(resources, "-windowtitle", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -780,7 +781,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new XOption(this, "-Xdoclint") {
|
||||
new XOption(resources, "-Xdoclint") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -788,7 +789,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new XOption(this, "-Xdocrootparent", 1) {
|
||||
new XOption(resources, "-Xdocrootparent", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -796,7 +797,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new XOption(this, "doclet.xusage.xdoclint-extended.", "-Xdoclint:", 0) {
|
||||
new XOption(resources, "doclet.usage.xdoclint-extended", "-Xdoclint:", 0) {
|
||||
@Override
|
||||
public boolean matches(String option) {
|
||||
return option.toLowerCase().startsWith(getName().toLowerCase());
|
||||
@ -809,7 +810,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new XOption(this, "doclet.xusage.xdoclint-package.", "-Xdoclint/package:", 0) {
|
||||
new XOption(resources, "doclet.usage.xdoclint-package", "-Xdoclint/package:", 0) {
|
||||
@Override
|
||||
public boolean matches(String option) {
|
||||
return option.toLowerCase().startsWith(getName().toLowerCase());
|
||||
|
||||
@ -191,144 +191,196 @@ doclet.Groupname_already_used=In -group option, groupname already used: {0}
|
||||
doclet.Same_package_name_used=Package name format used twice: {0}
|
||||
|
||||
# option specifiers
|
||||
doclet.usage.d.parameters=<directory>
|
||||
doclet.usage.d.description=Destination directory for output files
|
||||
doclet.usage.d.parameters=\
|
||||
<directory>
|
||||
doclet.usage.d.description=\
|
||||
Destination directory for output files
|
||||
|
||||
doclet.usage.use.description=Create class and package usage pages
|
||||
doclet.usage.use.description=\
|
||||
Create class and package usage pages
|
||||
|
||||
doclet.usage.version.description=Include @version paragraphs
|
||||
doclet.usage.version.description=\
|
||||
Include @version paragraphs
|
||||
|
||||
doclet.usage.author.description=Include @author paragraphs
|
||||
doclet.usage.author.description=\
|
||||
Include @author paragraphs
|
||||
|
||||
doclet.usage.docfilessubdirs.description=Recursively copy doc-file subdirectories
|
||||
doclet.usage.docfilessubdirs.description=\
|
||||
Recursively copy doc-file subdirectories
|
||||
|
||||
doclet.usage.splitindex.description=Split index into one file per letter
|
||||
doclet.usage.splitindex.description=\
|
||||
Split index into one file per letter
|
||||
|
||||
doclet.usage.overview.parameters=<file>
|
||||
doclet.usage.overview.description=Read overview documentation from HTML file
|
||||
doclet.usage.overview.parameters=\
|
||||
<file>
|
||||
doclet.usage.overview.description=\
|
||||
Read overview documentation from HTML file
|
||||
|
||||
doclet.usage.windowtitle.parameters=\
|
||||
<text>
|
||||
doclet.usage.windowtitle.description=\
|
||||
Browser window title for the documentation
|
||||
|
||||
doclet.usage.windowtitle.parameters=<text>
|
||||
doclet.usage.windowtitle.description=Browser window title for the documentation
|
||||
doclet.usage.doctitle.parameters=\
|
||||
<html-code>
|
||||
doclet.usage.doctitle.description=\
|
||||
Include title for the overview page
|
||||
|
||||
doclet.usage.doctitle.parameters=<html-code>
|
||||
doclet.usage.doctitle.description=Include title for the overview page
|
||||
doclet.usage.header.parameters=\
|
||||
<html-code>
|
||||
doclet.usage.header.description=\
|
||||
Include header text for each page
|
||||
|
||||
doclet.usage.header.parameters=<html-code>
|
||||
doclet.usage.header.description=Include header text for each page
|
||||
doclet.usage.html4.description=\
|
||||
Generate HTML 4.01 output
|
||||
|
||||
doclet.usage.html4.description=Generate HTML 4.01 output
|
||||
doclet.usage.html5.description=\
|
||||
Generate HTML 5 output
|
||||
|
||||
doclet.usage.html5.description=Generate HTML 5 output
|
||||
doclet.usage.footer.parameters=\
|
||||
<html-code>
|
||||
doclet.usage.footer.description=\
|
||||
Include footer text for each page
|
||||
|
||||
doclet.usage.footer.parameters=<html-code>
|
||||
doclet.usage.footer.description=Include footer text for each page
|
||||
doclet.usage.top.parameters=\
|
||||
<html-code>
|
||||
doclet.usage.top.description=\
|
||||
Include top text for each page
|
||||
|
||||
doclet.usage.top.parameters=<html-code>
|
||||
doclet.usage.top.description=Include top text for each page
|
||||
doclet.usage.bottom.parameters=\
|
||||
<html-code>
|
||||
doclet.usage.bottom.description=\
|
||||
Include bottom text for each page
|
||||
|
||||
doclet.usage.bottom.parameters=<html-code>
|
||||
doclet.usage.bottom.description=Include bottom text for each page
|
||||
doclet.usage.link.parameters=\
|
||||
<url>
|
||||
doclet.usage.link.description=\
|
||||
Create links to javadoc output at <url>
|
||||
|
||||
doclet.usage.link.parameters=<url>
|
||||
doclet.usage.link.description=Create links to javadoc output at <url>
|
||||
doclet.usage.linkoffline.parameters=\
|
||||
<url1> <url2>
|
||||
doclet.usage.linkoffline.description=\
|
||||
Link to docs at <url1> using package list at <url2>
|
||||
|
||||
doclet.usage.linkoffline.parameters=<url1> <url2>
|
||||
doclet.usage.linkoffline.description=Link to docs at <url1> using package list\n\
|
||||
\ at <url2>
|
||||
doclet.usage.excludedocfilessubdir.parameters=\
|
||||
<name>:..
|
||||
doclet.usage.excludedocfilessubdir.description=\
|
||||
Exclude any doc-files subdirectories with given name
|
||||
|
||||
doclet.usage.excludedocfilessubdir.parameters=<name>:..
|
||||
doclet.usage.excludedocfilessubdir.description=\n\
|
||||
\ Exclude any doc-files subdirectories with\n\
|
||||
\ given name
|
||||
doclet.usage.group.parameters=\
|
||||
<name> <p1>:<p2>..
|
||||
doclet.usage.group.description=\
|
||||
Group specified packages together in overview page
|
||||
|
||||
doclet.usage.group.parameters=<name> <p1>:<p2>..
|
||||
doclet.usage.group.description=Group specified packages together\n\
|
||||
\ in overview page
|
||||
doclet.usage.nocomment.description=\
|
||||
Suppress description and tags, generate only declarations
|
||||
|
||||
doclet.usage.nocomment.description=Suppress description and tags, generate\n\
|
||||
\ only declarations
|
||||
doclet.usage.nodeprecated.description=\
|
||||
Do not include @deprecated information
|
||||
|
||||
doclet.usage.nodeprecated.description=Do not include @deprecated information
|
||||
doclet.usage.noqualifier.parameters=\
|
||||
<name1>:<name2>:..
|
||||
doclet.usage.noqualifier.description=\
|
||||
Exclude the list of qualifiers from the output
|
||||
|
||||
doclet.usage.noqualifier.parameters=<name1>:<name2>:..
|
||||
doclet.usage.noqualifier.description=Exclude the list of qualifiers from the output
|
||||
doclet.usage.nosince.description=\
|
||||
Do not include @since information
|
||||
|
||||
doclet.usage.nosince.description=Do not include @since information
|
||||
doclet.usage.notimestamp.description=\
|
||||
Do not include hidden time stamp
|
||||
|
||||
doclet.usage.notimestamp.description=Do not include hidden time stamp
|
||||
doclet.usage.nodeprecatedlist.description=\
|
||||
Do not generate deprecated list
|
||||
|
||||
doclet.usage.nodeprecatedlist.description=Do not generate deprecated list
|
||||
doclet.usage.notree.description=\
|
||||
Do not generate class hierarchy
|
||||
|
||||
doclet.usage.notree.description=Do not generate class hierarchy
|
||||
doclet.usage.noindex.description=\
|
||||
Do not generate index
|
||||
|
||||
doclet.usage.noindex.description=Do not generate index
|
||||
doclet.usage.nohelp.description=\
|
||||
Do not generate help link
|
||||
|
||||
doclet.usage.nohelp.description=Do not generate help link
|
||||
doclet.usage.nonavbar.description=\
|
||||
Do not generate navigation bar
|
||||
|
||||
doclet.usage.nonavbar.description=Do not generate navigation bar
|
||||
doclet.usage.nooverview.description=\
|
||||
Do not generate overview pages
|
||||
|
||||
doclet.usage.nooverview.description=Do not generate overview pages
|
||||
doclet.usage.serialwarn.description=\
|
||||
Generate warning about @serial tag
|
||||
|
||||
doclet.usage.serialwarn.description=Generate warning about @serial tag
|
||||
doclet.usage.tag.parameters=\
|
||||
<name>:<locations>:<header>
|
||||
doclet.usage.tag.description=\
|
||||
Specify single argument custom tags
|
||||
|
||||
doclet.usage.tag.parameters=<name>:<locations>:<header>
|
||||
doclet.usage.tag.description=\n\
|
||||
\ Specify single argument custom tags
|
||||
doclet.usage.taglet.description=\
|
||||
The fully qualified name of Taglet to register
|
||||
|
||||
doclet.usage.taglet.description=The fully qualified name of Taglet to register
|
||||
doclet.usage.tagletpath.description=\
|
||||
The path to Taglets
|
||||
|
||||
doclet.usage.tagletpath.description=The path to Taglets
|
||||
doclet.usage.charset.parameters=\
|
||||
<charset>
|
||||
doclet.usage.charset.description=\
|
||||
Charset for cross-platform viewing of generated documentation
|
||||
|
||||
doclet.usage.charset.parameters=<charset>
|
||||
doclet.usage.charset.description=Charset for cross-platform viewing of\n\
|
||||
\ generated documentation
|
||||
doclet.usage.helpfile.parameters=\
|
||||
<file>
|
||||
doclet.usage.helpfile.description=\
|
||||
Include file that help link links to
|
||||
|
||||
doclet.usage.helpfile.parameters=<file>
|
||||
doclet.usage.helpfile.description=Include file that help link links to
|
||||
doclet.usage.linksource.description=\
|
||||
Generate source in HTML
|
||||
|
||||
doclet.usage.linksource.description=Generate source in HTML
|
||||
doclet.usage.sourcetab.parameters=\
|
||||
<tab length>
|
||||
doclet.usage.sourcetab.description=\
|
||||
Specify the number of spaces each tab takes up in the source
|
||||
|
||||
doclet.usage.sourcetab.parameters=<tab length>
|
||||
doclet.usage.sourcetab.description=Specify the number of spaces each tab\n\
|
||||
\ takes up in the source
|
||||
doclet.usage.keywords.description=\
|
||||
Include HTML meta tags with package, class and member info
|
||||
|
||||
doclet.usage.keywords.description=Include HTML meta tags with package,\n\
|
||||
\ class and member info
|
||||
doclet.usage.stylesheetfile.parameters=\
|
||||
<path>
|
||||
doclet.usage.stylesheetfile.description=\
|
||||
File to change style of the generated documentation
|
||||
|
||||
doclet.usage.stylesheetfile.parameters=<path>
|
||||
doclet.usage.stylesheetfile.description=File to change style of the generated\n\
|
||||
\ documentation
|
||||
doclet.usage.docencoding.parameters=\
|
||||
<name>
|
||||
doclet.usage.docencoding.description=\
|
||||
Specify the character encoding for the output
|
||||
|
||||
doclet.usage.docencoding.parameters=<name>
|
||||
doclet.usage.docencoding.description=Specify the character encoding for the output
|
||||
doclet.usage.frames.description=\
|
||||
Enable the use of frames in the generated output (default)
|
||||
|
||||
doclet.usage.frames.description=Enable the use of frames in the generated output (default)
|
||||
doclet.usage.no-frames.description=\
|
||||
Disable the use of frames in the generated output
|
||||
|
||||
doclet.usage.no-frames.description=Disable the use of frames in the generated output
|
||||
doclet.usage.xdocrootparent.parameters=\
|
||||
<url>
|
||||
doclet.usage.xdocrootparent.description=\
|
||||
Replaces all @docRoot followed by /.. in doc comments with\n\
|
||||
<url>
|
||||
|
||||
doclet.xusage.xdocrootparent.parameters=<url>
|
||||
doclet.xusage.xdocrootparent.description=Replaces all @docRoot followed by /..\n\
|
||||
\ in doc comments with <url>
|
||||
doclet.usage.xdoclint.description=\
|
||||
Enable recommended checks for problems in javadoc comments
|
||||
|
||||
doclet.xusage.xdoclint.description=Enable recommended checks for problems in\n\
|
||||
\ javadoc comments
|
||||
|
||||
doclet.xusage.xdoclint-extended.parameters=(all|none|[-]<group>)
|
||||
doclet.usage.xdoclint-extended.parameters=\
|
||||
(all|none|[-]<group>)
|
||||
# L10N: do not localize these words: all none accessibility html missing reference syntax
|
||||
doclet.xusage.xdoclint-extended.description=Enable or disable specific checks\n\
|
||||
\ for problems in javadoc comments, where \n\
|
||||
\ <group> is one of accessibility, html,\n\
|
||||
\ missing, reference, or syntax.\n
|
||||
doclet.usage.xdoclint-extended.description=\
|
||||
Enable or disable specific checks for problems in javadoc\n\
|
||||
comments, where <group> is one of accessibility, html,\n\
|
||||
missing, reference, or syntax.
|
||||
|
||||
doclet.xusage.xdoclint-package.parameters=([-]<packages>)
|
||||
doclet.xusage.xdoclint-package.description=\n\
|
||||
\ Enable or disable checks in specific\n\
|
||||
\ packages. <packages> is a comma separated\n\
|
||||
\ list of package specifiers. Package\n\
|
||||
\ specifier is either a qualified name of a\n\
|
||||
\ package or a package name prefix followed\n\
|
||||
\ by .*, which expands to all sub-packages\n\
|
||||
\ of the given package. Prefix the package\n\
|
||||
\ specifier with - to disable checks for\n\
|
||||
\ the specified packages.\n
|
||||
doclet.usage.xdoclint-package.parameters=\
|
||||
([-]<packages>)
|
||||
doclet.usage.xdoclint-package.description=\
|
||||
Enable or disable checks in specific packages. <packages> is a\n\
|
||||
comma separated list of package specifiers. A package\n\
|
||||
specifier is either a qualified name of a package or a package\n\
|
||||
name prefix followed by .*, which expands to all sub-packages\n\
|
||||
of the given package. Prefix the package specifier with - to\n\
|
||||
disable checks for the specified packages.
|
||||
|
||||
@ -404,8 +404,9 @@ public abstract class Configuration {
|
||||
}
|
||||
|
||||
public Set<Doclet.Option> getSupportedOptions() {
|
||||
Resources resources = getResources();
|
||||
Doclet.Option[] options = {
|
||||
new Option(this, "-author") {
|
||||
new Option(resources, "-author") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -413,7 +414,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-d", 1) {
|
||||
new Option(resources, "-d", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -421,7 +422,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-docencoding", 1) {
|
||||
new Option(resources, "-docencoding", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -429,7 +430,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-docfilessubdirs") {
|
||||
new Option(resources, "-docfilessubdirs") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -437,7 +438,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Hidden(this, "-encoding", 1) {
|
||||
new Hidden(resources, "-encoding", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -445,7 +446,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-excludedocfilessubdir", 1) {
|
||||
new Option(resources, "-excludedocfilessubdir", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -453,7 +454,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-group", 2) {
|
||||
new Option(resources, "-group", 2) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -461,7 +462,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Hidden(this, "-javafx") {
|
||||
new Hidden(resources, "-javafx") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -469,7 +470,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-keywords") {
|
||||
new Option(resources, "-keywords") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -477,7 +478,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-link", 1) {
|
||||
new Option(resources, "-link", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -486,7 +487,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-linksource") {
|
||||
new Option(resources, "-linksource") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -494,7 +495,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-linkoffline", 2) {
|
||||
new Option(resources, "-linkoffline", 2) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -503,7 +504,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-nocomment") {
|
||||
new Option(resources, "-nocomment") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -511,7 +512,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-nodeprecated") {
|
||||
new Option(resources, "-nodeprecated") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -519,7 +520,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-nosince") {
|
||||
new Option(resources, "-nosince") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -527,7 +528,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-notimestamp") {
|
||||
new Option(resources, "-notimestamp") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -535,7 +536,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-noqualifier", 1) {
|
||||
new Option(resources, "-noqualifier", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -543,7 +544,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Hidden(this, "-quiet") {
|
||||
new Hidden(resources, "-quiet") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -551,7 +552,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-serialwarn") {
|
||||
new Option(resources, "-serialwarn") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -559,7 +560,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-sourcetab", 1) {
|
||||
new Option(resources, "-sourcetab", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -578,7 +579,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-tag", 1) {
|
||||
new Option(resources, "-tag", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -589,7 +590,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-taglet", 1) {
|
||||
new Option(resources, "-taglet", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -600,7 +601,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-tagletpath", 1) {
|
||||
new Option(resources, "-tagletpath", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -608,7 +609,7 @@ public abstract class Configuration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "-version") {
|
||||
new Option(resources, "-version") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
@ -1057,37 +1058,30 @@ public abstract class Configuration {
|
||||
private final String description;
|
||||
private final int argCount;
|
||||
|
||||
protected final Configuration c;
|
||||
protected Option(Resources resources, String name, int argCount) {
|
||||
this(resources, "doclet.usage." + name.toLowerCase().replaceAll("^-*", ""), name, argCount);
|
||||
}
|
||||
|
||||
protected Option(Configuration config, String keyName, String name, int argCount) {
|
||||
c = config;
|
||||
protected Option(Resources resources, String keyBase, String name, int argCount) {
|
||||
this.name = name;
|
||||
String desc = getOptionsMessage(keyName + "description");
|
||||
String desc = getOptionsMessage(resources, keyBase + ".description");
|
||||
if (desc.isEmpty()) {
|
||||
this.description = "<MISSING KEY>";
|
||||
this.parameters = "<MISSING KEY>";
|
||||
} else {
|
||||
this.description = desc;
|
||||
this.parameters = getOptionsMessage(keyName + "parameters");
|
||||
this.parameters = getOptionsMessage(resources, keyBase + ".parameters");
|
||||
}
|
||||
this.argCount = argCount;
|
||||
}
|
||||
|
||||
protected Option(String prefix, Configuration config, String name, int argCount) {
|
||||
this(config, prefix + name.toLowerCase().replaceAll("^-*", "") + ".", name, argCount);
|
||||
protected Option(Resources resources, String name) {
|
||||
this(resources, name, 0);
|
||||
}
|
||||
|
||||
protected Option(Configuration config, String name, int argCount) {
|
||||
this("doclet.usage.", config, name, argCount);
|
||||
}
|
||||
|
||||
protected Option(Configuration config, String name) {
|
||||
this(config, name, 0);
|
||||
}
|
||||
|
||||
private String getOptionsMessage(String key) {
|
||||
private String getOptionsMessage(Resources resources, String key) {
|
||||
try {
|
||||
return c.getResources().getText(key);
|
||||
return resources.getText(key);
|
||||
} catch (MissingResourceException ignore) {
|
||||
return "";
|
||||
}
|
||||
@ -1113,19 +1107,9 @@ public abstract class Configuration {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maintains the formatting for javadoc -help. Note the space
|
||||
* alignment.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String opt = name + (name.endsWith(":") ? "" : " ") + parameters;
|
||||
StringBuffer sb = new StringBuffer(" ").append(opt).append(" ");
|
||||
for (int i = opt.length(); i < 32; i++) {
|
||||
sb.append(" ");
|
||||
}
|
||||
sb.append(description);
|
||||
return sb.toString();
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1135,7 +1119,14 @@ public abstract class Configuration {
|
||||
|
||||
@Override
|
||||
public boolean matches(String option) {
|
||||
return name.toLowerCase().equals(option.toLowerCase());
|
||||
boolean matchCase = name.startsWith("--");
|
||||
if (option.startsWith("--") && option.contains("=")) {
|
||||
return name.equals(option.substring(option.indexOf("=") + 1));
|
||||
} else if (matchCase) {
|
||||
return name.equals(option);
|
||||
} else {
|
||||
return name.toLowerCase().equals(option.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1146,16 +1137,16 @@ public abstract class Configuration {
|
||||
|
||||
public abstract class XOption extends Option {
|
||||
|
||||
public XOption(Configuration config, String keyname, String name, int argCount) {
|
||||
super(config, keyname, name, argCount);
|
||||
public XOption(Resources resources, String prefix, String name, int argCount) {
|
||||
super(resources, prefix, name, argCount);
|
||||
}
|
||||
|
||||
public XOption(Configuration config, String name, int argCount) {
|
||||
super("doclet.xusage.", config, name, argCount);
|
||||
public XOption(Resources resources, String name, int argCount) {
|
||||
super(resources, name, argCount);
|
||||
}
|
||||
|
||||
public XOption(Configuration config, String name) {
|
||||
this(config, name, 0);
|
||||
public XOption(Resources resources, String name) {
|
||||
this(resources, name, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1166,12 +1157,12 @@ public abstract class Configuration {
|
||||
|
||||
public abstract class Hidden extends Option {
|
||||
|
||||
public Hidden(Configuration config, String name, int argCount) {
|
||||
super("doclet.xusage.", config, name, argCount);
|
||||
public Hidden(Resources resources, String name, int argCount) {
|
||||
super(resources, name, argCount);
|
||||
}
|
||||
|
||||
public Hidden(Configuration config, String name) {
|
||||
this(config, name, 0);
|
||||
public Hidden(Resources resources, String name) {
|
||||
this(resources, name, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -255,7 +255,7 @@ public class Messager extends Log implements Reporter {
|
||||
private void incrementErrorCount(String prefix, String msg) {
|
||||
if (nerrors < MaxErrors) {
|
||||
PrintWriter errWriter = getWriter(WriterKind.ERROR);
|
||||
errWriter.println(prefix + ": " + getText("javadoc.error") + " - " + msg);
|
||||
printRawLines(errWriter, prefix + ": " + getText("javadoc.error") + " - " + msg);
|
||||
errWriter.flush();
|
||||
prompt();
|
||||
nerrors++;
|
||||
@ -293,7 +293,7 @@ public class Messager extends Log implements Reporter {
|
||||
private void incrementWarningCount(String prefix, String msg) {
|
||||
if (nwarnings < MaxWarnings) {
|
||||
PrintWriter warnWriter = getWriter(WriterKind.WARNING);
|
||||
warnWriter.println(prefix + ": " + getText("javadoc.warning") + " - " + msg);
|
||||
printRawLines(warnWriter, prefix + ": " + getText("javadoc.warning") + " - " + msg);
|
||||
warnWriter.flush();
|
||||
nwarnings++;
|
||||
}
|
||||
@ -318,9 +318,9 @@ public class Messager extends Log implements Reporter {
|
||||
|
||||
PrintWriter noticeWriter = getWriter(WriterKind.NOTICE);
|
||||
if (path == null) {
|
||||
noticeWriter.println(msg);
|
||||
printRawLines(noticeWriter, msg);
|
||||
} else {
|
||||
noticeWriter.println(prefix + ": " + msg);
|
||||
printRawLines(noticeWriter, prefix + ": " + msg);
|
||||
}
|
||||
noticeWriter.flush();
|
||||
}
|
||||
@ -334,9 +334,9 @@ public class Messager extends Log implements Reporter {
|
||||
|
||||
PrintWriter noticeWriter = getWriter(WriterKind.NOTICE);
|
||||
if (e == null) {
|
||||
noticeWriter.println(msg);
|
||||
printRawLines(noticeWriter, msg);
|
||||
} else {
|
||||
noticeWriter.println(pos + ": " + msg);
|
||||
printRawLines(noticeWriter, pos + ": " + msg);
|
||||
}
|
||||
noticeWriter.flush();
|
||||
}
|
||||
|
||||
@ -31,14 +31,18 @@ import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Path;
|
||||
import java.text.BreakIterator;
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.tools.JavaFileManager;
|
||||
import javax.tools.JavaFileObject;
|
||||
@ -61,6 +65,7 @@ import com.sun.tools.javac.util.Options;
|
||||
import jdk.javadoc.doclet.Doclet;
|
||||
import jdk.javadoc.doclet.Doclet.Option;
|
||||
import jdk.javadoc.doclet.DocletEnvironment;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Resources;
|
||||
|
||||
import static javax.tools.DocumentationTool.Location.*;
|
||||
|
||||
@ -168,7 +173,10 @@ public class Start extends ToolOption.Helper {
|
||||
}
|
||||
|
||||
void usage(boolean exit) {
|
||||
usage("main.usage", "-help", "main.usage.foot", exit);
|
||||
usage("main.usage", "-help", "main.usage.foot");
|
||||
|
||||
if (exit)
|
||||
throw new Messager.ExitJavadoc();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -177,30 +185,128 @@ public class Start extends ToolOption.Helper {
|
||||
}
|
||||
|
||||
void Xusage(boolean exit) {
|
||||
usage("main.Xusage", "-X", "main.Xusage.foot", exit);
|
||||
}
|
||||
|
||||
private void usage(String main, String option, String foot, boolean exit) {
|
||||
messager.notice(main);
|
||||
// let doclet print usage information (does nothing on error)
|
||||
if (docletClass != null) {
|
||||
String name = doclet.getName();
|
||||
Set<Option> supportedOptions = doclet.getSupportedOptions();
|
||||
messager.notice("main.doclet.usage.header", name);
|
||||
Option.Kind myKind = option.equals("-X")
|
||||
? Option.Kind.EXTENDED
|
||||
: Option.Kind.STANDARD;
|
||||
supportedOptions.stream()
|
||||
.filter(opt -> opt.getKind() == myKind)
|
||||
.forEach(opt -> messager.printNotice(opt.toString()));
|
||||
}
|
||||
if (foot != null)
|
||||
messager.notice(foot);
|
||||
usage("main.Xusage", "-X", "main.Xusage.foot");
|
||||
|
||||
if (exit)
|
||||
throw new Messager.ExitJavadoc();
|
||||
}
|
||||
|
||||
private void usage(String header, String option, String footer) {
|
||||
messager.notice(header);
|
||||
showToolOptions(option.equals("-X") ? OptionKind.EXTENDED : OptionKind.STANDARD);
|
||||
|
||||
// let doclet print usage information
|
||||
if (docletClass != null) {
|
||||
String name = doclet.getName();
|
||||
messager.notice("main.doclet.usage.header", name);
|
||||
showDocletOptions(option.equals("-X") ? Option.Kind.EXTENDED : Option.Kind.STANDARD);
|
||||
}
|
||||
|
||||
if (footer != null)
|
||||
messager.notice(footer);
|
||||
}
|
||||
|
||||
void showToolOptions(OptionKind kind) {
|
||||
Comparator<ToolOption> comp = new Comparator<ToolOption>() {
|
||||
final Collator collator = Collator.getInstance(Locale.US);
|
||||
{ collator.setStrength(Collator.PRIMARY); }
|
||||
|
||||
@Override
|
||||
public int compare(ToolOption o1, ToolOption o2) {
|
||||
return collator.compare(o1.primaryName, o2.primaryName);
|
||||
}
|
||||
};
|
||||
|
||||
Stream.of(ToolOption.values())
|
||||
.filter(opt -> opt.kind == kind)
|
||||
.sorted(comp)
|
||||
.forEach(opt -> showToolOption(opt));
|
||||
}
|
||||
|
||||
void showToolOption(ToolOption option) {
|
||||
List<String> names = option.getNames();
|
||||
String parameters;
|
||||
if (option.hasArg || option.primaryName.endsWith(":")) {
|
||||
String sep = (option == ToolOption.J) || option.primaryName.endsWith(":") ? "" : " ";
|
||||
parameters = sep + option.getParameters(messager);
|
||||
} else {
|
||||
parameters = "";
|
||||
}
|
||||
String description = option.getDescription(messager);
|
||||
showUsage(names, parameters, description);
|
||||
}
|
||||
|
||||
void showDocletOptions(Option.Kind kind) {
|
||||
Comparator<Doclet.Option> comp = new Comparator<Doclet.Option>() {
|
||||
final Collator collator = Collator.getInstance(Locale.US);
|
||||
{ collator.setStrength(Collator.PRIMARY); }
|
||||
|
||||
@Override
|
||||
public int compare(Doclet.Option o1, Doclet.Option o2) {
|
||||
return collator.compare(o1.getName(), o2.getName());
|
||||
}
|
||||
};
|
||||
|
||||
doclet.getSupportedOptions().stream()
|
||||
.filter(opt -> opt.getKind() == kind)
|
||||
.sorted(comp)
|
||||
.forEach(opt -> showDocletOption(opt));
|
||||
}
|
||||
|
||||
void showDocletOption(Doclet.Option option) {
|
||||
List<String> names = Arrays.asList(option.getName());
|
||||
String parameters;
|
||||
if (option.getArgumentCount() > 0 || option.getName().endsWith(":")) {
|
||||
String sep = option.getName().endsWith(":") ? "" : " ";
|
||||
parameters = sep + option.getParameters();
|
||||
} else {
|
||||
parameters = "";
|
||||
}
|
||||
String description = option.getDescription();
|
||||
showUsage(names, parameters, description);
|
||||
}
|
||||
|
||||
// The following constants are intended to format the output to
|
||||
// be similar to that of the java launcher: i.e. "java -help".
|
||||
|
||||
/** The indent for the option synopsis. */
|
||||
private static final String SMALL_INDENT = " ";
|
||||
/** The automatic indent for the description. */
|
||||
private static final String LARGE_INDENT = " ";
|
||||
/** The space allowed for the synopsis, if the description is to be shown on the same line. */
|
||||
private static final int DEFAULT_SYNOPSIS_WIDTH = 13;
|
||||
/** The nominal maximum line length, when seeing if text will fit on a line. */
|
||||
private static final int DEFAULT_MAX_LINE_LENGTH = 80;
|
||||
/** The format for a single-line help entry. */
|
||||
private static final String COMPACT_FORMAT = SMALL_INDENT + "%-" + DEFAULT_SYNOPSIS_WIDTH + "s %s";
|
||||
|
||||
void showUsage(List<String> names, String parameters, String description) {
|
||||
String synopses = names.stream()
|
||||
.map(s -> s + parameters)
|
||||
.collect(Collectors.joining(", "));
|
||||
// If option synopses and description fit on a single line of reasonable length,
|
||||
// display using COMPACT_FORMAT
|
||||
if (synopses.length() < DEFAULT_SYNOPSIS_WIDTH
|
||||
&& !description.contains("\n")
|
||||
&& (SMALL_INDENT.length() + DEFAULT_SYNOPSIS_WIDTH + 1 + description.length() <= DEFAULT_MAX_LINE_LENGTH)) {
|
||||
messager.printNotice(String.format(COMPACT_FORMAT, synopses, description));
|
||||
return;
|
||||
}
|
||||
|
||||
// If option synopses fit on a single line of reasonable length, show that;
|
||||
// otherwise, show 1 per line
|
||||
if (synopses.length() <= DEFAULT_MAX_LINE_LENGTH) {
|
||||
messager.printNotice(SMALL_INDENT + synopses);
|
||||
} else {
|
||||
for (String name: names) {
|
||||
messager.printNotice(SMALL_INDENT + name + parameters);
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, show the description
|
||||
messager.printNotice(LARGE_INDENT + description.replace("\n", "\n" + LARGE_INDENT));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Main program - external wrapper. In order to maintain backward
|
||||
@ -433,14 +539,37 @@ public class Start extends ToolOption.Helper {
|
||||
docletOptions = doclet.getSupportedOptions();
|
||||
}
|
||||
String arg = args.get(idx);
|
||||
String argBase, argVal;
|
||||
if (arg.startsWith("--") && arg.contains("=")) {
|
||||
int sep = arg.indexOf("=");
|
||||
argBase = arg.substring(0, sep);
|
||||
argVal = arg.substring(sep + 1);
|
||||
} else {
|
||||
argBase = arg;
|
||||
argVal = null;
|
||||
}
|
||||
|
||||
for (Doclet.Option opt : docletOptions) {
|
||||
if (opt.matches(arg)) {
|
||||
if (args.size() - idx < opt.getArgumentCount()) {
|
||||
usageError("main.requires_argument", arg);
|
||||
if (opt.matches(argBase)) {
|
||||
if (argVal != null) {
|
||||
switch (opt.getArgumentCount()) {
|
||||
case 0:
|
||||
usageError("main.unnecessary_arg_provided", argBase);
|
||||
break;
|
||||
case 1:
|
||||
opt.process(arg, Arrays.asList(argVal).listIterator());
|
||||
break;
|
||||
default:
|
||||
usageError("main.only_one_argument_with_equals", argBase);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (args.size() - idx -1 < opt.getArgumentCount()) {
|
||||
usageError("main.requires_argument", arg);
|
||||
}
|
||||
opt.process(arg, args.listIterator(idx + 1));
|
||||
idx += opt.getArgumentCount();
|
||||
}
|
||||
opt.process(arg, args.listIterator(idx + 1));
|
||||
idx += opt.getArgumentCount();
|
||||
return idx;
|
||||
}
|
||||
}
|
||||
@ -463,11 +592,11 @@ public class Start extends ToolOption.Helper {
|
||||
// Step 1: loop through the args, set locale early on, if found.
|
||||
for (int i = 0 ; i < argv.size() ; i++) {
|
||||
String arg = argv.get(i);
|
||||
if (arg.equals(ToolOption.LOCALE.opt)) {
|
||||
if (arg.equals(ToolOption.LOCALE.primaryName)) {
|
||||
checkOneArg(argv, i++);
|
||||
String lname = argv.get(i);
|
||||
locale = getLocale(lname);
|
||||
} else if (arg.equals(ToolOption.DOCLET.opt)) {
|
||||
} else if (arg.equals(ToolOption.DOCLET.primaryName)) {
|
||||
checkOneArg(argv, i++);
|
||||
if (userDocletName != null) {
|
||||
usageError("main.more_than_one_doclet_specified_0_and_1",
|
||||
@ -478,7 +607,7 @@ public class Start extends ToolOption.Helper {
|
||||
docletName, argv.get(i));
|
||||
}
|
||||
userDocletName = argv.get(i);
|
||||
} else if (arg.equals(ToolOption.DOCLETPATH.opt)) {
|
||||
} else if (arg.equals(ToolOption.DOCLETPATH.primaryName)) {
|
||||
checkOneArg(argv, i++);
|
||||
if (userDocletPath == null) {
|
||||
userDocletPath = argv.get(i);
|
||||
@ -599,8 +728,12 @@ public class Start extends ToolOption.Helper {
|
||||
handleDocletOptions(i, args, true);
|
||||
|
||||
if (o.hasArg) {
|
||||
checkOneArg(args, i++);
|
||||
o.process(this, args.get(i));
|
||||
if (arg.startsWith("--") && arg.contains("=")) {
|
||||
o.process(this, arg.substring(arg.indexOf('=') + 1));
|
||||
} else {
|
||||
checkOneArg(args, i++);
|
||||
o.process(this, args.get(i));
|
||||
}
|
||||
} else if (o.hasSuffix) {
|
||||
o.process(this, arg);
|
||||
} else {
|
||||
|
||||
@ -35,9 +35,12 @@ import java.util.Map;
|
||||
import javax.lang.model.element.ElementKind;
|
||||
|
||||
import com.sun.tools.javac.main.Option;
|
||||
import com.sun.tools.javac.main.Option.OptionKind;
|
||||
import com.sun.tools.javac.main.OptionHelper;
|
||||
import com.sun.tools.javac.util.Options;
|
||||
|
||||
import static com.sun.tools.javac.main.Option.OptionKind.*;
|
||||
|
||||
/**
|
||||
* javadoc tool options.
|
||||
*
|
||||
@ -50,197 +53,169 @@ public enum ToolOption {
|
||||
|
||||
// ----- options for underlying compiler -----
|
||||
|
||||
BOOTCLASSPATH("-bootclasspath", true) {
|
||||
BOOTCLASSPATH("-bootclasspath", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
CLASSPATH("-classpath", true) {
|
||||
CLASS_PATH("--class-path -classpath -cp", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.CLASS_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
CP("-cp", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.CLASS_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_PATH("--class-path", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.CLASS_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
EXTDIRS("-extdirs", true) {
|
||||
EXTDIRS("-extdirs", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.EXTDIRS, arg);
|
||||
}
|
||||
},
|
||||
|
||||
SOURCEPATH("-sourcepath", true) {
|
||||
SOURCE_PATH("--source-path -sourcepath", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.SOURCE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
SOURCE_PATH("--source-path", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.SOURCE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
SYSCLASSPATH("-sysclasspath", true) {
|
||||
SYSCLASSPATH("-sysclasspath", HIDDEN, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
MODULE_SOURCE_PATH("--module-source-path", true) {
|
||||
MODULE_SOURCE_PATH("--module-source-path", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
UPGRADE_MODULE_PATH("--upgrade-module-path", true) {
|
||||
UPGRADE_MODULE_PATH("--upgrade-module-path", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
SYSTEM("--system", true) {
|
||||
SYSTEM("--system", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.SYSTEM, arg);
|
||||
}
|
||||
},
|
||||
|
||||
MODULE_PATH("--module-path", true) {
|
||||
MODULE_PATH("--module-path -p", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.MODULE_PATH, arg);
|
||||
}
|
||||
},
|
||||
|
||||
P("-p", true) {
|
||||
ADD_MODULES("--add-modules", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.MODULE_PATH, arg);
|
||||
Option.ADD_MODULES.process(helper.getOptionHelper(), primaryName, arg);
|
||||
}
|
||||
},
|
||||
|
||||
ADD_MODULES("--add-modules", true) {
|
||||
LIMIT_MODULES("--limit-modules", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.ADD_MODULES.process(helper.getOptionHelper(), opt, arg);
|
||||
Option.LIMIT_MODULES.process(helper.getOptionHelper(), primaryName, arg);
|
||||
}
|
||||
},
|
||||
|
||||
LIMIT_MODULES("--limit-modules", true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.LIMIT_MODULES.process(helper.getOptionHelper(), opt, arg);
|
||||
}
|
||||
},
|
||||
|
||||
MODULE("--module", true) {
|
||||
MODULE("--module", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.addToList(this, ",", arg);
|
||||
}
|
||||
},
|
||||
|
||||
ENCODING("-encoding", true) {
|
||||
ENCODING("-encoding", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFileManagerOpt(Option.ENCODING, arg);
|
||||
}
|
||||
},
|
||||
|
||||
RELEASE("--release", true) {
|
||||
RELEASE("--release", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.RELEASE.process(helper.getOptionHelper(), opt, arg);
|
||||
Option.RELEASE.process(helper.getOptionHelper(), primaryName, arg);
|
||||
}
|
||||
},
|
||||
|
||||
SOURCE("-source", true) {
|
||||
SOURCE("-source", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.SOURCE.process(helper.getOptionHelper(), opt, arg);
|
||||
Option.SOURCE.process(helper.getOptionHelper(), primaryName, arg);
|
||||
}
|
||||
},
|
||||
|
||||
XMAXERRS("-Xmaxerrs", true) {
|
||||
XMAXERRS("-Xmaxerrs", EXTENDED, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.XMAXERRS.process(helper.getOptionHelper(), opt, arg);
|
||||
Option.XMAXERRS.process(helper.getOptionHelper(), primaryName, arg);
|
||||
}
|
||||
},
|
||||
|
||||
XMAXWARNS("-Xmaxwarns", true) {
|
||||
XMAXWARNS("-Xmaxwarns", EXTENDED, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.XMAXWARNS.process(helper.getOptionHelper(), opt, arg);
|
||||
Option.XMAXWARNS.process(helper.getOptionHelper(), primaryName, arg);
|
||||
}
|
||||
},
|
||||
|
||||
ADD_READS("--add-reads", true) {
|
||||
ADD_READS("--add-reads", EXTENDED, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.ADD_READS.process(helper.getOptionHelper(), opt, arg);
|
||||
Option.ADD_READS.process(helper.getOptionHelper(), primaryName, arg);
|
||||
}
|
||||
},
|
||||
|
||||
ADD_EXPORTS("--add-exports", true) {
|
||||
ADD_EXPORTS("--add-exports", EXTENDED, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.ADD_EXPORTS.process(helper.getOptionHelper(), opt, arg);
|
||||
Option.ADD_EXPORTS.process(helper.getOptionHelper(), primaryName, arg);
|
||||
}
|
||||
},
|
||||
|
||||
XMODULE("-Xmodule:", false) {
|
||||
XMODULE("-Xmodule:", EXTENDED, false) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.XMODULE.process(helper.getOptionHelper(), arg);
|
||||
}
|
||||
},
|
||||
|
||||
PATCH_MODULE("--patch-module", true) {
|
||||
PATCH_MODULE("--patch-module", EXTENDED, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
Option.PATCH_MODULE.process(helper.getOptionHelper(), opt, arg);
|
||||
Option.PATCH_MODULE.process(helper.getOptionHelper(), primaryName, arg);
|
||||
}
|
||||
},
|
||||
|
||||
// ----- doclet options -----
|
||||
|
||||
DOCLET("-doclet", true), // handled in setDocletInvoker
|
||||
DOCLET("-doclet", STANDARD, true), // handled in setDocletInvoker
|
||||
|
||||
DOCLETPATH("-docletpath", true), // handled in setDocletInvoker
|
||||
DOCLETPATH("-docletpath", STANDARD, true), // handled in setDocletInvoker
|
||||
|
||||
// ----- selection options -----
|
||||
|
||||
SUBPACKAGES("-subpackages", true) {
|
||||
SUBPACKAGES("-subpackages", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.addToList(this, ":", arg);
|
||||
}
|
||||
},
|
||||
|
||||
EXCLUDE("-exclude", true) {
|
||||
EXCLUDE("-exclude", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.addToList(this, ":", arg);
|
||||
@ -249,72 +224,72 @@ public enum ToolOption {
|
||||
|
||||
// ----- filtering options -----
|
||||
|
||||
PACKAGE("-package") {
|
||||
PACKAGE("-package", STANDARD) {
|
||||
@Override
|
||||
public void process(Helper helper) {
|
||||
helper.setSimpleFilter("package");
|
||||
}
|
||||
},
|
||||
|
||||
PRIVATE("-private") {
|
||||
PRIVATE("-private", STANDARD) {
|
||||
@Override
|
||||
public void process(Helper helper) {
|
||||
helper.setSimpleFilter("private");
|
||||
}
|
||||
},
|
||||
|
||||
PROTECTED("-protected") {
|
||||
PROTECTED("-protected", STANDARD) {
|
||||
@Override
|
||||
public void process(Helper helper) {
|
||||
helper.setSimpleFilter("protected");
|
||||
}
|
||||
},
|
||||
|
||||
PUBLIC("-public") {
|
||||
PUBLIC("-public", STANDARD) {
|
||||
@Override
|
||||
public void process(Helper helper) {
|
||||
helper.setSimpleFilter("public");
|
||||
}
|
||||
},
|
||||
|
||||
SHOW_MEMBERS("--show-members:") {
|
||||
SHOW_MEMBERS("--show-members", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFilter(this, arg);
|
||||
}
|
||||
},
|
||||
|
||||
SHOW_TYPES("--show-types:") {
|
||||
SHOW_TYPES("--show-types", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setFilter(this, arg);
|
||||
}
|
||||
},
|
||||
|
||||
SHOW_PACKAGES("--show-packages:") {
|
||||
SHOW_PACKAGES("--show-packages", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setShowPackageAccess(SHOW_PACKAGES, helper.getOptionArgumentValue(arg));
|
||||
helper.setShowPackageAccess(SHOW_PACKAGES, arg);
|
||||
}
|
||||
},
|
||||
|
||||
SHOW_MODULE_CONTENTS("--show-module-contents:") {
|
||||
SHOW_MODULE_CONTENTS("--show-module-contents", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setShowModuleContents(SHOW_MODULE_CONTENTS, helper.getOptionArgumentValue(arg));
|
||||
helper.setShowModuleContents(SHOW_MODULE_CONTENTS, arg);
|
||||
}
|
||||
},
|
||||
|
||||
EXPAND_REQUIRES("--expand-requires:") {
|
||||
EXPAND_REQUIRES("--expand-requires", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.setExpandRequires(EXPAND_REQUIRES, helper.getOptionArgumentValue(arg));
|
||||
helper.setExpandRequires(EXPAND_REQUIRES, arg);
|
||||
}
|
||||
},
|
||||
|
||||
// ----- output control options -----
|
||||
|
||||
PROMPT("-prompt") {
|
||||
PROMPT("-prompt", HIDDEN) {
|
||||
@Override
|
||||
public void process(Helper helper) {
|
||||
helper.compOpts.put("-prompt", "-prompt");
|
||||
@ -322,21 +297,21 @@ public enum ToolOption {
|
||||
}
|
||||
},
|
||||
|
||||
QUIET("-quiet") {
|
||||
QUIET("-quiet", STANDARD) {
|
||||
@Override
|
||||
public void process(Helper helper) {
|
||||
helper.jdtoolOpts.put(QUIET, true);
|
||||
}
|
||||
},
|
||||
|
||||
VERBOSE("-verbose") {
|
||||
VERBOSE("-verbose", STANDARD) {
|
||||
@Override
|
||||
public void process(Helper helper) {
|
||||
helper.compOpts.put("-verbose", "");
|
||||
}
|
||||
},
|
||||
|
||||
XWERROR("-Xwerror") {
|
||||
XWERROR("-Xwerror", HIDDEN) {
|
||||
@Override
|
||||
public void process(Helper helper) {
|
||||
helper.rejectWarnings = true;
|
||||
@ -346,21 +321,21 @@ public enum ToolOption {
|
||||
|
||||
// ----- other options -----
|
||||
|
||||
BREAKITERATOR("-breakiterator") {
|
||||
BREAKITERATOR("-breakiterator", STANDARD) {
|
||||
@Override
|
||||
public void process(Helper helper) {
|
||||
helper.breakiterator = true;
|
||||
}
|
||||
},
|
||||
|
||||
LOCALE("-locale", true) {
|
||||
LOCALE("-locale", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper, String arg) {
|
||||
helper.docLocale = arg;
|
||||
}
|
||||
},
|
||||
|
||||
XCLASSES("-Xclasses") {
|
||||
XCLASSES("-Xclasses", HIDDEN) {
|
||||
@Override
|
||||
public void process(Helper helper) {
|
||||
helper.jdtoolOpts.put(XCLASSES, true);
|
||||
@ -369,32 +344,54 @@ public enum ToolOption {
|
||||
|
||||
// ----- help options -----
|
||||
|
||||
HELP("-help") {
|
||||
HELP("--help -help", STANDARD) {
|
||||
@Override
|
||||
public void process(Helper helper) {
|
||||
helper.usage();
|
||||
}
|
||||
},
|
||||
|
||||
X("-X") {
|
||||
X("-X", STANDARD) {
|
||||
@Override
|
||||
public void process(Helper helper) {
|
||||
helper.Xusage();
|
||||
}
|
||||
},
|
||||
|
||||
// This option exists only for the purpose of documenting itself.
|
||||
// It's actually implemented by the launcher.
|
||||
J("-J", STANDARD, true) {
|
||||
@Override
|
||||
public void process(Helper helper) {
|
||||
throw new AssertionError("the -J flag should be caught by the launcher.");
|
||||
}
|
||||
},
|
||||
|
||||
// This option exists only for the purpose of documenting itself.
|
||||
// It's actually implemented ahead of the normal option decoding loop.
|
||||
Xold("-Xold", EXTENDED) {
|
||||
@Override
|
||||
public void process(Helper helper) {
|
||||
throw new AssertionError("the -Xold flag should be handled earlier.");
|
||||
}
|
||||
};
|
||||
|
||||
public final String opt;
|
||||
public final String primaryName;
|
||||
public final List<String> names;
|
||||
public final OptionKind kind;
|
||||
public final boolean hasArg;
|
||||
public final boolean hasSuffix; // ex: foo:bar or -foo=bar
|
||||
|
||||
ToolOption(String opt) {
|
||||
this(opt, false);
|
||||
ToolOption(String opt, OptionKind kind) {
|
||||
this(opt, kind, false);
|
||||
}
|
||||
|
||||
ToolOption(String opt, boolean hasArg) {
|
||||
this.opt = opt;
|
||||
ToolOption(String names, OptionKind kind, boolean hasArg) {
|
||||
this.names = Arrays.asList(names.split("\\s+"));
|
||||
this.primaryName = this.names.get(0);
|
||||
this.kind = kind;
|
||||
this.hasArg = hasArg;
|
||||
char lastChar = opt.charAt(opt.length() - 1);
|
||||
char lastChar = names.charAt(names.length() - 1);
|
||||
this.hasSuffix = lastChar == ':' || lastChar == '=';
|
||||
}
|
||||
|
||||
@ -402,16 +399,42 @@ public enum ToolOption {
|
||||
|
||||
void process(Helper helper) { }
|
||||
|
||||
List<String> getNames() {
|
||||
return names;
|
||||
}
|
||||
|
||||
String getParameters(Messager messager) {
|
||||
return (hasArg || primaryName.endsWith(":"))
|
||||
? messager.getText(getKey(primaryName, ".arg"))
|
||||
: null;
|
||||
}
|
||||
|
||||
String getDescription(Messager messager) {
|
||||
return messager.getText(getKey(primaryName, ".desc"));
|
||||
}
|
||||
|
||||
private String getKey(String optionName, String suffix) {
|
||||
return "main.opt."
|
||||
+ optionName
|
||||
.replaceAll("^-*", "") // remove leading '-'
|
||||
.replaceAll("[^A-Za-z0-9]+$", "") // remove trailing non-alphanumeric
|
||||
.replaceAll("[^A-Za-z0-9]", ".") // replace internal non-alphanumeric
|
||||
+ suffix;
|
||||
}
|
||||
|
||||
|
||||
static ToolOption get(String name) {
|
||||
String oname = name;
|
||||
if (name.contains(":")) {
|
||||
oname = name.substring(0, name.indexOf(':') + 1);
|
||||
} else if (name.contains("=")) {
|
||||
oname = name.substring(0, name.indexOf('=') + 1);
|
||||
oname = name.substring(0, name.indexOf('='));
|
||||
}
|
||||
for (ToolOption o : values()) {
|
||||
if (oname.equals(o.opt)) {
|
||||
return o;
|
||||
for (String n : o.names) {
|
||||
if (oname.equals(n)) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -457,11 +480,6 @@ public enum ToolOption {
|
||||
jdtoolOpts.put(opt, list);
|
||||
}
|
||||
|
||||
String getOptionArgumentValue(String in) {
|
||||
String[] values = in.trim().split(":");
|
||||
return values[1];
|
||||
}
|
||||
|
||||
void setExpandRequires(ToolOption opt, String arg) {
|
||||
switch (arg) {
|
||||
case "public":
|
||||
|
||||
@ -28,112 +28,234 @@ main.error={0} error
|
||||
main.warnings={0} warnings
|
||||
main.warning={0} warning
|
||||
|
||||
main.usage=Usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\
|
||||
\ -overview <file> Read overview documentation from HTML file\n\
|
||||
\ -public Show only public classes and members\n\
|
||||
\ -protected Show protected/public classes and \n\
|
||||
\ members (default)\n\
|
||||
\ -package Show package/protected/public classes\n\
|
||||
\ and members\n\
|
||||
\ -private Show all classes and members\n\
|
||||
\ --show-members:value Specifies which members (fields, methods\n\
|
||||
\ etc.) will be documented, where value can\n\
|
||||
\ be one of "public", "protected", "package"\n\
|
||||
\ or "private".\n\
|
||||
\ Default is protected, will show public and\n\
|
||||
\ protected members, "public" will show only\n\
|
||||
\ public members, "package" will show public,\n\
|
||||
\ protected and package members and \n\
|
||||
\ "private" will show all members\n\
|
||||
\ --show-types:value Specifies which types (classes, interfaces\n\
|
||||
\ etc.) will be documented, where value can be\n\
|
||||
\ one of "public", "protected", "package" or\n\
|
||||
\ "private".\n\
|
||||
\ Default is "protected", show public and\n\
|
||||
\ protected types, "package" will show public,\n\
|
||||
\ protected and package types and "private"\n\
|
||||
\ will show all types\n\
|
||||
\ --show-packages:value Specifies which module's packages will be\n\
|
||||
\ documented. Possible values are "exported"\n\
|
||||
\ or "all" packages\n\
|
||||
\ --show-module-contents:value Specifies the documentation granularity of\n\
|
||||
\ module declarations.\n\
|
||||
\ Possible values are "api" or "all".\n\
|
||||
\ --expand-requires:value Instructs the tool to expand the "requires"\n\
|
||||
\ module dependencies "public" expands all the\n\
|
||||
\ "requires public" edges of the module graph.\n\
|
||||
\ "all" expands all the "requires" edges of\n\
|
||||
\ the module graph by default only the\n\
|
||||
\ specified modules will be considered.\n\
|
||||
\ -help Display command line options and exit\n\
|
||||
\ --module m1, m2.. Document the specified module(s)\n\
|
||||
\ -doclet <class> Generate output via alternate doclet\n\
|
||||
\ -docletpath <path> Specify where to find doclet class files\n\
|
||||
\ --module-source-path <path> Specify where to find input source files\n\
|
||||
\ for multiple modules\n\
|
||||
\ --upgrade-module-path <path> Override location of upgradeable modules\n\
|
||||
\ --module-path <path>, -p <path> Specify where to find application modules\n\
|
||||
\ --add-modules <module>(,<module>)*\n\
|
||||
\ Root modules to resolve in addition to the\n\
|
||||
\ initial modules,\n\
|
||||
\ or all modules on the module path if\n\
|
||||
\ <module> is ALL-MODULE-PATH.\n\
|
||||
\ --limit-modules <module>(,<module>)*\n\
|
||||
\ Limit the universe of observable modules\n\
|
||||
\ --source-path <path> Specify where to find source files\n\
|
||||
\ -sourcepath <path> Specify where to find source files\n\
|
||||
\ --class-path <path> Specify where to find user class files\n\
|
||||
\ -classpath <path> Specify where to find user class files\n\
|
||||
\ -cp <path> Specify where to find user class files\n\
|
||||
\ -exclude <pkglist> Specify a list of packages to exclude\n\
|
||||
\ -subpackages <subpkglist> Specify subpackages to recursively load\n\
|
||||
\ -breakiterator Compute first sentence with BreakIterator\n\
|
||||
\ -bootclasspath <path> Override location of platform class files\n\
|
||||
\ used for non-modular releases\n\
|
||||
\ --system <jdk> Override location of system modules used\n\
|
||||
\ for modular releases.\n\
|
||||
\ --release <release> Provide source compatibility with\n\
|
||||
\ specified release\n\
|
||||
\ -source <release> Provide source compatibility with\n\
|
||||
\ specified release\n\
|
||||
\ -extdirs <dirlist> Override location of installed extensions\n\
|
||||
\ -verbose Output messages about what Javadoc is doing\n\
|
||||
\ -locale <name> Locale to be used, e.g. en_US or en_US_WIN\n\
|
||||
\ -encoding <name> Source file encoding name\n\
|
||||
\ -quiet Do not display status messages\n\
|
||||
\ -J<flag> Pass <flag> directly to the runtime system\n\
|
||||
\ -X Print a synopsis of nonstandard\n\
|
||||
\ options and exit\n
|
||||
main.usage=Usage:\n\
|
||||
\ javadoc [options] [packagenames] [sourcefiles] [@files]\n\
|
||||
where options include:
|
||||
|
||||
main.opt.public.desc=\
|
||||
Show only public classes and members
|
||||
|
||||
main.opt.protected.desc=\
|
||||
Show protected/public classes and members (default)
|
||||
|
||||
main.opt.package.desc=\
|
||||
Show package/protected/public classes and members
|
||||
|
||||
main.opt.private.desc=\
|
||||
Show all classes and members
|
||||
|
||||
main.opt.show.members.arg=\
|
||||
<value>
|
||||
main.opt.show.members.desc=\
|
||||
Specifies which members (fields, methods, etc.) will be\n\
|
||||
documented, where value can be one of "public", "protected",\n\
|
||||
"package" or "private". The default is "protected", which will\n\
|
||||
show public and protected members, "public" will show only\n\
|
||||
public members, "package" will show public, protected and\n\
|
||||
package members and "private" will show all members.
|
||||
|
||||
main.opt.show.types.arg=\
|
||||
<value>
|
||||
main.opt.show.types.desc=\
|
||||
Specifies which types (classes, interfaces, etc.) will be\n\
|
||||
documented, where value can be one of "public", "protected",\n\
|
||||
"package" or "private". The default is "protected", which will\n\
|
||||
show public and protected types, "public" will show only\n\
|
||||
public types, "package" will show public, protected and\n\
|
||||
package types and "private" will show all types.
|
||||
|
||||
main.opt.show.packages.arg=\
|
||||
<value>
|
||||
main.opt.show.packages.desc=\
|
||||
Specifies which module's packages will be documented. Possible\n\
|
||||
values are "exported" or "all" packages.
|
||||
|
||||
main.opt.show.module.contents.arg=\
|
||||
<value>
|
||||
main.opt.show.module.contents.desc=\
|
||||
Specifies the documentation granularity of module\n\
|
||||
declarations. Possible values are "api" or "all".
|
||||
|
||||
main.opt.expand.requires.arg=\
|
||||
<value>
|
||||
main.opt.expand.requires.desc=\
|
||||
Instructs the tool to expand the set of modules to be\n\
|
||||
documented. By default, only the modules given explicitly on\n\
|
||||
the command line will be documented. A value of "public" will\n\
|
||||
additionally include all "requires public" dependencies of\n\
|
||||
those modules. A value of "all" will include all dependencies\n\
|
||||
of those modules.
|
||||
|
||||
main.opt.help.desc=\
|
||||
Display command line options and exit
|
||||
|
||||
main.opt.module.arg=\
|
||||
<module>(,<module>)*
|
||||
main.opt.module.desc=\
|
||||
Document the specified module(s)
|
||||
|
||||
main.opt.doclet.arg=\
|
||||
<class>
|
||||
main.opt.doclet.desc=\
|
||||
Generate output via alternate doclet
|
||||
|
||||
main.opt.docletpath.arg=\
|
||||
<path>
|
||||
main.opt.docletpath.desc=\
|
||||
Specify where to find doclet class files
|
||||
|
||||
main.opt.module.source.path.arg=\
|
||||
<path>
|
||||
main.opt.module.source.path.desc=\
|
||||
Specify where to find input source files for multiple modules
|
||||
|
||||
main.opt.upgrade.module.path.arg=\
|
||||
<path>
|
||||
main.opt.upgrade.module.path.desc=\
|
||||
Override location of upgradeable modules
|
||||
|
||||
main.opt.module.path.arg=\
|
||||
<path>
|
||||
main.opt.module.path.desc=\
|
||||
Specify where to find application modules
|
||||
|
||||
main.opt.add.modules.arg=\
|
||||
<module>(,<module>)*
|
||||
main.opt.add.modules.desc=\
|
||||
Root modules to resolve in addition to the initial modules,\n\
|
||||
or all modules on the module path if <module> is\n\
|
||||
ALL-MODULE-PATH.
|
||||
|
||||
main.opt.limit.modules.arg=\
|
||||
<module>(,<module>)*
|
||||
main.opt.limit.modules.desc=\
|
||||
Limit the universe of observable modules
|
||||
|
||||
main.opt.source.path.arg=\
|
||||
<path>
|
||||
main.opt.source.path.desc=\
|
||||
Specify where to find source files
|
||||
|
||||
main.opt.class.path.arg=\
|
||||
<path>
|
||||
main.opt.class.path.desc=\
|
||||
Specify where to find user class files
|
||||
|
||||
main.opt.exclude.arg=\
|
||||
<pkglist>
|
||||
main.opt.exclude.desc=\
|
||||
Specify a list of packages to exclude
|
||||
|
||||
main.opt.subpackages.arg=\
|
||||
<subpkglist>
|
||||
main.opt.subpackages.desc=\
|
||||
Specify subpackages to recursively load
|
||||
|
||||
main.opt.breakiterator.desc=\
|
||||
Compute first sentence with BreakIterator
|
||||
|
||||
main.opt.bootclasspath.arg=\
|
||||
<path>
|
||||
main.opt.bootclasspath.desc=\
|
||||
Override location of platform class files used for non-modular\n\
|
||||
releases
|
||||
|
||||
main.opt.system.arg=\
|
||||
<jdk>
|
||||
main.opt.system.desc=\
|
||||
Override location of system modules used for modular releases
|
||||
|
||||
main.opt.release.arg=\
|
||||
<release>
|
||||
main.opt.release.desc=\
|
||||
Provide source compatibility with specified release
|
||||
|
||||
main.opt.source.arg=\
|
||||
<release>
|
||||
main.opt.source.desc=\
|
||||
Provide source compatibility with specified release
|
||||
|
||||
main.opt.extdirs.arg=\
|
||||
<dirlist>
|
||||
main.opt.extdirs.desc=\
|
||||
Override location of installed extensions
|
||||
|
||||
main.opt.verbose.desc=\
|
||||
Output messages about what Javadoc is doing
|
||||
|
||||
main.opt.locale.arg=\
|
||||
<name>
|
||||
main.opt.locale.desc=\
|
||||
Locale to be used, e.g. en_US or en_US_WIN
|
||||
|
||||
main.opt.encoding.arg=\
|
||||
<name>
|
||||
main.opt.encoding.desc=\
|
||||
Source file encoding name
|
||||
|
||||
main.opt.quiet.desc=\
|
||||
Do not display status messages
|
||||
|
||||
main.opt.J.arg=\
|
||||
<flag>
|
||||
main.opt.J.desc=\
|
||||
Pass <flag> directly to the runtime system
|
||||
|
||||
main.opt.X.desc=\
|
||||
Print a synopsis of nonstandard options and exit
|
||||
|
||||
main.usage.foot=\n\
|
||||
GNU-style options may use '=' instead of whitespace to separate the name of an\n\
|
||||
option from its value.\n
|
||||
|
||||
main.Xusage=\
|
||||
\ -Xmaxerrs <number> Set the maximum number of errors to print\n\
|
||||
\ -Xmaxwarns <number> Set the maximum number of warnings to print\n\
|
||||
\ --add-exports <module>/<package>=<other-module>(,<other-module>)*\n\
|
||||
\ Specify a package to be considered as exported\n\
|
||||
\ from its defining module to additional modules,\n\
|
||||
\ or to all unnamed modules if <other-module> is\n\
|
||||
\ ALL-UNNAMED.\n\
|
||||
\ --add-reads <module>=<other-module>(,<other-module>)*\n\
|
||||
\ Specify additional modules to be considered as\n\
|
||||
\ required by a given module. <other-module> may be\n\
|
||||
\ ALL-UNNAMED to require the unnamed module.\n\
|
||||
\ -Xmodule:<module-name> Specify a module to which the classes being\n\
|
||||
\ compiled belong.\n\
|
||||
\ --patch-module <module>=<file>(:<file>)*\n\
|
||||
\ Override or augment a module with classes\n\
|
||||
\ and resources in JAR files or directories\n\
|
||||
\ -Xold Invoke the legacy javadoc tool\n
|
||||
main.Xusage=
|
||||
|
||||
main.Xusage.foot=\
|
||||
main.opt.Xmaxerrs.arg=\
|
||||
<number>
|
||||
main.opt.Xmaxerrs.desc=\
|
||||
Set the maximum number of errors to print
|
||||
|
||||
main.opt.Xmaxwarns.arg=\
|
||||
<number>
|
||||
main.opt.Xmaxwarns.desc=\
|
||||
Set the maximum number of warnings to print
|
||||
|
||||
main.opt.add.exports.arg=\
|
||||
<module>/<package>=<other-module>(,<other-module>)*
|
||||
main.opt.add.exports.desc=\
|
||||
Specify a package to be considered as exported from its\n\
|
||||
defining module to additional modules, or to all unnamed\n\
|
||||
modules if <other-module> is ALL-UNNAMED
|
||||
|
||||
main.opt.add.reads.arg=\
|
||||
<module>=<other-module>(,<other-module>)*
|
||||
main.opt.add.reads.desc=\
|
||||
Specify additional modules to be considered as required by a\n\
|
||||
given module. <other-module> may be ALL-UNNAMED to require\n\
|
||||
the unnamed module.
|
||||
|
||||
main.opt.Xmodule.arg=\
|
||||
<module-name>
|
||||
main.opt.Xmodule.desc=\
|
||||
Specify a module to which the classes being compiled belong
|
||||
|
||||
main.opt.patch.module.arg=\
|
||||
<module>=<file>(:<file>)*
|
||||
main.opt.patch.module.desc=\
|
||||
Override or augment a module with classes and resources in\n\
|
||||
JAR files or directories
|
||||
|
||||
main.opt.Xold.desc=\
|
||||
Invoke the legacy javadoc tool
|
||||
|
||||
main.Xusage.foot=\n\
|
||||
These options are non-standard and subject to change without notice.
|
||||
|
||||
main.doclet.usage.header=Provided by the {0} doclet:
|
||||
main.doclet.usage.header=\nProvided by the {0} doclet:
|
||||
|
||||
main.requires_argument=option {0} requires an argument.
|
||||
main.unnecessary_arg_provided=option {0} does not require an argument
|
||||
main.only_one_argument_with_equals=cannot use ''='' syntax for options that require multiple arguments
|
||||
main.invalid_flag=invalid flag: {0}
|
||||
main.No_modules_packages_or_classes_specified=No modules, packages or classes specified.
|
||||
main.module_not_found=module {0} not found.\n
|
||||
|
||||
@ -41,6 +41,7 @@ import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -409,6 +410,23 @@ public abstract class JavadocTester {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content of the one of the output streams written by
|
||||
* javadoc.
|
||||
*/
|
||||
public String getOutput(Output output) {
|
||||
return outputMap.get(output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content of the one of the output streams written by
|
||||
* javadoc.
|
||||
*/
|
||||
public List<String> getOutputLines(Output output) {
|
||||
String text = outputMap.get(output);
|
||||
return (text == null) ? Collections.emptyList() : Arrays.asList(text.split(NL));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for files in (or not in) the generated output.
|
||||
* @param expectedFound true if all of the files are expected
|
||||
|
||||
@ -32,6 +32,9 @@
|
||||
* @run main TestHelpOption
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
public class TestHelpOption extends JavadocTester {
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
@ -39,6 +42,26 @@ public class TestHelpOption extends JavadocTester {
|
||||
tester.runTests();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLineLengths() {
|
||||
javadoc("-d", "out1",
|
||||
"-sourcepath", testSrc,
|
||||
"-X",
|
||||
testSrc("TestXOption.java"));
|
||||
checkExit(Exit.OK);
|
||||
List<String> longLines = getOutputLines(Output.OUT).stream()
|
||||
.filter(s -> s.length() > 80)
|
||||
.collect(Collectors.toList());
|
||||
checking("line lengths");
|
||||
if (longLines.isEmpty()) {
|
||||
passed("all lines OK");
|
||||
} else {
|
||||
out.println("long lines:");
|
||||
longLines.stream().forEach(s -> out.println(">>>" + s + "<<<"));
|
||||
failed(longLines.size() + " long lines");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithOption() {
|
||||
javadoc("-d", "out1",
|
||||
@ -107,7 +130,7 @@ public class TestHelpOption extends JavadocTester {
|
||||
"-use ",
|
||||
"-version ",
|
||||
"-author ",
|
||||
"-docfilessubdirs ",
|
||||
"-docfilessubdirs\n",
|
||||
"-splitindex ",
|
||||
"-windowtitle ",
|
||||
"-doctitle ",
|
||||
@ -119,11 +142,11 @@ public class TestHelpOption extends JavadocTester {
|
||||
"-excludedocfilessubdir ",
|
||||
"-group ",
|
||||
"-nocomment ",
|
||||
"-nodeprecated ",
|
||||
"-nodeprecated\n",
|
||||
"-noqualifier ",
|
||||
"-nosince ",
|
||||
"-notimestamp ",
|
||||
"-nodeprecatedlist ",
|
||||
"-nodeprecatedlist\n",
|
||||
"-notree ",
|
||||
"-noindex ",
|
||||
"-nohelp ",
|
||||
|
||||
@ -31,6 +31,9 @@
|
||||
* @run main TestXOption
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
public class TestXOption extends JavadocTester {
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
@ -38,6 +41,26 @@ public class TestXOption extends JavadocTester {
|
||||
tester.runTests();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLineLengths() {
|
||||
javadoc("-d", "out1",
|
||||
"-sourcepath", testSrc,
|
||||
"-X",
|
||||
testSrc("TestXOption.java"));
|
||||
checkExit(Exit.OK);
|
||||
List<String> longLines = getOutputLines(Output.OUT).stream()
|
||||
.filter(s -> s.length() > 80)
|
||||
.collect(Collectors.toList());
|
||||
checking("line lengths");
|
||||
if (longLines.isEmpty()) {
|
||||
passed("all lines OK");
|
||||
} else {
|
||||
out.println("long lines:");
|
||||
longLines.stream().forEach(s -> out.println(">>>" + s + "<<<"));
|
||||
failed(longLines.size() + " long lines");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithOption() {
|
||||
javadoc("-d", "out1",
|
||||
@ -58,14 +81,9 @@ public class TestXOption extends JavadocTester {
|
||||
}
|
||||
|
||||
private void checkOutput(boolean expectFound) {
|
||||
// TODO: It's an ugly hidden side-effect of the current doclet API
|
||||
// that the -X output from the tool and the -X output from the doclet
|
||||
// come out on different streams!
|
||||
// When we clean up the doclet API, this should be rationalized.
|
||||
checkOutput(Output.OUT, expectFound,
|
||||
"-Xmaxerrs ",
|
||||
"-Xmaxwarns ");
|
||||
checkOutput(Output.OUT, expectFound,
|
||||
"-Xmaxwarns ",
|
||||
"-Xdocrootparent ",
|
||||
"-Xdoclint ",
|
||||
"-Xdoclint:");
|
||||
|
||||
@ -145,6 +145,9 @@ public class CheckResourceKeys {
|
||||
// ignore these synthesized keys, tested by usageTests
|
||||
if (rk.startsWith("doclet.usage.") || rk.startsWith("doclet.xusage"))
|
||||
continue;
|
||||
// ignore these synthesized keys, tested by usageTests
|
||||
if (rk.matches("main\\.opt\\..*\\.(arg|desc)"))
|
||||
continue;
|
||||
if (codeKeys.contains(rk))
|
||||
continue;
|
||||
|
||||
@ -161,6 +164,9 @@ public class CheckResourceKeys {
|
||||
// ignore these synthesized keys, tested by usageTests
|
||||
if (ck.startsWith("doclet.usage.") || ck.startsWith("doclet.xusage."))
|
||||
continue;
|
||||
// ignore this partial key, tested by usageTests
|
||||
if (ck.equals("main.opt."))
|
||||
continue;
|
||||
if (resourceKeys.contains(ck))
|
||||
continue;
|
||||
error("No resource for \"" + ck + "\"");
|
||||
|
||||
293
langtools/test/jdk/javadoc/tool/OptionSyntaxTest.java
Normal file
293
langtools/test/jdk/javadoc/tool/OptionSyntaxTest.java
Normal file
@ -0,0 +1,293 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2016, 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8166144
|
||||
* @summary support new-style options
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* @modules jdk.compiler/com.sun.tools.javac.main
|
||||
* @modules jdk.javadoc/jdk.javadoc.internal.api
|
||||
* @modules jdk.javadoc/jdk.javadoc.internal.tool
|
||||
* @library /tools/lib
|
||||
* @build toolbox.JavacTask toolbox.JavadocTask toolbox.ModuleBuilder toolbox.TestRunner toolbox.ToolBox
|
||||
* @run main OptionSyntaxTest
|
||||
*/
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.lang.model.SourceVersion;
|
||||
|
||||
import jdk.javadoc.doclet.Doclet;
|
||||
import jdk.javadoc.doclet.DocletEnvironment;
|
||||
import jdk.javadoc.doclet.Reporter;
|
||||
|
||||
import toolbox.JavadocTask;
|
||||
import toolbox.ModuleBuilder;
|
||||
import toolbox.Task;
|
||||
import toolbox.TestRunner;
|
||||
import toolbox.ToolBox;
|
||||
|
||||
|
||||
public class OptionSyntaxTest extends TestRunner {
|
||||
public static class TestDoclet implements Doclet {
|
||||
@Override
|
||||
public boolean run(DocletEnvironment root) {
|
||||
System.out.println("TestDoclet.run");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Option> getSupportedOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SourceVersion getSupportedSourceVersion() {
|
||||
return SourceVersion.latest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Locale locale, Reporter reporter) {
|
||||
}
|
||||
|
||||
private final Set<Doclet.Option> options = new HashSet<>(Arrays.asList(
|
||||
new DOption("-old", 0),
|
||||
new DOption("-oldWithArg", 1),
|
||||
new DOption("-oldWithArgs", 2),
|
||||
new DOption("--new", 0),
|
||||
new DOption("--newWithArg", 1),
|
||||
new DOption("--newWithArgs", 2)
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
static class DOption implements Doclet.Option {
|
||||
private final String name;
|
||||
private final int argCount;
|
||||
|
||||
DOption(String name, int argCount) {
|
||||
this.name = name;
|
||||
this.argCount = argCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArgumentCount() {
|
||||
return argCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "description[" + name + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Kind getKind() {
|
||||
return Doclet.Option.Kind.STANDARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameters() {
|
||||
return argCount > 0 ? "parameters[" + name + "," + argCount + "]" : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(String option) {
|
||||
return option.equals(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(String option, ListIterator<String> arguments) {
|
||||
List<String> args = new ArrayList<>();
|
||||
for (int i = 0; i < argCount && arguments.hasNext(); i++) {
|
||||
args.add(arguments.next());
|
||||
}
|
||||
System.out.println("process " + option + " " + args);
|
||||
return args.stream().filter(s -> s.startsWith("arg")).count() == argCount;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
OptionSyntaxTest t = new OptionSyntaxTest();
|
||||
t.runTests();
|
||||
}
|
||||
|
||||
private final ToolBox tb = new ToolBox();
|
||||
private final Path src = Paths.get("src");
|
||||
private final Path modules = Paths.get("modules");
|
||||
|
||||
OptionSyntaxTest() throws IOException {
|
||||
super(System.err);
|
||||
initModules();
|
||||
}
|
||||
|
||||
void initModules() throws IOException {
|
||||
new ModuleBuilder(tb, "m1")
|
||||
.exports("p1")
|
||||
.classes("package p1; public class C1 { }")
|
||||
.write(src);
|
||||
|
||||
new ModuleBuilder(tb, "m2")
|
||||
.exports("p2")
|
||||
.classes("package p2; public class C2 { }")
|
||||
.build(modules);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasic() {
|
||||
new JavadocTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-docletpath", System.getProperty("test.classes"),
|
||||
"-doclet", TestDoclet.class.getName(),
|
||||
"-sourcepath", "src/m1",
|
||||
"p1")
|
||||
.run()
|
||||
.writeAll();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewSourcePath() {
|
||||
new JavadocTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-docletpath", System.getProperty("test.classes"),
|
||||
"-doclet", TestDoclet.class.getName(),
|
||||
"--source-path", "src/m1",
|
||||
"p1")
|
||||
.run()
|
||||
.writeAll();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewSourcePathEquals() {
|
||||
new JavadocTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-docletpath", System.getProperty("test.classes"),
|
||||
"-doclet", TestDoclet.class.getName(),
|
||||
"--source-path=src/m1",
|
||||
"p1")
|
||||
.run()
|
||||
.writeAll();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOldDocletArgs() {
|
||||
new JavadocTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-docletpath", System.getProperty("test.classes"),
|
||||
"-doclet", TestDoclet.class.getName(),
|
||||
"-sourcepath", "src/m1",
|
||||
"-old",
|
||||
"-oldWithArg", "arg",
|
||||
"-oldWithArgs", "arg1", "arg2",
|
||||
"p1")
|
||||
.run()
|
||||
.writeAll();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewDocletArgs() {
|
||||
new JavadocTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-docletpath", System.getProperty("test.classes"),
|
||||
"-doclet", TestDoclet.class.getName(),
|
||||
"-sourcepath", "src/m1",
|
||||
"--new",
|
||||
"--newWithArg", "arg",
|
||||
"--newWithArgs", "arg1", "arg2",
|
||||
"p1")
|
||||
.run()
|
||||
.writeAll();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewDocletArgsEquals() {
|
||||
new JavadocTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-docletpath", System.getProperty("test.classes"),
|
||||
"-doclet", TestDoclet.class.getName(),
|
||||
"-sourcepath", "src/m1",
|
||||
"--new", "--newWithArg=arg",
|
||||
"p1")
|
||||
.run()
|
||||
.writeAll();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewDocletArgsMissingArgs() throws Exception {
|
||||
String log = new JavadocTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-docletpath", System.getProperty("test.classes"),
|
||||
"-doclet", TestDoclet.class.getName(),
|
||||
"-sourcepath", "src/m1",
|
||||
"--newWithArg")
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
.getOutput(Task.OutputKind.DIRECT);
|
||||
if (!log.contains("option --newWithArg requires an argument"))
|
||||
throw new Exception("expected output not found");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewDocletArgsExtraArgs() throws Exception {
|
||||
String log = new JavadocTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-docletpath", System.getProperty("test.classes"),
|
||||
"-doclet", TestDoclet.class.getName(),
|
||||
"-sourcepath", "src/m1",
|
||||
"--new=arg",
|
||||
"p1")
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
.getOutput(Task.OutputKind.DIRECT);
|
||||
if (!log.contains("option --new does not require an argument"))
|
||||
throw new Exception("expected output not found");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewDocletArgsExtraArgs2() throws Exception {
|
||||
String log = new JavadocTask(tb, Task.Mode.CMDLINE)
|
||||
.options("-docletpath", System.getProperty("test.classes"),
|
||||
"-doclet", TestDoclet.class.getName(),
|
||||
"-sourcepath", "src/m1",
|
||||
"--newWithArgs=arg1 arg2",
|
||||
"p1")
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
.getOutput(Task.OutputKind.DIRECT);
|
||||
if (!log.contains("cannot use '=' syntax for options that require multiple arguments"))
|
||||
throw new Exception("expected output not found");
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016, 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
|
||||
@ -35,7 +35,7 @@ import javax.tools.DocumentationTool;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
/**
|
||||
* Tests for DocumentationTool.usSupportedOption method.
|
||||
* Tests for DocumentationTool.isSupportedOption method.
|
||||
*/
|
||||
public class IsSupportedOptionTest extends APITest {
|
||||
public static void main(String... args) throws Exception {
|
||||
|
||||
@ -70,7 +70,7 @@ public class FilterOptions extends ModuleTestBase {
|
||||
@Test
|
||||
public void testModuleModeApi(Path base) throws Exception {
|
||||
execTask("--module-source-path", src,
|
||||
"--module", "m1", "--show-module-contents:api");
|
||||
"--module", "m1", "--show-module-contents", "api");
|
||||
|
||||
checkModuleMode("API");
|
||||
}
|
||||
@ -78,7 +78,7 @@ public class FilterOptions extends ModuleTestBase {
|
||||
@Test
|
||||
public void testModuleModeAll(Path base) throws Exception {
|
||||
execTask("--module-source-path", src,
|
||||
"--module", "m1", "--show-module-contents:all");
|
||||
"--module", "m1", "--show-module-contents", "all");
|
||||
|
||||
checkModuleMode("ALL");
|
||||
}
|
||||
@ -87,7 +87,7 @@ public class FilterOptions extends ModuleTestBase {
|
||||
public void testShowPackagesExported(Path base) throws Exception {
|
||||
execTask("--module-source-path", src,
|
||||
"--module", "m1",
|
||||
"--show-packages:exported"); // default
|
||||
"--show-packages", "exported"); // default
|
||||
|
||||
checkModulesSpecified("m1");
|
||||
checkModulesIncluded("m1");
|
||||
@ -99,7 +99,7 @@ public class FilterOptions extends ModuleTestBase {
|
||||
public void testShowPackagesAll(Path base) throws Exception {
|
||||
execTask("--module-source-path", src,
|
||||
"--module", "m1",
|
||||
"--show-packages:all");
|
||||
"--show-packages", "all");
|
||||
checkModulesSpecified("m1");
|
||||
checkModulesIncluded("m1");
|
||||
checkPackagesIncluded("pub", "pro");
|
||||
@ -112,7 +112,7 @@ public class FilterOptions extends ModuleTestBase {
|
||||
public void testShowTypesPrivate(Path base) throws Exception {
|
||||
execTask("--module-source-path", src,
|
||||
"--module", "m1",
|
||||
"--show-types:private");
|
||||
"--show-types", "private");
|
||||
|
||||
checkModulesSpecified("m1");
|
||||
checkModulesIncluded("m1");
|
||||
@ -129,7 +129,7 @@ public class FilterOptions extends ModuleTestBase {
|
||||
public void testShowTypesPackage(Path base) throws Exception {
|
||||
execTask("--module-source-path", src,
|
||||
"--module", "m1",
|
||||
"--show-types:package");
|
||||
"--show-types", "package");
|
||||
|
||||
checkModulesSpecified("m1");
|
||||
checkModulesIncluded("m1");
|
||||
@ -145,7 +145,7 @@ public class FilterOptions extends ModuleTestBase {
|
||||
public void testShowTypesProtected(Path base) throws Exception {
|
||||
execTask("--module-source-path", src,
|
||||
"--module", "m1",
|
||||
"--show-types:protected");
|
||||
"--show-types", "protected");
|
||||
|
||||
checkModulesSpecified("m1");
|
||||
checkModulesIncluded("m1");
|
||||
@ -162,7 +162,7 @@ public class FilterOptions extends ModuleTestBase {
|
||||
public void testShowTypesPublic(Path base) throws Exception {
|
||||
execTask("--module-source-path", src,
|
||||
"--module", "m1",
|
||||
"--show-types:public");
|
||||
"--show-types", "public");
|
||||
|
||||
checkModulesSpecified("m1");
|
||||
checkModulesIncluded("m1");
|
||||
@ -179,7 +179,7 @@ public class FilterOptions extends ModuleTestBase {
|
||||
public void testShowMembersPrivate(Path base) throws Exception {
|
||||
execTask("--module-source-path", src,
|
||||
"--module", "m1",
|
||||
"--show-members:private");
|
||||
"--show-members", "private");
|
||||
|
||||
checkMembers(Visibility.PRIVATE);
|
||||
}
|
||||
@ -188,7 +188,7 @@ public class FilterOptions extends ModuleTestBase {
|
||||
public void testShowMembersPackage(Path base) throws Exception {
|
||||
execTask("--module-source-path", src,
|
||||
"--module", "m1",
|
||||
"--show-members:package");
|
||||
"--show-members", "package");
|
||||
|
||||
checkMembers(Visibility.PACKAGE);
|
||||
}
|
||||
@ -197,7 +197,7 @@ public class FilterOptions extends ModuleTestBase {
|
||||
public void testShowMembersProtected(Path base) throws Exception {
|
||||
execTask("--module-source-path", src,
|
||||
"--module", "m1",
|
||||
"--show-members:protected");
|
||||
"--show-members", "protected");
|
||||
|
||||
checkMembers(Visibility.PROTECTED);
|
||||
}
|
||||
@ -206,7 +206,7 @@ public class FilterOptions extends ModuleTestBase {
|
||||
public void testShowMembersPublic(Path base) throws Exception {
|
||||
execTask("--module-source-path", src,
|
||||
"--module", "m1",
|
||||
"--show-members:public");
|
||||
"--show-members", "public");
|
||||
|
||||
checkMembers(Visibility.PUBLIC);
|
||||
}
|
||||
|
||||
@ -440,7 +440,7 @@ public class Modules extends ModuleTestBase {
|
||||
|
||||
execTask("--module-source-path", src.toString(),
|
||||
"--module", "M",
|
||||
"--expand-requires:public");
|
||||
"--expand-requires", "public");
|
||||
|
||||
checkModulesSpecified("M", "N", "O");
|
||||
checkModulesIncluded("M", "N", "O");
|
||||
@ -465,7 +465,7 @@ public class Modules extends ModuleTestBase {
|
||||
|
||||
execTask("--module-source-path", src.toString(),
|
||||
"--module", "M",
|
||||
"--expand-requires:all");
|
||||
"--expand-requires", "all");
|
||||
|
||||
checkModulesSpecified("M", "java.base", "N", "L", "O");
|
||||
checkModulesIncluded("M", "java.base", "N", "L", "O");
|
||||
@ -493,7 +493,7 @@ public class Modules extends ModuleTestBase {
|
||||
|
||||
execNegativeTask("--module-source-path", src.toString(),
|
||||
"--module", "MIA",
|
||||
"--expand-requires:all");
|
||||
"--expand-requires", "all");
|
||||
|
||||
assertErrorPresent("javadoc: error - module MIA not found.");
|
||||
}
|
||||
@ -515,7 +515,7 @@ public class Modules extends ModuleTestBase {
|
||||
|
||||
execNegativeTask("--module-source-path", src.toString(),
|
||||
"--module", "M,N,L,MIA,O,P",
|
||||
"--expand-requires:all");
|
||||
"--expand-requires", "all");
|
||||
|
||||
assertErrorPresent("javadoc: error - module MIA not found");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user