101 private static final Map<String, LintCategory> map = new ConcurrentHashMap<>(20);
102
103 protected Lint(Context context) {
104 // initialize values according to the lint options
105 Options options = Options.instance(context);
106
107 if (options.isSet(Option.XLINT) || options.isSet(Option.XLINT_CUSTOM, "all")) {
108 // If -Xlint or -Xlint:all is given, enable all categories by default
109 values = EnumSet.allOf(LintCategory.class);
110 } else if (options.isSet(Option.XLINT_CUSTOM, "none")) {
111 // if -Xlint:none is given, disable all categories by default
112 values = EnumSet.noneOf(LintCategory.class);
113 } else {
114 // otherwise, enable on-by-default categories
115 values = EnumSet.noneOf(LintCategory.class);
116
117 Source source = Source.instance(context);
118 if (source.compareTo(Source.JDK1_9) >= 0) {
119 values.add(LintCategory.DEP_ANN);
120 }
121 values.add(LintCategory.REMOVAL);
122 }
123
124 // Look for specific overrides
125 for (LintCategory lc : LintCategory.values()) {
126 if (options.isSet(Option.XLINT_CUSTOM, lc.option)) {
127 values.add(lc);
128 } else if (options.isSet(Option.XLINT_CUSTOM, "-" + lc.option)) {
129 values.remove(lc);
130 }
131 }
132
133 suppressedValues = EnumSet.noneOf(LintCategory.class);
134
135 context.put(lintKey, this);
136 augmentor = new AugmentVisitor(context);
137 }
138
139 protected Lint(Lint other) {
140 this.augmentor = other.augmentor;
188 * Warn about empty statement after if.
189 */
190 EMPTY("empty"),
191
192 /**
193 * Warn about issues regarding module exports.
194 */
195 EXPORTS("exports"),
196
197 /**
198 * Warn about falling through from one case of a switch statement to the next.
199 */
200 FALLTHROUGH("fallthrough"),
201
202 /**
203 * Warn about finally clauses that do not terminate normally.
204 */
205 FINALLY("finally"),
206
207 /**
208 * Warn about issues relating to use of command line options
209 */
210 OPTIONS("options"),
211
212 /**
213 * Warn about issues regarding method overloads.
214 */
215 OVERLOADS("overloads"),
216
217 /**
218 * Warn about issues regarding method overrides.
219 */
220 OVERRIDES("overrides"),
221
222 /**
223 * Warn about invalid path elements on the command line.
224 * Such warnings cannot be suppressed with the SuppressWarnings
225 * annotation.
226 */
227 PATH("path"),
|
101 private static final Map<String, LintCategory> map = new ConcurrentHashMap<>(20);
102
103 protected Lint(Context context) {
104 // initialize values according to the lint options
105 Options options = Options.instance(context);
106
107 if (options.isSet(Option.XLINT) || options.isSet(Option.XLINT_CUSTOM, "all")) {
108 // If -Xlint or -Xlint:all is given, enable all categories by default
109 values = EnumSet.allOf(LintCategory.class);
110 } else if (options.isSet(Option.XLINT_CUSTOM, "none")) {
111 // if -Xlint:none is given, disable all categories by default
112 values = EnumSet.noneOf(LintCategory.class);
113 } else {
114 // otherwise, enable on-by-default categories
115 values = EnumSet.noneOf(LintCategory.class);
116
117 Source source = Source.instance(context);
118 if (source.compareTo(Source.JDK1_9) >= 0) {
119 values.add(LintCategory.DEP_ANN);
120 }
121 values.add(LintCategory.MODULE);
122 values.add(LintCategory.REMOVAL);
123 }
124
125 // Look for specific overrides
126 for (LintCategory lc : LintCategory.values()) {
127 if (options.isSet(Option.XLINT_CUSTOM, lc.option)) {
128 values.add(lc);
129 } else if (options.isSet(Option.XLINT_CUSTOM, "-" + lc.option)) {
130 values.remove(lc);
131 }
132 }
133
134 suppressedValues = EnumSet.noneOf(LintCategory.class);
135
136 context.put(lintKey, this);
137 augmentor = new AugmentVisitor(context);
138 }
139
140 protected Lint(Lint other) {
141 this.augmentor = other.augmentor;
189 * Warn about empty statement after if.
190 */
191 EMPTY("empty"),
192
193 /**
194 * Warn about issues regarding module exports.
195 */
196 EXPORTS("exports"),
197
198 /**
199 * Warn about falling through from one case of a switch statement to the next.
200 */
201 FALLTHROUGH("fallthrough"),
202
203 /**
204 * Warn about finally clauses that do not terminate normally.
205 */
206 FINALLY("finally"),
207
208 /**
209 * Warn about module system related issues.
210 */
211 MODULE("module"),
212
213 /**
214 * Warn about issues relating to use of command line options
215 */
216 OPTIONS("options"),
217
218 /**
219 * Warn about issues regarding method overloads.
220 */
221 OVERLOADS("overloads"),
222
223 /**
224 * Warn about issues regarding method overrides.
225 */
226 OVERRIDES("overrides"),
227
228 /**
229 * Warn about invalid path elements on the command line.
230 * Such warnings cannot be suppressed with the SuppressWarnings
231 * annotation.
232 */
233 PATH("path"),
|