Tue, 27 Aug 2013 11:58:53 -0700
8023826: Typo in warning about obsolete source / target values
Reviewed-by: jjg, wmdietl
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 XDIAGS("-Xdiags:", "opt.diags", EXTENDED, BASIC, ONEOF, "compact", "verbose"),
412 /* This is a back door to the compiler's option table.
413 * -XDx=y sets the option x to the value y.
414 * -XDx sets the option x to the value x.
415 */
416 XD("-XD", null, HIDDEN, BASIC) {
417 @Override
418 public boolean matches(String s) {
419 return s.startsWith(text);
420 }
421 @Override
422 public boolean process(OptionHelper helper, String option) {
423 option = option.substring(text.length());
424 int eq = option.indexOf('=');
425 String key = (eq < 0) ? option : option.substring(0, eq);
426 String value = (eq < 0) ? option : option.substring(eq+1);
427 helper.put(key, value);
428 return false;
429 }
430 },
432 // This option exists only for the purpose of documenting itself.
433 // It's actually implemented by the CommandLine class.
434 AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO, true) {
435 @Override
436 public boolean process(OptionHelper helper, String option) {
437 throw new AssertionError("the @ flag should be caught by CommandLine.");
438 }
439 },
441 /*
442 * TODO: With apt, the matches method accepts anything if
443 * -XclassAsDecls is used; code elsewhere does the lookup to
444 * see if the class name is both legal and found.
445 *
446 * In apt, the process method adds the candidate class file
447 * name to a separate list.
448 */
449 SOURCEFILE("sourcefile", null, HIDDEN, INFO) {
450 @Override
451 public boolean matches(String s) {
452 return s.endsWith(".java") // Java source file
453 || SourceVersion.isName(s); // Legal type name
454 }
455 @Override
456 public boolean process(OptionHelper helper, String option) {
457 if (option.endsWith(".java") ) {
458 File f = new File(option);
459 if (!f.exists()) {
460 helper.error("err.file.not.found", f);
461 return true;
462 }
463 if (!f.isFile()) {
464 helper.error("err.file.not.file", f);
465 return true;
466 }
467 helper.addFile(f);
468 } else {
469 helper.addClassName(option);
470 }
471 return false;
472 }
473 };
475 /** The kind of an Option. This is used by the -help and -X options. */
476 public enum OptionKind {
477 /** A standard option, documented by -help. */
478 STANDARD,
479 /** An extended option, documented by -X. */
480 EXTENDED,
481 /** A hidden option, not documented. */
482 HIDDEN,
483 }
485 /** The group for an Option. This determines the situations in which the
486 * option is applicable. */
487 enum OptionGroup {
488 /** A basic option, available for use on the command line or via the
489 * Compiler API. */
490 BASIC,
491 /** An option for javac's standard JavaFileManager. Other file managers
492 * may or may not support these options. */
493 FILEMANAGER,
494 /** A command-line option that requests information, such as -help. */
495 INFO,
496 /** A command-line "option" representing a file or class name. */
497 OPERAND
498 }
500 /** The kind of choice for "choice" options. */
501 enum ChoiceKind {
502 /** The expected value is exactly one of the set of choices. */
503 ONEOF,
504 /** The expected value is one of more of the set of choices. */
505 ANYOF
506 }
508 public final String text;
510 final OptionKind kind;
512 final OptionGroup group;
514 /** Documentation key for arguments.
515 */
516 final String argsNameKey;
518 /** Documentation key for description.
519 */
520 final String descrKey;
522 /** Suffix option (-foo=bar or -foo:bar)
523 */
524 final boolean hasSuffix;
526 /** The kind of choices for this option, if any.
527 */
528 final ChoiceKind choiceKind;
530 /** The choices for this option, if any, and whether or not the choices
531 * are hidden
532 */
533 final Map<String,Boolean> choices;
536 Option(String text, String descrKey,
537 OptionKind kind, OptionGroup group) {
538 this(text, null, descrKey, kind, group, null, null, false);
539 }
541 Option(String text, String argsNameKey, String descrKey,
542 OptionKind kind, OptionGroup group) {
543 this(text, argsNameKey, descrKey, kind, group, null, null, false);
544 }
546 Option(String text, String argsNameKey, String descrKey,
547 OptionKind kind, OptionGroup group, boolean doHasSuffix) {
548 this(text, argsNameKey, descrKey, kind, group, null, null, doHasSuffix);
549 }
551 Option(String text, String descrKey,
552 OptionKind kind, OptionGroup group,
553 ChoiceKind choiceKind, Map<String,Boolean> choices) {
554 this(text, null, descrKey, kind, group, choiceKind, choices, false);
555 }
557 Option(String text, String descrKey,
558 OptionKind kind, OptionGroup group,
559 ChoiceKind choiceKind, String... choices) {
560 this(text, null, descrKey, kind, group, choiceKind,
561 createChoices(choices), false);
562 }
563 // where
564 private static Map<String,Boolean> createChoices(String... choices) {
565 Map<String,Boolean> map = new LinkedHashMap<String,Boolean>();
566 for (String c: choices)
567 map.put(c, false);
568 return map;
569 }
571 private Option(String text, String argsNameKey, String descrKey,
572 OptionKind kind, OptionGroup group,
573 ChoiceKind choiceKind, Map<String,Boolean> choices,
574 boolean doHasSuffix) {
575 this.text = text;
576 this.argsNameKey = argsNameKey;
577 this.descrKey = descrKey;
578 this.kind = kind;
579 this.group = group;
580 this.choiceKind = choiceKind;
581 this.choices = choices;
582 char lastChar = text.charAt(text.length()-1);
583 this.hasSuffix = doHasSuffix || lastChar == ':' || lastChar == '=';
584 }
586 public String getText() {
587 return text;
588 }
590 public OptionKind getKind() {
591 return kind;
592 }
594 public boolean hasArg() {
595 return argsNameKey != null && !hasSuffix;
596 }
598 public boolean matches(String option) {
599 if (!hasSuffix)
600 return option.equals(text);
602 if (!option.startsWith(text))
603 return false;
605 if (choices != null) {
606 String arg = option.substring(text.length());
607 if (choiceKind == ChoiceKind.ONEOF)
608 return choices.keySet().contains(arg);
609 else {
610 for (String a: arg.split(",+")) {
611 if (!choices.keySet().contains(a))
612 return false;
613 }
614 }
615 }
617 return true;
618 }
620 public boolean process(OptionHelper helper, String option, String arg) {
621 if (choices != null) {
622 if (choiceKind == ChoiceKind.ONEOF) {
623 // some clients like to see just one of option+choice set
624 for (String s: choices.keySet())
625 helper.remove(option + s);
626 String opt = option + arg;
627 helper.put(opt, opt);
628 // some clients like to see option (without trailing ":")
629 // set to arg
630 String nm = option.substring(0, option.length() - 1);
631 helper.put(nm, arg);
632 } else {
633 // set option+word for each word in arg
634 for (String a: arg.split(",+")) {
635 String opt = option + a;
636 helper.put(opt, opt);
637 }
638 }
639 }
640 helper.put(option, arg);
641 return false;
642 }
644 public boolean process(OptionHelper helper, String option) {
645 if (hasSuffix)
646 return process(helper, text, option.substring(text.length()));
647 else
648 return process(helper, option, option);
649 }
651 void help(Log log, OptionKind kind) {
652 if (this.kind != kind)
653 return;
655 log.printRawLines(WriterKind.NOTICE,
656 String.format(" %-26s %s",
657 helpSynopsis(log),
658 log.localize(PrefixKind.JAVAC, descrKey)));
660 }
662 private String helpSynopsis(Log log) {
663 StringBuilder sb = new StringBuilder();
664 sb.append(text);
665 if (argsNameKey == null) {
666 if (choices != null) {
667 String sep = "{";
668 for (Map.Entry<String,Boolean> e: choices.entrySet()) {
669 if (!e.getValue()) {
670 sb.append(sep);
671 sb.append(e.getKey());
672 sep = ",";
673 }
674 }
675 sb.append("}");
676 }
677 } else {
678 if (!hasSuffix)
679 sb.append(" ");
680 sb.append(log.localize(PrefixKind.JAVAC, argsNameKey));
682 }
684 return sb.toString();
685 }
687 // For -XpkgInfo:value
688 public enum PkgInfo {
689 ALWAYS, LEGACY, NONEMPTY;
690 public static PkgInfo get(Options options) {
691 String v = options.get(XPKGINFO);
692 return (v == null
693 ? PkgInfo.LEGACY
694 : PkgInfo.valueOf(v.toUpperCase()));
695 }
696 }
698 private static Map<String,Boolean> getXLintChoices() {
699 Map<String,Boolean> choices = new LinkedHashMap<String,Boolean>();
700 choices.put("all", false);
701 for (Lint.LintCategory c : Lint.LintCategory.values())
702 choices.put(c.option, c.hidden);
703 for (Lint.LintCategory c : Lint.LintCategory.values())
704 choices.put("-" + c.option, c.hidden);
705 choices.put("none", false);
706 return choices;
707 }
709 static Set<Option> getJavaCompilerOptions() {
710 return EnumSet.allOf(Option.class);
711 }
713 public static Set<Option> getJavacFileManagerOptions() {
714 return getOptions(EnumSet.of(FILEMANAGER));
715 }
717 public static Set<Option> getJavacToolOptions() {
718 return getOptions(EnumSet.of(BASIC));
719 }
721 static Set<Option> getOptions(Set<OptionGroup> desired) {
722 Set<Option> options = EnumSet.noneOf(Option.class);
723 for (Option option : Option.values())
724 if (desired.contains(option.group))
725 options.add(option);
726 return Collections.unmodifiableSet(options);
727 }
729 }