Wed, 19 Dec 2012 11:29:56 +0000
8004833: Integrate doclint support into javac
Reviewed-by: mcimadamore
1 /*
2 * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.tools.javac.main;
28 import java.io.File;
29 import java.io.FileWriter;
30 import java.io.PrintWriter;
31 import java.util.Collections;
32 import java.util.EnumSet;
33 import java.util.LinkedHashMap;
34 import java.util.Map;
35 import java.util.Set;
37 import javax.lang.model.SourceVersion;
39 import com.sun.tools.doclint.DocLint;
40 import com.sun.tools.javac.code.Lint;
41 import com.sun.tools.javac.code.Source;
42 import com.sun.tools.javac.code.Type;
43 import com.sun.tools.javac.jvm.Target;
44 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
45 import com.sun.tools.javac.util.Log;
46 import com.sun.tools.javac.util.Log.PrefixKind;
47 import com.sun.tools.javac.util.Log.WriterKind;
48 import com.sun.tools.javac.util.Options;
49 import static com.sun.tools.javac.main.Option.ChoiceKind.*;
50 import static com.sun.tools.javac.main.Option.OptionGroup.*;
51 import static com.sun.tools.javac.main.Option.OptionKind.*;
53 /**
54 * Options for javac. The specific Option to handle a command-line option
55 * is identified by searching the members of this enum in order, looking
56 * the first {@link #matches match}. The action for an Option is performed
57 * by calling {@link #process process}, and by providing a suitable
58 * {@link OptionHelper} to provide access the compiler state.
59 *
60 * <p><b>This is NOT part of any supported API.
61 * If you write code that depends on this, you do so at your own
62 * risk. This code and its internal interfaces are subject to change
63 * or deletion without notice.</b></p>
64 */
65 public enum Option {
66 G("-g", "opt.g", STANDARD, BASIC),
68 G_NONE("-g:none", "opt.g.none", STANDARD, BASIC) {
69 @Override
70 public boolean process(OptionHelper helper, String option) {
71 helper.put("-g:", "none");
72 return false;
73 }
74 },
76 G_CUSTOM("-g:", "opt.g.lines.vars.source",
77 STANDARD, BASIC, ANYOF, "lines", "vars", "source"),
79 XLINT("-Xlint", "opt.Xlint", EXTENDED, BASIC),
81 XLINT_CUSTOM("-Xlint:", "opt.Xlint.suboptlist",
82 EXTENDED, BASIC, ANYOF, getXLintChoices()),
84 XDOCLINT("-Xdoclint", "opt.Xdoclint", EXTENDED, BASIC),
86 XDOCLINT_CUSTOM("-Xdoclint:", "opt.Xdoclint.subopts", "opt.Xdoclint.custom", EXTENDED, BASIC) {
87 @Override
88 public boolean matches(String option) {
89 return DocLint.isValidOption(
90 option.replace(XDOCLINT_CUSTOM.text, DocLint.XMSGS_CUSTOM_PREFIX));
91 }
93 @Override
94 public boolean process(OptionHelper helper, String option) {
95 String prev = helper.get(XDOCLINT_CUSTOM);
96 String next = (prev == null) ? option : (prev + " " + option);
97 helper.put(XDOCLINT_CUSTOM.text, next);
98 return false;
99 }
100 },
102 // -nowarn is retained for command-line backward compatibility
103 NOWARN("-nowarn", "opt.nowarn", STANDARD, BASIC) {
104 @Override
105 public boolean process(OptionHelper helper, String option) {
106 helper.put("-Xlint:none", option);
107 return false;
108 }
109 },
111 VERBOSE("-verbose", "opt.verbose", STANDARD, BASIC),
113 // -deprecation is retained for command-line backward compatibility
114 DEPRECATION("-deprecation", "opt.deprecation", STANDARD, BASIC) {
115 @Override
116 public boolean process(OptionHelper helper, String option) {
117 helper.put("-Xlint:deprecation", option);
118 return false;
119 }
120 },
122 CLASSPATH("-classpath", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER),
124 CP("-cp", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER) {
125 @Override
126 public boolean process(OptionHelper helper, String option, String arg) {
127 return super.process(helper, "-classpath", arg);
128 }
129 },
131 SOURCEPATH("-sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER),
133 BOOTCLASSPATH("-bootclasspath", "opt.arg.path", "opt.bootclasspath", STANDARD, FILEMANAGER) {
134 @Override
135 public boolean process(OptionHelper helper, String option, String arg) {
136 helper.remove("-Xbootclasspath/p:");
137 helper.remove("-Xbootclasspath/a:");
138 return super.process(helper, option, arg);
139 }
140 },
142 XBOOTCLASSPATH_PREPEND("-Xbootclasspath/p:", "opt.arg.path", "opt.Xbootclasspath.p", EXTENDED, FILEMANAGER),
144 XBOOTCLASSPATH_APPEND("-Xbootclasspath/a:", "opt.arg.path", "opt.Xbootclasspath.a", EXTENDED, FILEMANAGER),
146 XBOOTCLASSPATH("-Xbootclasspath:", "opt.arg.path", "opt.bootclasspath", EXTENDED, FILEMANAGER) {
147 @Override
148 public boolean process(OptionHelper helper, String option, String arg) {
149 helper.remove("-Xbootclasspath/p:");
150 helper.remove("-Xbootclasspath/a:");
151 return super.process(helper, "-bootclasspath", arg);
152 }
153 },
155 EXTDIRS("-extdirs", "opt.arg.dirs", "opt.extdirs", STANDARD, FILEMANAGER),
157 DJAVA_EXT_DIRS("-Djava.ext.dirs=", "opt.arg.dirs", "opt.extdirs", EXTENDED, FILEMANAGER) {
158 @Override
159 public boolean process(OptionHelper helper, String option, String arg) {
160 return super.process(helper, "-extdirs", arg);
161 }
162 },
164 ENDORSEDDIRS("-endorseddirs", "opt.arg.dirs", "opt.endorseddirs", STANDARD, FILEMANAGER),
166 DJAVA_ENDORSED_DIRS("-Djava.endorsed.dirs=", "opt.arg.dirs", "opt.endorseddirs", EXTENDED, FILEMANAGER) {
167 @Override
168 public boolean process(OptionHelper helper, String option, String arg) {
169 return super.process(helper, "-endorseddirs", arg);
170 }
171 },
173 PROC("-proc:", "opt.proc.none.only", STANDARD, BASIC, ONEOF, "none", "only"),
175 PROCESSOR("-processor", "opt.arg.class.list", "opt.processor", STANDARD, BASIC),
177 PROCESSORPATH("-processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER),
179 D("-d", "opt.arg.directory", "opt.d", STANDARD, FILEMANAGER),
181 S("-s", "opt.arg.directory", "opt.sourceDest", STANDARD, FILEMANAGER),
183 H("-h", "opt.arg.directory", "opt.headerDest", STANDARD, FILEMANAGER),
185 IMPLICIT("-implicit:", "opt.implicit", STANDARD, BASIC, ONEOF, "none", "class"),
187 ENCODING("-encoding", "opt.arg.encoding", "opt.encoding", STANDARD, FILEMANAGER) {
188 @Override
189 public boolean process(OptionHelper helper, String option, String operand) {
190 return super.process(helper, option, operand);
191 }
193 },
195 SOURCE("-source", "opt.arg.release", "opt.source", STANDARD, BASIC) {
196 @Override
197 public boolean process(OptionHelper helper, String option, String operand) {
198 Source source = Source.lookup(operand);
199 if (source == null) {
200 helper.error("err.invalid.source", operand);
201 return true;
202 }
203 return super.process(helper, option, operand);
204 }
205 },
207 TARGET("-target", "opt.arg.release", "opt.target", STANDARD, BASIC) {
208 @Override
209 public boolean process(OptionHelper helper, String option, String operand) {
210 Target target = Target.lookup(operand);
211 if (target == null) {
212 helper.error("err.invalid.target", operand);
213 return true;
214 }
215 return super.process(helper, option, operand);
216 }
217 },
219 VERSION("-version", "opt.version", STANDARD, INFO) {
220 @Override
221 public boolean process(OptionHelper helper, String option) {
222 Log log = helper.getLog();
223 String ownName = helper.getOwnName();
224 log.printLines(PrefixKind.JAVAC, "version", ownName, JavaCompiler.version());
225 return super.process(helper, option);
226 }
227 },
229 FULLVERSION("-fullversion", null, HIDDEN, INFO) {
230 @Override
231 public boolean process(OptionHelper helper, String option) {
232 Log log = helper.getLog();
233 String ownName = helper.getOwnName();
234 log.printLines(PrefixKind.JAVAC, "fullVersion", ownName, JavaCompiler.fullVersion());
235 return super.process(helper, option);
236 }
237 },
239 DIAGS("-XDdiags=", null, HIDDEN, INFO) {
240 @Override
241 public boolean process(OptionHelper helper, String option) {
242 option = option.substring(option.indexOf('=') + 1);
243 String diagsOption = option.contains("%") ?
244 "-XDdiagsFormat=" :
245 "-XDdiags=";
246 diagsOption += option;
247 if (XD.matches(diagsOption))
248 return XD.process(helper, diagsOption);
249 else
250 return false;
251 }
252 },
254 HELP("-help", "opt.help", STANDARD, INFO) {
255 @Override
256 public boolean process(OptionHelper helper, String option) {
257 Log log = helper.getLog();
258 String ownName = helper.getOwnName();
259 log.printLines(PrefixKind.JAVAC, "msg.usage.header", ownName);
260 for (Option o: getJavaCompilerOptions()) {
261 o.help(log, OptionKind.STANDARD);
262 }
263 log.printNewline();
264 return super.process(helper, option);
265 }
266 },
268 A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC, true) {
269 @Override
270 public boolean matches(String arg) {
271 return arg.startsWith("-A");
272 }
274 @Override
275 public boolean hasArg() {
276 return false;
277 }
278 // Mapping for processor options created in
279 // JavacProcessingEnvironment
280 @Override
281 public boolean process(OptionHelper helper, String option) {
282 int argLength = option.length();
283 if (argLength == 2) {
284 helper.error("err.empty.A.argument");
285 return true;
286 }
287 int sepIndex = option.indexOf('=');
288 String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
289 if (!JavacProcessingEnvironment.isValidOptionName(key)) {
290 helper.error("err.invalid.A.key", option);
291 return true;
292 }
293 return process(helper, option, option);
294 }
295 },
297 X("-X", "opt.X", STANDARD, INFO) {
298 @Override
299 public boolean process(OptionHelper helper, String option) {
300 Log log = helper.getLog();
301 for (Option o: getJavaCompilerOptions()) {
302 o.help(log, OptionKind.EXTENDED);
303 }
304 log.printNewline();
305 log.printLines(PrefixKind.JAVAC, "msg.usage.nonstandard.footer");
306 return super.process(helper, option);
307 }
308 },
310 // This option exists only for the purpose of documenting itself.
311 // It's actually implemented by the launcher.
312 J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO) {
313 @Override
314 public boolean process(OptionHelper helper, String option) {
315 throw new AssertionError
316 ("the -J flag should be caught by the launcher.");
317 }
318 },
320 MOREINFO("-moreinfo", null, HIDDEN, BASIC) {
321 @Override
322 public boolean process(OptionHelper helper, String option) {
323 Type.moreInfo = true;
324 return super.process(helper, option);
325 }
326 },
328 // treat warnings as errors
329 WERROR("-Werror", "opt.Werror", STANDARD, BASIC),
331 // prompt after each error
332 // new Option("-prompt", "opt.prompt"),
333 PROMPT("-prompt", null, HIDDEN, BASIC),
335 // dump stack on error
336 DOE("-doe", null, HIDDEN, BASIC),
338 // output source after type erasure
339 PRINTSOURCE("-printsource", null, HIDDEN, BASIC),
341 // display warnings for generic unchecked operations
342 WARNUNCHECKED("-warnunchecked", null, HIDDEN, BASIC) {
343 @Override
344 public boolean process(OptionHelper helper, String option) {
345 helper.put("-Xlint:unchecked", option);
346 return false;
347 }
348 },
350 XMAXERRS("-Xmaxerrs", "opt.arg.number", "opt.maxerrs", EXTENDED, BASIC),
352 XMAXWARNS("-Xmaxwarns", "opt.arg.number", "opt.maxwarns", EXTENDED, BASIC),
354 XSTDOUT("-Xstdout", "opt.arg.file", "opt.Xstdout", EXTENDED, INFO) {
355 @Override
356 public boolean process(OptionHelper helper, String option, String arg) {
357 try {
358 Log log = helper.getLog();
359 // TODO: this file should be closed at the end of compilation
360 log.setWriters(new PrintWriter(new FileWriter(arg), true));
361 } catch (java.io.IOException e) {
362 helper.error("err.error.writing.file", arg, e);
363 return true;
364 }
365 return super.process(helper, option, arg);
366 }
367 },
369 XPRINT("-Xprint", "opt.print", EXTENDED, BASIC),
371 XPRINTROUNDS("-XprintRounds", "opt.printRounds", EXTENDED, BASIC),
373 XPRINTPROCESSORINFO("-XprintProcessorInfo", "opt.printProcessorInfo", EXTENDED, BASIC),
375 XPREFER("-Xprefer:", "opt.prefer", EXTENDED, BASIC, ONEOF, "source", "newer"),
377 XPKGINFO("-Xpkginfo:", "opt.pkginfo", EXTENDED, BASIC, ONEOF, "always", "legacy", "nonempty"),
379 /* -O is a no-op, accepted for backward compatibility. */
380 O("-O", null, HIDDEN, BASIC),
382 /* -Xjcov produces tables to support the code coverage tool jcov. */
383 XJCOV("-Xjcov", null, HIDDEN, BASIC),
385 PLUGIN("-Xplugin:", "opt.arg.plugin", "opt.plugin", EXTENDED, BASIC) {
386 @Override
387 public boolean process(OptionHelper helper, String option) {
388 String p = option.substring(option.indexOf(':') + 1);
389 String prev = helper.get(PLUGIN);
390 helper.put(PLUGIN.text, (prev == null) ? p : prev + '\0' + p.trim());
391 return false;
392 }
393 },
395 /* This is a back door to the compiler's option table.
396 * -XDx=y sets the option x to the value y.
397 * -XDx sets the option x to the value x.
398 */
399 XD("-XD", null, HIDDEN, BASIC) {
400 @Override
401 public boolean matches(String s) {
402 return s.startsWith(text);
403 }
404 @Override
405 public boolean process(OptionHelper helper, String option) {
406 option = option.substring(text.length());
407 int eq = option.indexOf('=');
408 String key = (eq < 0) ? option : option.substring(0, eq);
409 String value = (eq < 0) ? option : option.substring(eq+1);
410 helper.put(key, value);
411 return false;
412 }
413 },
415 // This option exists only for the purpose of documenting itself.
416 // It's actually implemented by the CommandLine class.
417 AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO) {
418 @Override
419 public boolean process(OptionHelper helper, String option) {
420 throw new AssertionError("the @ flag should be caught by CommandLine.");
421 }
422 },
424 /*
425 * TODO: With apt, the matches method accepts anything if
426 * -XclassAsDecls is used; code elsewhere does the lookup to
427 * see if the class name is both legal and found.
428 *
429 * In apt, the process method adds the candidate class file
430 * name to a separate list.
431 */
432 SOURCEFILE("sourcefile", null, HIDDEN, INFO) {
433 @Override
434 public boolean matches(String s) {
435 return s.endsWith(".java") // Java source file
436 || SourceVersion.isName(s); // Legal type name
437 }
438 @Override
439 public boolean process(OptionHelper helper, String option) {
440 if (option.endsWith(".java") ) {
441 File f = new File(option);
442 if (!f.exists()) {
443 helper.error("err.file.not.found", f);
444 return true;
445 }
446 if (!f.isFile()) {
447 helper.error("err.file.not.file", f);
448 return true;
449 }
450 helper.addFile(f);
451 } else {
452 helper.addClassName(option);
453 }
454 return false;
455 }
456 };
458 /** The kind of an Option. This is used by the -help and -X options. */
459 public enum OptionKind {
460 /** A standard option, documented by -help. */
461 STANDARD,
462 /** An extended option, documented by -X. */
463 EXTENDED,
464 /** A hidden option, not documented. */
465 HIDDEN,
466 }
468 /** The group for an Option. This determines the situations in which the
469 * option is applicable. */
470 enum OptionGroup {
471 /** A basic option, available for use on the command line or via the
472 * Compiler API. */
473 BASIC,
474 /** An option for javac's standard JavaFileManager. Other file managers
475 * may or may not support these options. */
476 FILEMANAGER,
477 /** A command-line option that requests information, such as -help. */
478 INFO,
479 /** A command-line "option" representing a file or class name. */
480 OPERAND
481 }
483 /** The kind of choice for "choice" options. */
484 enum ChoiceKind {
485 /** The expected value is exactly one of the set of choices. */
486 ONEOF,
487 /** The expected value is one of more of the set of choices. */
488 ANYOF
489 }
491 public final String text;
493 final OptionKind kind;
495 final OptionGroup group;
497 /** Documentation key for arguments.
498 */
499 final String argsNameKey;
501 /** Documentation key for description.
502 */
503 final String descrKey;
505 /** Suffix option (-foo=bar or -foo:bar)
506 */
507 final boolean hasSuffix;
509 /** The kind of choices for this option, if any.
510 */
511 final ChoiceKind choiceKind;
513 /** The choices for this option, if any, and whether or not the choices
514 * are hidden
515 */
516 final Map<String,Boolean> choices;
519 Option(String text, String descrKey,
520 OptionKind kind, OptionGroup group) {
521 this(text, null, descrKey, kind, group, null, null, false);
522 }
524 Option(String text, String argsNameKey, String descrKey,
525 OptionKind kind, OptionGroup group) {
526 this(text, argsNameKey, descrKey, kind, group, null, null, false);
527 }
529 Option(String text, String argsNameKey, String descrKey,
530 OptionKind kind, OptionGroup group, boolean doHasSuffix) {
531 this(text, argsNameKey, descrKey, kind, group, null, null, doHasSuffix);
532 }
534 Option(String text, String descrKey,
535 OptionKind kind, OptionGroup group,
536 ChoiceKind choiceKind, Map<String,Boolean> choices) {
537 this(text, null, descrKey, kind, group, choiceKind, choices, false);
538 }
540 Option(String text, String descrKey,
541 OptionKind kind, OptionGroup group,
542 ChoiceKind choiceKind, String... choices) {
543 this(text, null, descrKey, kind, group, choiceKind,
544 createChoices(choices), false);
545 }
546 // where
547 private static Map<String,Boolean> createChoices(String... choices) {
548 Map<String,Boolean> map = new LinkedHashMap<String,Boolean>();
549 for (String c: choices)
550 map.put(c, false);
551 return map;
552 }
554 private Option(String text, String argsNameKey, String descrKey,
555 OptionKind kind, OptionGroup group,
556 ChoiceKind choiceKind, Map<String,Boolean> choices,
557 boolean doHasSuffix) {
558 this.text = text;
559 this.argsNameKey = argsNameKey;
560 this.descrKey = descrKey;
561 this.kind = kind;
562 this.group = group;
563 this.choiceKind = choiceKind;
564 this.choices = choices;
565 char lastChar = text.charAt(text.length()-1);
566 this.hasSuffix = doHasSuffix || lastChar == ':' || lastChar == '=';
567 }
569 public String getText() {
570 return text;
571 }
573 public OptionKind getKind() {
574 return kind;
575 }
577 public boolean hasArg() {
578 return argsNameKey != null && !hasSuffix;
579 }
581 public boolean matches(String option) {
582 if (!hasSuffix)
583 return option.equals(text);
585 if (!option.startsWith(text))
586 return false;
588 if (choices != null) {
589 String arg = option.substring(text.length());
590 if (choiceKind == ChoiceKind.ONEOF)
591 return choices.keySet().contains(arg);
592 else {
593 for (String a: arg.split(",+")) {
594 if (!choices.keySet().contains(a))
595 return false;
596 }
597 }
598 }
600 return true;
601 }
603 public boolean process(OptionHelper helper, String option, String arg) {
604 if (choices != null) {
605 if (choiceKind == ChoiceKind.ONEOF) {
606 // some clients like to see just one of option+choice set
607 for (String s: choices.keySet())
608 helper.remove(option + s);
609 String opt = option + arg;
610 helper.put(opt, opt);
611 // some clients like to see option (without trailing ":")
612 // set to arg
613 String nm = option.substring(0, option.length() - 1);
614 helper.put(nm, arg);
615 } else {
616 // set option+word for each word in arg
617 for (String a: arg.split(",+")) {
618 String opt = option + a;
619 helper.put(opt, opt);
620 }
621 }
622 }
623 helper.put(option, arg);
624 return false;
625 }
627 public boolean process(OptionHelper helper, String option) {
628 if (hasSuffix)
629 return process(helper, text, option.substring(text.length()));
630 else
631 return process(helper, option, option);
632 }
634 void help(Log log, OptionKind kind) {
635 if (this.kind != kind)
636 return;
638 log.printRawLines(WriterKind.NOTICE,
639 String.format(" %-26s %s",
640 helpSynopsis(log),
641 log.localize(PrefixKind.JAVAC, descrKey)));
643 }
645 private String helpSynopsis(Log log) {
646 StringBuilder sb = new StringBuilder();
647 sb.append(text);
648 if (argsNameKey == null) {
649 if (choices != null) {
650 String sep = "{";
651 for (Map.Entry<String,Boolean> e: choices.entrySet()) {
652 if (!e.getValue()) {
653 sb.append(sep);
654 sb.append(e.getKey());
655 sep = ",";
656 }
657 }
658 sb.append("}");
659 }
660 } else {
661 if (!hasSuffix)
662 sb.append(" ");
663 sb.append(log.localize(PrefixKind.JAVAC, argsNameKey));
665 }
667 return sb.toString();
668 }
670 // For -XpkgInfo:value
671 public enum PkgInfo {
672 ALWAYS, LEGACY, NONEMPTY;
673 public static PkgInfo get(Options options) {
674 String v = options.get(XPKGINFO);
675 return (v == null
676 ? PkgInfo.LEGACY
677 : PkgInfo.valueOf(v.toUpperCase()));
678 }
679 }
681 private static Map<String,Boolean> getXLintChoices() {
682 Map<String,Boolean> choices = new LinkedHashMap<String,Boolean>();
683 choices.put("all", false);
684 for (Lint.LintCategory c : Lint.LintCategory.values())
685 choices.put(c.option, c.hidden);
686 for (Lint.LintCategory c : Lint.LintCategory.values())
687 choices.put("-" + c.option, c.hidden);
688 choices.put("none", false);
689 return choices;
690 }
692 static Set<Option> getJavaCompilerOptions() {
693 return EnumSet.allOf(Option.class);
694 }
696 public static Set<Option> getJavacFileManagerOptions() {
697 return getOptions(EnumSet.of(FILEMANAGER));
698 }
700 public static Set<Option> getJavacToolOptions() {
701 return getOptions(EnumSet.of(BASIC));
702 }
704 static Set<Option> getOptions(Set<OptionGroup> desired) {
705 Set<Option> options = EnumSet.noneOf(Option.class);
706 for (Option option : Option.values())
707 if (desired.contains(option.group))
708 options.add(option);
709 return Collections.unmodifiableSet(options);
710 }
712 }