mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8224612: javadoc should better handle empty set of doclet options
Reviewed-by: hannesw
This commit is contained in:
parent
d19f5f6830
commit
392b75d158
2 changed files with 173 additions and 4 deletions
|
@ -188,8 +188,6 @@ public class Start {
|
|||
|
||||
// let doclet print usage information
|
||||
if (docletClass != null) {
|
||||
String name = doclet.getName();
|
||||
messager.notice("main.doclet.usage.header", name);
|
||||
showDocletOptions(kind == ToolOption.Kind.EXTENDED
|
||||
? Option.Kind.EXTENDED
|
||||
: Option.Kind.STANDARD);
|
||||
|
@ -252,6 +250,13 @@ public class Start {
|
|||
}
|
||||
|
||||
private void showDocletOptions(Option.Kind kind) {
|
||||
String name = doclet.getName();
|
||||
Set<? extends Option> options = getSupportedOptionsOf(doclet);
|
||||
if (options.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
messager.notice("main.doclet.usage.header", name);
|
||||
|
||||
Comparator<Doclet.Option> comp = new Comparator<Doclet.Option>() {
|
||||
final Collator collator = Collator.getInstance(Locale.US);
|
||||
{ collator.setStrength(Collator.PRIMARY); }
|
||||
|
@ -262,7 +267,7 @@ public class Start {
|
|||
}
|
||||
};
|
||||
|
||||
doclet.getSupportedOptions().stream()
|
||||
options.stream()
|
||||
.filter(opt -> opt.getKind() == kind)
|
||||
.sorted(comp)
|
||||
.forEach(this::showDocletOption);
|
||||
|
@ -577,7 +582,7 @@ public class Start {
|
|||
int handleDocletOption(int idx, List<String> args, boolean isToolOption)
|
||||
throws OptionException {
|
||||
if (docletOptions == null) {
|
||||
docletOptions = doclet.getSupportedOptions();
|
||||
docletOptions = getSupportedOptionsOf(doclet);
|
||||
}
|
||||
String arg = args.get(idx);
|
||||
String argBase, argVal;
|
||||
|
@ -623,6 +628,11 @@ public class Start {
|
|||
return idx;
|
||||
}
|
||||
|
||||
private static Set<? extends Option> getSupportedOptionsOf(Doclet doclet) {
|
||||
Set<? extends Option> options = doclet.getSupportedOptions();
|
||||
return options == null ? Set.of() : options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an initial pass over the options, primarily to determine
|
||||
* the doclet to be used (if any), so that it may participate in the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue