equal
deleted
inserted
replaced
25 |
25 |
26 package com.sun.tools.javac.util; |
26 package com.sun.tools.javac.util; |
27 |
27 |
28 import java.util.*; |
28 import java.util.*; |
29 |
29 |
30 import com.sun.tools.javac.code.Source; |
|
31 import com.sun.tools.javac.main.Option; |
30 import com.sun.tools.javac.main.Option; |
32 import static com.sun.tools.javac.main.Option.*; |
31 import static com.sun.tools.javac.main.Option.*; |
33 |
32 |
34 /** A table of all command-line options. |
33 /** A table of all command-line options. |
35 * If an option has an argument, the option name is mapped to the argument. |
34 * If an option has an argument, the option name is mapped to the argument. |
111 */ |
110 */ |
112 public boolean isSet(Option option, String value) { |
111 public boolean isSet(Option option, String value) { |
113 return (values.get(option.primaryName + value) != null); |
112 return (values.get(option.primaryName + value) != null); |
114 } |
113 } |
115 |
114 |
|
115 /** Check if the value for a lint option has been explicitly set, either with -Xlint:opt |
|
116 * or if all lint options have enabled and this one not disabled with -Xlint:-opt. |
|
117 */ |
|
118 public boolean isLintSet(String s) { |
|
119 // return true if either the specific option is enabled, or |
|
120 // they are all enabled without the specific one being |
|
121 // disabled |
|
122 return |
|
123 isSet(XLINT_CUSTOM, s) || |
|
124 (isSet(XLINT) || isSet(XLINT_CUSTOM, "all")) && isUnset(XLINT_CUSTOM, "-" + s); |
|
125 } |
|
126 |
116 /** |
127 /** |
117 * Check if the value for an undocumented option has not been set. |
128 * Check if the value for an undocumented option has not been set. |
118 */ |
129 */ |
119 public boolean isUnset(String name) { |
130 public boolean isUnset(String name) { |
120 return (values.get(name) == null); |
131 return (values.get(name) == null); |
168 |
179 |
169 public void notifyListeners() { |
180 public void notifyListeners() { |
170 for (Runnable r: listeners) |
181 for (Runnable r: listeners) |
171 r.run(); |
182 r.run(); |
172 } |
183 } |
173 |
|
174 /** Check for a lint suboption. */ |
|
175 public boolean lint(String s) { |
|
176 // return true if either the specific option is enabled, or |
|
177 // they are all enabled without the specific one being |
|
178 // disabled |
|
179 return |
|
180 isSet(XLINT_CUSTOM, s) || |
|
181 (isSet(XLINT) || isSet(XLINT_CUSTOM, "all") || (s.equals("dep-ann") && depAnnOnByDefault())) && |
|
182 isUnset(XLINT_CUSTOM, "-" + s); |
|
183 } |
|
184 // where |
|
185 private boolean depAnnOnByDefault() { |
|
186 String sourceName = get(Option.SOURCE); |
|
187 Source source = null; |
|
188 if (sourceName != null) |
|
189 source = Source.lookup(sourceName); |
|
190 if (source == null) |
|
191 source = Source.DEFAULT; |
|
192 return source.compareTo(Source.JDK1_9) >= 0; |
|
193 } |
|
194 } |
184 } |