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 */ 25 26 package com.sun.tools.javac.main; 27 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; 36 37 import javax.lang.model.SourceVersion; 38 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.*; 52 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), 67 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 }, 75 76 G_CUSTOM("-g:", "opt.g.lines.vars.source", 77 STANDARD, BASIC, ANYOF, "lines", "vars", "source"), 78 79 XLINT("-Xlint", "opt.Xlint", EXTENDED, BASIC), 80 81 XLINT_CUSTOM("-Xlint:", "opt.Xlint.suboptlist", 82 EXTENDED, BASIC, ANYOF, getXLintChoices()), 83 84 XDOCLINT("-Xdoclint", "opt.Xdoclint", EXTENDED, BASIC), 85 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 } 92 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 }, 101 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 }, 110 111 VERBOSE("-verbose", "opt.verbose", STANDARD, BASIC), 112 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 }, 121 122 CLASSPATH("-classpath", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER), 123 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 }, 130 131 SOURCEPATH("-sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER), 132 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 }, 141 142 XBOOTCLASSPATH_PREPEND("-Xbootclasspath/p:", "opt.arg.path", "opt.Xbootclasspath.p", EXTENDED, FILEMANAGER), 143 144 XBOOTCLASSPATH_APPEND("-Xbootclasspath/a:", "opt.arg.path", "opt.Xbootclasspath.a", EXTENDED, FILEMANAGER), 145 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 }, 154 155 EXTDIRS("-extdirs", "opt.arg.dirs", "opt.extdirs", STANDARD, FILEMANAGER), 156 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 }, 163 164 ENDORSEDDIRS("-endorseddirs", "opt.arg.dirs", "opt.endorseddirs", STANDARD, FILEMANAGER), 165 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 }, 172 173 PROC("-proc:", "opt.proc.none.only", STANDARD, BASIC, ONEOF, "none", "only"), 174 175 PROCESSOR("-processor", "opt.arg.class.list", "opt.processor", STANDARD, BASIC), 176 177 PROCESSORPATH("-processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER), 178 179 PARAMETERS("-parameters","opt.parameters", STANDARD, BASIC), 180 181 D("-d", "opt.arg.directory", "opt.d", STANDARD, FILEMANAGER), 182 183 S("-s", "opt.arg.directory", "opt.sourceDest", STANDARD, FILEMANAGER), 184 185 H("-h", "opt.arg.directory", "opt.headerDest", STANDARD, FILEMANAGER), 186 187 IMPLICIT("-implicit:", "opt.implicit", STANDARD, BASIC, ONEOF, "none", "class"), 188 189 ENCODING("-encoding", "opt.arg.encoding", "opt.encoding", STANDARD, FILEMANAGER) { 190 @Override 191 public boolean process(OptionHelper helper, String option, String operand) { 192 return super.process(helper, option, operand); 193 } 194 195 }, 196 197 SOURCE("-source", "opt.arg.release", "opt.source", STANDARD, BASIC) { 198 @Override 199 public boolean process(OptionHelper helper, String option, String operand) { 200 Source source = Source.lookup(operand); 201 if (source == null) { 202 helper.error("err.invalid.source", operand); 203 return true; 204 } 205 return super.process(helper, option, operand); 206 } 207 }, 208 209 TARGET("-target", "opt.arg.release", "opt.target", STANDARD, BASIC) { 210 @Override 211 public boolean process(OptionHelper helper, String option, String operand) { 212 Target target = Target.lookup(operand); 213 if (target == null) { 214 helper.error("err.invalid.target", operand); 215 return true; 216 } 217 return super.process(helper, option, operand); 218 } 219 }, 220 221 VERSION("-version", "opt.version", STANDARD, INFO) { 222 @Override 223 public boolean process(OptionHelper helper, String option) { 224 Log log = helper.getLog(); 225 String ownName = helper.getOwnName(); 226 log.printLines(PrefixKind.JAVAC, "version", ownName, JavaCompiler.version()); 227 return super.process(helper, option); 228 } 229 }, 230 231 FULLVERSION("-fullversion", null, HIDDEN, INFO) { 232 @Override 233 public boolean process(OptionHelper helper, String option) { 234 Log log = helper.getLog(); 235 String ownName = helper.getOwnName(); 236 log.printLines(PrefixKind.JAVAC, "fullVersion", ownName, JavaCompiler.fullVersion()); 237 return super.process(helper, option); 238 } 239 }, 240 241 DIAGS("-XDdiags=", null, HIDDEN, INFO) { 242 @Override 243 public boolean process(OptionHelper helper, String option) { 244 option = option.substring(option.indexOf('=') + 1); 245 String diagsOption = option.contains("%") ? 246 "-XDdiagsFormat=" : 247 "-XDdiags="; 248 diagsOption += option; 249 if (XD.matches(diagsOption)) 250 return XD.process(helper, diagsOption); 251 else 252 return false; 253 } 254 }, 255 256 HELP("-help", "opt.help", STANDARD, INFO) { 257 @Override 258 public boolean process(OptionHelper helper, String option) { 259 Log log = helper.getLog(); 260 String ownName = helper.getOwnName(); 261 log.printLines(PrefixKind.JAVAC, "msg.usage.header", ownName); 262 for (Option o: getJavaCompilerOptions()) { 263 o.help(log, OptionKind.STANDARD); 264 } 265 log.printNewline(); 266 return super.process(helper, option); 267 } 268 }, 269 270 A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC, true) { 271 @Override 272 public boolean matches(String arg) { 273 return arg.startsWith("-A"); 274 } 275 276 @Override 277 public boolean hasArg() { 278 return false; 279 } 280 // Mapping for processor options created in 281 // JavacProcessingEnvironment 282 @Override 283 public boolean process(OptionHelper helper, String option) { 284 int argLength = option.length(); 285 if (argLength == 2) { 286 helper.error("err.empty.A.argument"); 287 return true; 288 } 289 int sepIndex = option.indexOf('='); 290 String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) ); 291 if (!JavacProcessingEnvironment.isValidOptionName(key)) { 292 helper.error("err.invalid.A.key", option); 293 return true; 294 } 295 return process(helper, option, option); 296 } 297 }, 298 299 X("-X", "opt.X", STANDARD, INFO) { 300 @Override 301 public boolean process(OptionHelper helper, String option) { 302 Log log = helper.getLog(); 303 for (Option o: getJavaCompilerOptions()) { 304 o.help(log, OptionKind.EXTENDED); 305 } 306 log.printNewline(); 307 log.printLines(PrefixKind.JAVAC, "msg.usage.nonstandard.footer"); 308 return super.process(helper, option); 309 } 310 }, 311 312 // This option exists only for the purpose of documenting itself. 313 // It's actually implemented by the launcher. 314 J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO, true) { 315 @Override 316 public boolean process(OptionHelper helper, String option) { 317 throw new AssertionError 318 ("the -J flag should be caught by the launcher."); 319 } 320 }, 321 322 MOREINFO("-moreinfo", null, HIDDEN, BASIC) { 323 @Override 324 public boolean process(OptionHelper helper, String option) { 325 Type.moreInfo = true; 326 return super.process(helper, option); 327 } 328 }, 329 330 // treat warnings as errors 331 WERROR("-Werror", "opt.Werror", STANDARD, BASIC), 332 333 // prompt after each error 334 // new Option("-prompt", "opt.prompt"), 335 PROMPT("-prompt", null, HIDDEN, BASIC), 336 337 // dump stack on error 338 DOE("-doe", null, HIDDEN, BASIC), 339 340 // output source after type erasure 341 PRINTSOURCE("-printsource", null, HIDDEN, BASIC), 342 343 // display warnings for generic unchecked operations 344 WARNUNCHECKED("-warnunchecked", null, HIDDEN, BASIC) { 345 @Override 346 public boolean process(OptionHelper helper, String option) { 347 helper.put("-Xlint:unchecked", option); 348 return false; 349 } 350 }, 351 352 XMAXERRS("-Xmaxerrs", "opt.arg.number", "opt.maxerrs", EXTENDED, BASIC), 353 354 XMAXWARNS("-Xmaxwarns", "opt.arg.number", "opt.maxwarns", EXTENDED, BASIC), 355 356 XSTDOUT("-Xstdout", "opt.arg.file", "opt.Xstdout", EXTENDED, INFO) { 357 @Override 358 public boolean process(OptionHelper helper, String option, String arg) { 359 try { 360 Log log = helper.getLog(); 361 // TODO: this file should be closed at the end of compilation 362 log.setWriters(new PrintWriter(new FileWriter(arg), true)); 363 } catch (java.io.IOException e) { 364 helper.error("err.error.writing.file", arg, e); 365 return true; 366 } 367 return super.process(helper, option, arg); 368 } 369 }, 370 371 XPRINT("-Xprint", "opt.print", EXTENDED, BASIC), 372 373 XPRINTROUNDS("-XprintRounds", "opt.printRounds", EXTENDED, BASIC), 374 375 XPRINTPROCESSORINFO("-XprintProcessorInfo", "opt.printProcessorInfo", EXTENDED, BASIC), 376 377 XPREFER("-Xprefer:", "opt.prefer", EXTENDED, BASIC, ONEOF, "source", "newer"), 378 379 XPKGINFO("-Xpkginfo:", "opt.pkginfo", EXTENDED, BASIC, ONEOF, "always", "legacy", "nonempty"), 380 381 /* -O is a no-op, accepted for backward compatibility. */ 382 O("-O", null, HIDDEN, BASIC), 383 384 /* -Xjcov produces tables to support the code coverage tool jcov. */ 385 XJCOV("-Xjcov", null, HIDDEN, BASIC), 386 387 PLUGIN("-Xplugin:", "opt.arg.plugin", "opt.plugin", EXTENDED, BASIC) { 388 @Override 389 public boolean process(OptionHelper helper, String option) { 390 String p = option.substring(option.indexOf(':') + 1); 391 String prev = helper.get(PLUGIN); 392 helper.put(PLUGIN.text, (prev == null) ? p : prev + '\0' + p.trim()); 393 return false; 394 } 395 }, 396 397 /* This is a back door to the compiler's option table. 398 * -XDx=y sets the option x to the value y. 399 * -XDx sets the option x to the value x. 400 */ 401 XD("-XD", null, HIDDEN, BASIC) { 402 @Override 403 public boolean matches(String s) { 404 return s.startsWith(text); 405 } 406 @Override 407 public boolean process(OptionHelper helper, String option) { 408 option = option.substring(text.length()); 409 int eq = option.indexOf('='); 410 String key = (eq < 0) ? option : option.substring(0, eq); 411 String value = (eq < 0) ? option : option.substring(eq+1); 412 helper.put(key, value); 413 return false; 414 } 415 }, 416 417 // This option exists only for the purpose of documenting itself. 418 // It's actually implemented by the CommandLine class. 419 AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO, true) { 420 @Override 421 public boolean process(OptionHelper helper, String option) { 422 throw new AssertionError("the @ flag should be caught by CommandLine."); 423 } 424 }, 425 426 /* 427 * TODO: With apt, the matches method accepts anything if 428 * -XclassAsDecls is used; code elsewhere does the lookup to 429 * see if the class name is both legal and found. 430 * 431 * In apt, the process method adds the candidate class file 432 * name to a separate list. 433 */ 434 SOURCEFILE("sourcefile", null, HIDDEN, INFO) { 435 @Override 436 public boolean matches(String s) { 437 return s.endsWith(".java") // Java source file 438 || SourceVersion.isName(s); // Legal type name 439 } 440 @Override 441 public boolean process(OptionHelper helper, String option) { 442 if (option.endsWith(".java") ) { 443 File f = new File(option); 444 if (!f.exists()) { 445 helper.error("err.file.not.found", f); 446 return true; 447 } 448 if (!f.isFile()) { 449 helper.error("err.file.not.file", f); 450 return true; 451 } 452 helper.addFile(f); 453 } else { 454 helper.addClassName(option); 455 } 456 return false; 457 } 458 }; 459 460 /** The kind of an Option. This is used by the -help and -X options. */ 461 public enum OptionKind { 462 /** A standard option, documented by -help. */ 463 STANDARD, 464 /** An extended option, documented by -X. */ 465 EXTENDED, 466 /** A hidden option, not documented. */ 467 HIDDEN, 468 } 469 470 /** The group for an Option. This determines the situations in which the 471 * option is applicable. */ 472 enum OptionGroup { 473 /** A basic option, available for use on the command line or via the 474 * Compiler API. */ 475 BASIC, 476 /** An option for javac's standard JavaFileManager. Other file managers 477 * may or may not support these options. */ 478 FILEMANAGER, 479 /** A command-line option that requests information, such as -help. */ 480 INFO, 481 /** A command-line "option" representing a file or class name. */ 482 OPERAND 483 } 484 485 /** The kind of choice for "choice" options. */ 486 enum ChoiceKind { 487 /** The expected value is exactly one of the set of choices. */ 488 ONEOF, 489 /** The expected value is one of more of the set of choices. */ 490 ANYOF 491 } 492 493 public final String text; 494 495 final OptionKind kind; 496 497 final OptionGroup group; 498 499 /** Documentation key for arguments. 500 */ 501 final String argsNameKey; 502 503 /** Documentation key for description. 504 */ 505 final String descrKey; 506 507 /** Suffix option (-foo=bar or -foo:bar) 508 */ 509 final boolean hasSuffix; 510 511 /** The kind of choices for this option, if any. 512 */ 513 final ChoiceKind choiceKind; 514 515 /** The choices for this option, if any, and whether or not the choices 516 * are hidden 517 */ 518 final Map<String,Boolean> choices; 519 520 521 Option(String text, String descrKey, 522 OptionKind kind, OptionGroup group) { 523 this(text, null, descrKey, kind, group, null, null, false); 524 } 525 526 Option(String text, String argsNameKey, String descrKey, 527 OptionKind kind, OptionGroup group) { 528 this(text, argsNameKey, descrKey, kind, group, null, null, false); 529 } 530 531 Option(String text, String argsNameKey, String descrKey, 532 OptionKind kind, OptionGroup group, boolean doHasSuffix) { 533 this(text, argsNameKey, descrKey, kind, group, null, null, doHasSuffix); 534 } 535 536 Option(String text, String descrKey, 537 OptionKind kind, OptionGroup group, 538 ChoiceKind choiceKind, Map<String,Boolean> choices) { 539 this(text, null, descrKey, kind, group, choiceKind, choices, false); 540 } 541 542 Option(String text, String descrKey, 543 OptionKind kind, OptionGroup group, 544 ChoiceKind choiceKind, String... choices) { 545 this(text, null, descrKey, kind, group, choiceKind, 546 createChoices(choices), false); 547 } 548 // where 549 private static Map<String,Boolean> createChoices(String... choices) { 550 Map<String,Boolean> map = new LinkedHashMap<String,Boolean>(); 551 for (String c: choices) 552 map.put(c, false); 553 return map; 554 } 555 556 private Option(String text, String argsNameKey, String descrKey, 557 OptionKind kind, OptionGroup group, 558 ChoiceKind choiceKind, Map<String,Boolean> choices, 559 boolean doHasSuffix) { 560 this.text = text; 561 this.argsNameKey = argsNameKey; 562 this.descrKey = descrKey; 563 this.kind = kind; 564 this.group = group; 565 this.choiceKind = choiceKind; 566 this.choices = choices; 567 char lastChar = text.charAt(text.length()-1); 568 this.hasSuffix = doHasSuffix || lastChar == ':' || lastChar == '='; 569 } 570 571 public String getText() { 572 return text; 573 } 574 575 public OptionKind getKind() { 576 return kind; 577 } 578 579 public boolean hasArg() { 580 return argsNameKey != null && !hasSuffix; 581 } 582 583 public boolean matches(String option) { 584 if (!hasSuffix) 585 return option.equals(text); 586 587 if (!option.startsWith(text)) 588 return false; 589 590 if (choices != null) { 591 String arg = option.substring(text.length()); 592 if (choiceKind == ChoiceKind.ONEOF) 593 return choices.keySet().contains(arg); 594 else { 595 for (String a: arg.split(",+")) { 596 if (!choices.keySet().contains(a)) 597 return false; 598 } 599 } 600 } 601 602 return true; 603 } 604 605 public boolean process(OptionHelper helper, String option, String arg) { 606 if (choices != null) { 607 if (choiceKind == ChoiceKind.ONEOF) { 608 // some clients like to see just one of option+choice set 609 for (String s: choices.keySet()) 610 helper.remove(option + s); 611 String opt = option + arg; 612 helper.put(opt, opt); 613 // some clients like to see option (without trailing ":") 614 // set to arg 615 String nm = option.substring(0, option.length() - 1); 616 helper.put(nm, arg); 617 } else { 618 // set option+word for each word in arg 619 for (String a: arg.split(",+")) { 620 String opt = option + a; 621 helper.put(opt, opt); 622 } 623 } 624 } 625 helper.put(option, arg); 626 return false; 627 } 628 629 public boolean process(OptionHelper helper, String option) { 630 if (hasSuffix) 631 return process(helper, text, option.substring(text.length())); 632 else 633 return process(helper, option, option); 634 } 635 636 void help(Log log, OptionKind kind) { 637 if (this.kind != kind) 638 return; 639 640 log.printRawLines(WriterKind.NOTICE, 641 String.format(" %-26s %s", 642 helpSynopsis(log), 643 log.localize(PrefixKind.JAVAC, descrKey))); 644 645 } 646 647 private String helpSynopsis(Log log) { 648 StringBuilder sb = new StringBuilder(); 649 sb.append(text); 650 if (argsNameKey == null) { 651 if (choices != null) { 652 String sep = "{"; 653 for (Map.Entry<String,Boolean> e: choices.entrySet()) { 654 if (!e.getValue()) { 655 sb.append(sep); 656 sb.append(e.getKey()); 657 sep = ","; 658 } 659 } 660 sb.append("}"); 661 } 662 } else { 663 if (!hasSuffix) 664 sb.append(" "); 665 sb.append(log.localize(PrefixKind.JAVAC, argsNameKey)); 666 667 } 668 669 return sb.toString(); 670 } 671 672 // For -XpkgInfo:value 673 public enum PkgInfo { 674 ALWAYS, LEGACY, NONEMPTY; 675 public static PkgInfo get(Options options) { 676 String v = options.get(XPKGINFO); 677 return (v == null 678 ? PkgInfo.LEGACY 679 : PkgInfo.valueOf(v.toUpperCase())); 680 } 681 } 682 683 private static Map<String,Boolean> getXLintChoices() { 684 Map<String,Boolean> choices = new LinkedHashMap<String,Boolean>(); 685 choices.put("all", false); 686 for (Lint.LintCategory c : Lint.LintCategory.values()) 687 choices.put(c.option, c.hidden); 688 for (Lint.LintCategory c : Lint.LintCategory.values()) 689 choices.put("-" + c.option, c.hidden); 690 choices.put("none", false); 691 return choices; 692 } 693 694 static Set<Option> getJavaCompilerOptions() { 695 return EnumSet.allOf(Option.class); 696 } 697 698 public static Set<Option> getJavacFileManagerOptions() { 699 return getOptions(EnumSet.of(FILEMANAGER)); 700 } 701 702 public static Set<Option> getJavacToolOptions() { 703 return getOptions(EnumSet.of(BASIC)); 704 } 705 706 static Set<Option> getOptions(Set<OptionGroup> desired) { 707 Set<Option> options = EnumSet.noneOf(Option.class); 708 for (Option option : Option.values()) 709 if (desired.contains(option.group)) 710 options.add(option); 711 return Collections.unmodifiableSet(options); 712 } 713 714 }