src/share/classes/com/sun/tools/javac/main/JavacOption.java

changeset 377
d9febdd5ae21
parent 54
eaf608c64fec
child 438
2ebae181a4ab
     1.1 --- a/src/share/classes/com/sun/tools/javac/main/JavacOption.java	Fri Aug 21 11:25:45 2009 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/main/JavacOption.java	Fri Aug 21 14:58:21 2009 -0700
     1.3 @@ -25,11 +25,11 @@
     1.4  
     1.5  package com.sun.tools.javac.main;
     1.6  
     1.7 +import java.io.PrintWriter;
     1.8 +import java.util.LinkedHashMap;
     1.9 +import java.util.Map;
    1.10  import com.sun.tools.javac.util.Log;
    1.11  import com.sun.tools.javac.util.Options;
    1.12 -import java.io.PrintWriter;
    1.13 -import java.util.Arrays;
    1.14 -import java.util.Collection;
    1.15  
    1.16  /**
    1.17   * TODO: describe com.sun.tools.javac.main.JavacOption
    1.18 @@ -106,9 +106,10 @@
    1.19           */
    1.20          ChoiceKind choiceKind;
    1.21  
    1.22 -        /** The choices for this option, if any.
    1.23 +        /** The choices for this option, if any, and whether or not the choices
    1.24 +         *  are hidden
    1.25           */
    1.26 -        Collection<String> choices;
    1.27 +        Map<String,Boolean> choices;
    1.28  
    1.29          Option(OptionName name, String argsNameKey, String descrKey) {
    1.30              this.name = name;
    1.31 @@ -123,10 +124,18 @@
    1.32          }
    1.33  
    1.34          Option(OptionName name, String descrKey, ChoiceKind choiceKind, String... choices) {
    1.35 -            this(name, descrKey, choiceKind, Arrays.asList(choices));
    1.36 +            this(name, descrKey, choiceKind, createChoices(choices));
    1.37          }
    1.38  
    1.39 -        Option(OptionName name, String descrKey, ChoiceKind choiceKind, Collection<String> choices) {
    1.40 +        private static Map<String,Boolean> createChoices(String... choices) {
    1.41 +            Map<String,Boolean> map = new LinkedHashMap<String,Boolean>();
    1.42 +            for (String c: choices)
    1.43 +                map.put(c, true);
    1.44 +            return map;
    1.45 +        }
    1.46 +
    1.47 +        Option(OptionName name, String descrKey, ChoiceKind choiceKind,
    1.48 +                Map<String,Boolean> choices) {
    1.49              this(name, null, descrKey);
    1.50              if (choiceKind == null || choices == null)
    1.51                  throw new NullPointerException();
    1.52 @@ -153,10 +162,10 @@
    1.53              if (choices != null) {
    1.54                  String arg = option.substring(name.optionName.length());
    1.55                  if (choiceKind == ChoiceKind.ONEOF)
    1.56 -                    return choices.contains(arg);
    1.57 +                    return choices.keySet().contains(arg);
    1.58                  else {
    1.59                      for (String a: arg.split(",+")) {
    1.60 -                        if (!choices.contains(a))
    1.61 +                        if (!choices.keySet().contains(a))
    1.62                              return false;
    1.63                      }
    1.64                  }
    1.65 @@ -181,10 +190,12 @@
    1.66              if (argsNameKey == null) {
    1.67                  if (choices != null) {
    1.68                      String sep = "{";
    1.69 -                    for (String c: choices) {
    1.70 -                        sb.append(sep);
    1.71 -                        sb.append(c);
    1.72 -                        sep = ",";
    1.73 +                    for (Map.Entry<String,Boolean> e: choices.entrySet()) {
    1.74 +                        if (!e.getValue()) {
    1.75 +                            sb.append(sep);
    1.76 +                            sb.append(e.getKey());
    1.77 +                            sep = ",";
    1.78 +                        }
    1.79                      }
    1.80                      sb.append("}");
    1.81                  }
    1.82 @@ -209,8 +220,8 @@
    1.83                  if (choices != null) {
    1.84                      if (choiceKind == ChoiceKind.ONEOF) {
    1.85                          // some clients like to see just one of option+choice set
    1.86 -                        for (String c: choices)
    1.87 -                            options.remove(option + c);
    1.88 +                        for (String s: choices.keySet())
    1.89 +                            options.remove(option + s);
    1.90                          String opt = option + arg;
    1.91                          options.put(opt, opt);
    1.92                          // some clients like to see option (without trailing ":")
    1.93 @@ -256,7 +267,7 @@
    1.94          XOption(OptionName name, String descrKey, ChoiceKind kind, String... choices) {
    1.95              super(name, descrKey, kind, choices);
    1.96          }
    1.97 -        XOption(OptionName name, String descrKey, ChoiceKind kind, Collection<String> choices) {
    1.98 +        XOption(OptionName name, String descrKey, ChoiceKind kind, Map<String,Boolean> choices) {
    1.99              super(name, descrKey, kind, choices);
   1.100          }
   1.101          @Override

mercurial