518 } |
518 } |
519 }, |
519 }, |
520 |
520 |
521 XDIAGS("-Xdiags:", "opt.diags", EXTENDED, BASIC, ONEOF, "compact", "verbose"), |
521 XDIAGS("-Xdiags:", "opt.diags", EXTENDED, BASIC, ONEOF, "compact", "verbose"), |
522 |
522 |
523 DEBUG("--debug:", null, HIDDEN, BASIC) { |
523 DEBUG("--debug", null, HIDDEN, BASIC, ArgKind.REQUIRED) { |
524 @Override |
524 @Override |
525 public void process(OptionHelper helper, String option) throws InvalidValueException { |
525 public void process(OptionHelper helper, String option, String arg) throws InvalidValueException { |
526 HiddenGroup.DEBUG.process(helper, option); |
526 HiddenGroup.DEBUG.process(helper, option, arg); |
527 } |
527 } |
528 }, |
528 }, |
529 |
529 |
530 SHOULDSTOP("--should-stop:", null, HIDDEN, BASIC) { |
530 SHOULDSTOP("--should-stop", null, HIDDEN, BASIC, ArgKind.REQUIRED) { |
531 @Override |
531 @Override |
532 public void process(OptionHelper helper, String option) throws InvalidValueException { |
532 public void process(OptionHelper helper, String option, String arg) throws InvalidValueException { |
533 HiddenGroup.SHOULDSTOP.process(helper, option); |
533 HiddenGroup.SHOULDSTOP.process(helper, option, arg); |
534 } |
534 } |
535 }, |
535 }, |
536 |
536 |
537 DIAGS("--diags:", null, HIDDEN, BASIC) { |
537 DIAGS("--diags", null, HIDDEN, BASIC, ArgKind.REQUIRED) { |
538 @Override |
538 @Override |
539 public void process(OptionHelper helper, String option) throws InvalidValueException { |
539 public void process(OptionHelper helper, String option, String arg) throws InvalidValueException { |
540 HiddenGroup.DIAGS.process(helper, option); |
540 HiddenGroup.DIAGS.process(helper, option, arg); |
541 } |
541 } |
542 }, |
542 }, |
543 |
543 |
544 /* This is a back door to the compiler's option table. |
544 /* This is a back door to the compiler's option table. |
545 * -XDx=y sets the option x to the value y. |
545 * -XDx=y sets the option x to the value y. |
844 enum HiddenGroup { |
844 enum HiddenGroup { |
845 DIAGS("diags"), |
845 DIAGS("diags"), |
846 DEBUG("debug"), |
846 DEBUG("debug"), |
847 SHOULDSTOP("should-stop"); |
847 SHOULDSTOP("should-stop"); |
848 |
848 |
849 static final Set<String> skipSet = new java.util.HashSet<>( |
|
850 Arrays.asList("--diags:", "--debug:", "--should-stop:")); |
|
851 |
|
852 final String text; |
849 final String text; |
853 |
850 |
854 HiddenGroup(String text) { |
851 HiddenGroup(String text) { |
855 this.text = text; |
852 this.text = text; |
856 } |
853 } |
857 |
854 |
858 public void process(OptionHelper helper, String option) throws InvalidValueException { |
855 public void process(OptionHelper helper, String option, String arg) throws InvalidValueException { |
859 String p = option.substring(option.indexOf(':') + 1).trim(); |
856 String[] subOptions = arg.split(";"); |
860 String[] subOptions = p.split(";"); |
|
861 for (String subOption : subOptions) { |
857 for (String subOption : subOptions) { |
862 subOption = text + "." + subOption.trim(); |
858 subOption = text + "." + subOption.trim(); |
863 XD.process(helper, subOption, subOption); |
859 XD.process(helper, subOption, subOption); |
864 } |
860 } |
865 } |
|
866 |
|
867 static boolean skip(String name) { |
|
868 return skipSet.contains(name); |
|
869 } |
861 } |
870 } |
862 } |
871 |
863 |
872 /** |
864 /** |
873 * The "primary name" for this option. |
865 * The "primary name" for this option. |
953 } |
945 } |
954 |
946 |
955 Option(String text, String descrKey, |
947 Option(String text, String descrKey, |
956 OptionKind kind, OptionGroup group) { |
948 OptionKind kind, OptionGroup group) { |
957 this(text, null, descrKey, kind, group, null, null, ArgKind.NONE); |
949 this(text, null, descrKey, kind, group, null, null, ArgKind.NONE); |
|
950 } |
|
951 |
|
952 Option(String text, String descrKey, |
|
953 OptionKind kind, OptionGroup group, ArgKind argKind) { |
|
954 this(text, null, descrKey, kind, group, null, null, argKind); |
958 } |
955 } |
959 |
956 |
960 Option(String text, String argsNameKey, String descrKey, |
957 Option(String text, String argsNameKey, String descrKey, |
961 OptionKind kind, OptionGroup group) { |
958 OptionKind kind, OptionGroup group) { |
962 this(text, argsNameKey, descrKey, kind, group, null, null, ArgKind.REQUIRED); |
959 this(text, argsNameKey, descrKey, kind, group, null, null, ArgKind.REQUIRED); |
1023 } |
1020 } |
1024 return false; |
1021 return false; |
1025 } |
1022 } |
1026 |
1023 |
1027 private boolean matches(String option, String name) { |
1024 private boolean matches(String option, String name) { |
1028 if (name.startsWith("--") && !HiddenGroup.skip(name)) { |
1025 if (name.startsWith("--")) { |
1029 return option.equals(name) |
1026 return option.equals(name) |
1030 || hasArg() && option.startsWith(name + "="); |
1027 || hasArg() && option.startsWith(name + "="); |
1031 } |
1028 } |
1032 |
1029 |
1033 boolean hasSuffix = (argKind == ArgKind.ADJACENT) |
1030 boolean hasSuffix = (argKind == ArgKind.ADJACENT) |