Sun, 17 Feb 2013 16:44:55 -0500
Merge
1 /*
2 * Copyright (c) 2006, 2013, 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.Profile;
44 import com.sun.tools.javac.jvm.Target;
45 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
46 import com.sun.tools.javac.util.Log;
47 import com.sun.tools.javac.util.Log.PrefixKind;
48 import com.sun.tools.javac.util.Log.WriterKind;
49 import com.sun.tools.javac.util.Options;
50 import static com.sun.tools.javac.main.Option.ChoiceKind.*;
51 import static com.sun.tools.javac.main.Option.OptionGroup.*;
52 import static com.sun.tools.javac.main.Option.OptionKind.*;
54 /**
55 * Options for javac. The specific Option to handle a command-line option
56 * is identified by searching the members of this enum in order, looking
57 * the first {@link #matches match}. The action for an Option is performed
58 * by calling {@link #process process}, and by providing a suitable
59 * {@link OptionHelper} to provide access the compiler state.
60 *
61 * <p><b>This is NOT part of any supported API.
62 * If you write code that depends on this, you do so at your own
63 * risk. This code and its internal interfaces are subject to change
64 * or deletion without notice.</b></p>
65 */
66 public enum Option {
67 G("-g", "opt.g", STANDARD, BASIC),
69 G_NONE("-g:none", "opt.g.none", STANDARD, BASIC) {
70 @Override
71 public boolean process(OptionHelper helper, String option) {
72 helper.put("-g:", "none");
73 return false;
74 }
75 },
77 G_CUSTOM("-g:", "opt.g.lines.vars.source",
78 STANDARD, BASIC, ANYOF, "lines", "vars", "source"),
80 XLINT("-Xlint", "opt.Xlint", EXTENDED, BASIC),
82 XLINT_CUSTOM("-Xlint:", "opt.Xlint.suboptlist",
83 EXTENDED, BASIC, ANYOF, getXLintChoices()),
85 XDOCLINT("-Xdoclint", "opt.Xdoclint", EXTENDED, BASIC),
87 XDOCLINT_CUSTOM("-Xdoclint:", "opt.Xdoclint.subopts", "opt.Xdoclint.custom", EXTENDED, BASIC) {
88 @Override
89 public boolean matches(String option) {
90 return DocLint.isValidOption(
91 option.replace(XDOCLINT_CUSTOM.text, DocLint.XMSGS_CUSTOM_PREFIX));
92 }
94 @Override
95 public boolean process(OptionHelper helper, String option) {
96 String prev = helper.get(XDOCLINT_CUSTOM);
97 String next = (prev == null) ? option : (prev + " " + option);
98 helper.put(XDOCLINT_CUSTOM.text, next);
99 return false;
100 }
101 },
103 // -nowarn is retained for command-line backward compatibility
104 NOWARN("-nowarn", "opt.nowarn", STANDARD, BASIC) {
105 @Override
106 public boolean process(OptionHelper helper, String option) {
107 helper.put("-Xlint:none", option);
108 return false;
109 }
110 },
112 VERBOSE("-verbose", "opt.verbose", STANDARD, BASIC),
114 // -deprecation is retained for command-line backward compatibility
115 DEPRECATION("-deprecation", "opt.deprecation", STANDARD, BASIC) {
116 @Override
117 public boolean process(OptionHelper helper, String option) {
118 helper.put("-Xlint:deprecation", option);
119 return false;
120 }
121 },
123 CLASSPATH("-classpath", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER),
125 CP("-cp", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER) {
126 @Override
127 public boolean process(OptionHelper helper, String option, String arg) {
128 return super.process(helper, "-classpath", arg);
129 }
130 },
132 SOURCEPATH("-sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER),
134 BOOTCLASSPATH("-bootclasspath", "opt.arg.path", "opt.bootclasspath", STANDARD, FILEMANAGER) {
135 @Override
136 public boolean process(OptionHelper helper, String option, String arg) {
137 helper.remove("-Xbootclasspath/p:");
138 helper.remove("-Xbootclasspath/a:");
139 return super.process(helper, option, arg);
140 }
141 },
143 XBOOTCLASSPATH_PREPEND("-Xbootclasspath/p:", "opt.arg.path", "opt.Xbootclasspath.p", EXTENDED, FILEMANAGER),
145 XBOOTCLASSPATH_APPEND("-Xbootclasspath/a:", "opt.arg.path", "opt.Xbootclasspath.a", EXTENDED, FILEMANAGER),
147 XBOOTCLASSPATH("-Xbootclasspath:", "opt.arg.path", "opt.bootclasspath", EXTENDED, FILEMANAGER) {
148 @Override
149 public boolean process(OptionHelper helper, String option, String arg) {
150 helper.remove("-Xbootclasspath/p:");
151 helper.remove("-Xbootclasspath/a:");
152 return super.process(helper, "-bootclasspath", arg);
153 }
154 },
156 EXTDIRS("-extdirs", "opt.arg.dirs", "opt.extdirs", STANDARD, FILEMANAGER),
158 DJAVA_EXT_DIRS("-Djava.ext.dirs=", "opt.arg.dirs", "opt.extdirs", EXTENDED, FILEMANAGER) {
159 @Override
160 public boolean process(OptionHelper helper, String option, String arg) {
161 return super.process(helper, "-extdirs", arg);
162 }
163 },
165 ENDORSEDDIRS("-endorseddirs", "opt.arg.dirs", "opt.endorseddirs", STANDARD, FILEMANAGER),
167 DJAVA_ENDORSED_DIRS("-Djava.endorsed.dirs=", "opt.arg.dirs", "opt.endorseddirs", EXTENDED, FILEMANAGER) {
168 @Override
169 public boolean process(OptionHelper helper, String option, String arg) {
170 return super.process(helper, "-endorseddirs", arg);
171 }
172 },
174 PROC("-proc:", "opt.proc.none.only", STANDARD, BASIC, ONEOF, "none", "only"),
176 PROCESSOR("-processor", "opt.arg.class.list", "opt.processor", STANDARD, BASIC),
178 PROCESSORPATH("-processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER),
180 PARAMETERS("-parameters","opt.parameters", STANDARD, BASIC),
182 D("-d", "opt.arg.directory", "opt.d", STANDARD, FILEMANAGER),
184 S("-s", "opt.arg.directory", "opt.sourceDest", STANDARD, FILEMANAGER),
186 H("-h", "opt.arg.directory", "opt.headerDest", STANDARD, FILEMANAGER),
188 IMPLICIT("-implicit:", "opt.implicit", STANDARD, BASIC, ONEOF, "none", "class"),
190 ENCODING("-encoding", "opt.arg.encoding", "opt.encoding", STANDARD, FILEMANAGER) {
191 @Override
192 public boolean process(OptionHelper helper, String option, String operand) {
193 return super.process(helper, option, operand);
194 }
196 },
198 SOURCE("-source", "opt.arg.release", "opt.source", STANDARD, BASIC) {
199 @Override
200 public boolean process(OptionHelper helper, String option, String operand) {
201 Source source = Source.lookup(operand);
202 if (source == null) {
203 helper.error("err.invalid.source", operand);
204 return true;
205 }
206 return super.process(helper, option, operand);
207 }
208 },
210 TARGET("-target", "opt.arg.release", "opt.target", STANDARD, BASIC) {
211 @Override
212 public boolean process(OptionHelper helper, String option, String operand) {
213 Target target = Target.lookup(operand);
214 if (target == null) {
215 helper.error("err.invalid.target", operand);
216 return true;
217 }
218 return super.process(helper, option, operand);
219 }
220 },
222 PROFILE("-profile", "opt.arg.profile", "opt.profile", STANDARD, BASIC) {
223 @Override
224 public boolean process(OptionHelper helper, String option, String operand) {
225 Profile profile = Profile.lookup(operand);
226 if (profile == null) {
227 helper.error("err.invalid.profile", operand);
228 return true;
229 }
230 return super.process(helper, option, operand);
231 }
232 },
234 VERSION("-version", "opt.version", STANDARD, INFO) {
235 @Override
236 public boolean process(OptionHelper helper, String option) {
237 Log log = helper.getLog();
238 String ownName = helper.getOwnName();
239 log.printLines(PrefixKind.JAVAC, "version", ownName, JavaCompiler.version());
240 return super.process(helper, option);
241 }
242 },
244 FULLVERSION("-fullversion", null, HIDDEN, INFO) {
245 @Override
246 public boolean process(OptionHelper helper, String option) {
247 Log log = helper.getLog();
248 String ownName = helper.getOwnName();
249 log.printLines(PrefixKind.JAVAC, "fullVersion", ownName, JavaCompiler.fullVersion());
250 return super.process(helper, option);
251 }
252 },
254 DIAGS("-XDdiags=", null, HIDDEN, INFO) {
255 @Override
256 public boolean process(OptionHelper helper, String option) {
257 option = option.substring(option.indexOf('=') + 1);
258 String diagsOption = option.contains("%") ?
259 "-XDdiagsFormat=" :
260 "-XDdiags=";
261 diagsOption += option;
262 if (XD.matches(diagsOption))
263 return XD.process(helper, diagsOption);
264 else
265 return false;
266 }
267 },
269 HELP("-help", "opt.help", STANDARD, INFO) {
270 @Override
271 public boolean process(OptionHelper helper, String option) {
272 Log log = helper.getLog();
273 String ownName = helper.getOwnName();
274 log.printLines(PrefixKind.JAVAC, "msg.usage.header", ownName);
275 for (Option o: getJavaCompilerOptions()) {
276 o.help(log, OptionKind.STANDARD);
277 }
278 log.printNewline();
279 return super.process(helper, option);
280 }
281 },
283 A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC, true) {
284 @Override
285 public boolean matches(String arg) {
286 return arg.startsWith("-A");
287 }
289 @Override
290 public boolean hasArg() {
291 return false;
292 }
293 // Mapping for processor options created in
294 // JavacProcessingEnvironment
295 @Override
296 public boolean process(OptionHelper helper, String option) {
297 int argLength = option.length();
298 if (argLength == 2) {
299 helper.error("err.empty.A.argument");
300 return true;
301 }
302 int sepIndex = option.indexOf('=');
303 String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
304 if (!JavacProcessingEnvironment.isValidOptionName(key)) {
305 helper.error("err.invalid.A.key", option);
306 return true;
307 }
308 return process(helper, option, option);
309 }
310 },
312 X("-X", "opt.X", STANDARD, INFO) {
313 @Override
314 public boolean process(OptionHelper helper, String option) {
315 Log log = helper.getLog();
316 for (Option o: getJavaCompilerOptions()) {
317 o.help(log, OptionKind.EXTENDED);
318 }
319 log.printNewline();
320 log.printLines(PrefixKind.JAVAC, "msg.usage.nonstandard.footer");
321 return super.process(helper, option);
322 }
323 },
325 // This option exists only for the purpose of documenting itself.
326 // It's actually implemented by the launcher.
327 J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO, true) {
328 @Override
329 public boolean process(OptionHelper helper, String option) {
330 throw new AssertionError
331 ("the -J flag should be caught by the launcher.");
332 }
333 },
335 MOREINFO("-moreinfo", null, HIDDEN, BASIC) {
336 @Override
337 public boolean process(OptionHelper helper, String option) {
338 Type.moreInfo = true;
339 return super.process(helper, option);
340 }
341 },
343 // treat warnings as errors
344 WERROR("-Werror", "opt.Werror", STANDARD, BASIC),
346 // prompt after each error
347 // new Option("-prompt", "opt.prompt"),
348 PROMPT("-prompt", null, HIDDEN, BASIC),
350 // dump stack on error
351 DOE("-doe", null, HIDDEN, BASIC),
353 // output source after type erasure
354 PRINTSOURCE("-printsource", null, HIDDEN, BASIC),
356 // display warnings for generic unchecked operations
357 WARNUNCHECKED("-warnunchecked", null, HIDDEN, BASIC) {
358 @Override
359 public boolean process(OptionHelper helper, String option) {
360 helper.put("-Xlint:unchecked", option);
361 return false;
362 }
363 },
365 XMAXERRS("-Xmaxerrs", "opt.arg.number", "opt.maxerrs", EXTENDED, BASIC),
367 XMAXWARNS("-Xmaxwarns", "opt.arg.number", "opt.maxwarns", EXTENDED, BASIC),
369 XSTDOUT("-Xstdout", "opt.arg.file", "opt.Xstdout", EXTENDED, INFO) {
370 @Override
371 public boolean process(OptionHelper helper, String option, String arg) {
372 try {
373 Log log = helper.getLog();
374 // TODO: this file should be closed at the end of compilation
375 log.setWriters(new PrintWriter(new FileWriter(arg), true));
376 } catch (java.io.IOException e) {
377 helper.error("err.error.writing.file", arg, e);
378 return true;
379 }
380 return super.process(helper, option, arg);
381 }
382 },
384 XPRINT("-Xprint", "opt.print", EXTENDED, BASIC),
386 XPRINTROUNDS("-XprintRounds", "opt.printRounds", EXTENDED, BASIC),
388 XPRINTPROCESSORINFO("-XprintProcessorInfo", "opt.printProcessorInfo", EXTENDED, BASIC),
390 XPREFER("-Xprefer:", "opt.prefer", EXTENDED, BASIC, ONEOF, "source", "newer"),
392 XPKGINFO("-Xpkginfo:", "opt.pkginfo", EXTENDED, BASIC, ONEOF, "always", "legacy", "nonempty"),
394 /* -O is a no-op, accepted for backward compatibility. */
395 O("-O", null, HIDDEN, BASIC),
397 /* -Xjcov produces tables to support the code coverage tool jcov. */
398 XJCOV("-Xjcov", null, HIDDEN, BASIC),
400 PLUGIN("-Xplugin:", "opt.arg.plugin", "opt.plugin", EXTENDED, BASIC) {
401 @Override
402 public boolean process(OptionHelper helper, String option) {
403 String p = option.substring(option.indexOf(':') + 1);
404 String prev = helper.get(PLUGIN);
405 helper.put(PLUGIN.text, (prev == null) ? p : prev + '\0' + p.trim());
406 return false;
407 }
408 },
410 /* This is a back door to the compiler's option table.
411 * -XDx=y sets the option x to the value y.
412 * -XDx sets the option x to the value x.
413 */
414 XD("-XD", null, HIDDEN, BASIC) {
415 @Override
416 public boolean matches(String s) {
417 return s.startsWith(text);
418 }
419 @Override
420 public boolean process(OptionHelper helper, String option) {
421 option = option.substring(text.length());
422 int eq = option.indexOf('=');
423 String key = (eq < 0) ? option : option.substring(0, eq);
424 String value = (eq < 0) ? option : option.substring(eq+1);
425 helper.put(key, value);
426 return false;
427 }
428 },
430 // This option exists only for the purpose of documenting itself.
431 // It's actually implemented by the CommandLine class.
432 AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO, true) {
433 @Override
434 public boolean process(OptionHelper helper, String option) {
435 throw new AssertionError("the @ flag should be caught by CommandLine.");
436 }
437 },
439 /*
440 * TODO: With apt, the matches method accepts anything if
441 * -XclassAsDecls is used; code elsewhere does the lookup to
442 * see if the class name is both legal and found.
443 *
444 * In apt, the process method adds the candidate class file
445 * name to a separate list.
446 */
447 SOURCEFILE("sourcefile", null, HIDDEN, INFO) {
448 @Override
449 public boolean matches(String s) {
450 return s.endsWith(".java") // Java source file
451 || SourceVersion.isName(s); // Legal type name
452 }
453 @Override
454 public boolean process(OptionHelper helper, String option) {
455 if (option.endsWith(".java") ) {
456 File f = new File(option);
457 if (!f.exists()) {
458 helper.error("err.file.not.found", f);
459 return true;
460 }
461 if (!f.isFile()) {
462 helper.error("err.file.not.file", f);
463 return true;
464 }
465 helper.addFile(f);
466 } else {
467 helper.addClassName(option);
468 }
469 return false;
470 }
471 };
473 /** The kind of an Option. This is used by the -help and -X options. */
474 public enum OptionKind {
475 /** A standard option, documented by -help. */
476 STANDARD,
477 /** An extended option, documented by -X. */
478 EXTENDED,
479 /** A hidden option, not documented. */
480 HIDDEN,
481 }
483 /** The group for an Option. This determines the situations in which the
484 * option is applicable. */
485 enum OptionGroup {
486 /** A basic option, available for use on the command line or via the
487 * Compiler API. */
488 BASIC,
489 /** An option for javac's standard JavaFileManager. Other file managers
490 * may or may not support these options. */
491 FILEMANAGER,
492 /** A command-line option that requests information, such as -help. */
493 INFO,
494 /** A command-line "option" representing a file or class name. */
495 OPERAND
496 }
498 /** The kind of choice for "choice" options. */
499 enum ChoiceKind {
500 /** The expected value is exactly one of the set of choices. */
501 ONEOF,
502 /** The expected value is one of more of the set of choices. */
503 ANYOF
504 }
506 public final String text;
508 final OptionKind kind;
510 final OptionGroup group;
512 /** Documentation key for arguments.
513 */
514 final String argsNameKey;
516 /** Documentation key for description.
517 */
518 final String descrKey;
520 /** Suffix option (-foo=bar or -foo:bar)
521 */
522 final boolean hasSuffix;
524 /** The kind of choices for this option, if any.
525 */
526 final ChoiceKind choiceKind;
528 /** The choices for this option, if any, and whether or not the choices
529 * are hidden
530 */
531 final Map<String,Boolean> choices;
534 Option(String text, String descrKey,
535 OptionKind kind, OptionGroup group) {
536 this(text, null, descrKey, kind, group, null, null, false);
537 }
539 Option(String text, String argsNameKey, String descrKey,
540 OptionKind kind, OptionGroup group) {
541 this(text, argsNameKey, descrKey, kind, group, null, null, false);
542 }
544 Option(String text, String argsNameKey, String descrKey,
545 OptionKind kind, OptionGroup group, boolean doHasSuffix) {
546 this(text, argsNameKey, descrKey, kind, group, null, null, doHasSuffix);
547 }
549 Option(String text, String descrKey,
550 OptionKind kind, OptionGroup group,
551 ChoiceKind choiceKind, Map<String,Boolean> choices) {
552 this(text, null, descrKey, kind, group, choiceKind, choices, false);
553 }
555 Option(String text, String descrKey,
556 OptionKind kind, OptionGroup group,
557 ChoiceKind choiceKind, String... choices) {
558 this(text, null, descrKey, kind, group, choiceKind,
559 createChoices(choices), false);
560 }
561 // where
562 private static Map<String,Boolean> createChoices(String... choices) {
563 Map<String,Boolean> map = new LinkedHashMap<String,Boolean>();
564 for (String c: choices)
565 map.put(c, false);
566 return map;
567 }
569 private Option(String text, String argsNameKey, String descrKey,
570 OptionKind kind, OptionGroup group,
571 ChoiceKind choiceKind, Map<String,Boolean> choices,
572 boolean doHasSuffix) {
573 this.text = text;
574 this.argsNameKey = argsNameKey;
575 this.descrKey = descrKey;
576 this.kind = kind;
577 this.group = group;
578 this.choiceKind = choiceKind;
579 this.choices = choices;
580 char lastChar = text.charAt(text.length()-1);
581 this.hasSuffix = doHasSuffix || lastChar == ':' || lastChar == '=';
582 }
584 public String getText() {
585 return text;
586 }
588 public OptionKind getKind() {
589 return kind;
590 }
592 public boolean hasArg() {
593 return argsNameKey != null && !hasSuffix;
594 }
596 public boolean matches(String option) {
597 if (!hasSuffix)
598 return option.equals(text);
600 if (!option.startsWith(text))
601 return false;
603 if (choices != null) {
604 String arg = option.substring(text.length());
605 if (choiceKind == ChoiceKind.ONEOF)
606 return choices.keySet().contains(arg);
607 else {
608 for (String a: arg.split(",+")) {
609 if (!choices.keySet().contains(a))
610 return false;
611 }
612 }
613 }
615 return true;
616 }
618 public boolean process(OptionHelper helper, String option, String arg) {
619 if (choices != null) {
620 if (choiceKind == ChoiceKind.ONEOF) {
621 // some clients like to see just one of option+choice set
622 for (String s: choices.keySet())
623 helper.remove(option + s);
624 String opt = option + arg;
625 helper.put(opt, opt);
626 // some clients like to see option (without trailing ":")
627 // set to arg
628 String nm = option.substring(0, option.length() - 1);
629 helper.put(nm, arg);
630 } else {
631 // set option+word for each word in arg
632 for (String a: arg.split(",+")) {
633 String opt = option + a;
634 helper.put(opt, opt);
635 }
636 }
637 }
638 helper.put(option, arg);
639 return false;
640 }
642 public boolean process(OptionHelper helper, String option) {
643 if (hasSuffix)
644 return process(helper, text, option.substring(text.length()));
645 else
646 return process(helper, option, option);
647 }
649 void help(Log log, OptionKind kind) {
650 if (this.kind != kind)
651 return;
653 log.printRawLines(WriterKind.NOTICE,
654 String.format(" %-26s %s",
655 helpSynopsis(log),
656 log.localize(PrefixKind.JAVAC, descrKey)));
658 }
660 private String helpSynopsis(Log log) {
661 StringBuilder sb = new StringBuilder();
662 sb.append(text);
663 if (argsNameKey == null) {
664 if (choices != null) {
665 String sep = "{";
666 for (Map.Entry<String,Boolean> e: choices.entrySet()) {
667 if (!e.getValue()) {
668 sb.append(sep);
669 sb.append(e.getKey());
670 sep = ",";
671 }
672 }
673 sb.append("}");
674 }
675 } else {
676 if (!hasSuffix)
677 sb.append(" ");
678 sb.append(log.localize(PrefixKind.JAVAC, argsNameKey));
680 }
682 return sb.toString();
683 }
685 // For -XpkgInfo:value
686 public enum PkgInfo {
687 ALWAYS, LEGACY, NONEMPTY;
688 public static PkgInfo get(Options options) {
689 String v = options.get(XPKGINFO);
690 return (v == null
691 ? PkgInfo.LEGACY
692 : PkgInfo.valueOf(v.toUpperCase()));
693 }
694 }
696 private static Map<String,Boolean> getXLintChoices() {
697 Map<String,Boolean> choices = new LinkedHashMap<String,Boolean>();
698 choices.put("all", false);
699 for (Lint.LintCategory c : Lint.LintCategory.values())
700 choices.put(c.option, c.hidden);
701 for (Lint.LintCategory c : Lint.LintCategory.values())
702 choices.put("-" + c.option, c.hidden);
703 choices.put("none", false);
704 return choices;
705 }
707 static Set<Option> getJavaCompilerOptions() {
708 return EnumSet.allOf(Option.class);
709 }
711 public static Set<Option> getJavacFileManagerOptions() {
712 return getOptions(EnumSet.of(FILEMANAGER));
713 }
715 public static Set<Option> getJavacToolOptions() {
716 return getOptions(EnumSet.of(BASIC));
717 }
719 static Set<Option> getOptions(Set<OptionGroup> desired) {
720 Set<Option> options = EnumSet.noneOf(Option.class);
721 for (Option option : Option.values())
722 if (desired.contains(option.group))
723 options.add(option);
724 return Collections.unmodifiableSet(options);
725 }
727 }