@@ -172,55 +172,67 @@ public boolean isUnset(Option option, String value) {
172
172
}
173
173
174
174
/**
175
- * Check whether the given lint category is explicitly enabled or disabled.
175
+ * Determine if a specific {@link LintCategory} is enabled via a custom
176
+ * option flag of the form {@code -Xlint}, {@code -Xlint:all}, or {@code -Xlint:key}.
176
177
*
177
178
* <p>
178
- * If the category is neither enabled nor disabled, return the given default value .
179
+ * Note: It's possible the category was also disabled; this method does not check that .
179
180
*
180
- * @param option the plain (non-custom) option
181
181
* @param lc the {@link LintCategory} in question
182
- * @param defaultValue presumed default value
183
- * @return true if {@code lc} would be included
182
+ * @return true if {@code lc} has been enabled
184
183
*/
185
- public boolean isSet (Option option , LintCategory lc , boolean defaultValue ) {
186
- Option customOption = option .getCustom ();
187
- if (lc .optionList .stream ().anyMatch (alias -> isSet (customOption , alias ))) {
188
- return true ;
189
- }
190
- if (lc .optionList .stream ().anyMatch (alias -> isSet (customOption , "-" + alias ))) {
191
- return false ;
192
- }
193
- if (isSet (option ) || isSet (customOption , Option .LINT_CUSTOM_ALL )) {
194
- return true ;
195
- }
196
- if (isSet (customOption , Option .LINT_CUSTOM_NONE )) {
197
- return false ;
198
- }
199
- return defaultValue ;
184
+ public boolean isLintEnabled (LintCategory lc ) {
185
+ return isLintExplicitlyEnabled (lc ) ||
186
+ isSet (Option .XLINT_CUSTOM ) ||
187
+ isSet (Option .XLINT_CUSTOM , Option .LINT_CUSTOM_ALL );
200
188
}
201
189
202
190
/**
203
- * Determine if a specific {@link LintCategory} was explicitly enabled via a custom option flag
204
- * of the form {@code -Flag:all} or {@code -Flag:key}.
191
+ * Determine if a specific {@link LintCategory} is disabled via a custom
192
+ * option flag of the form {@code -Xlint:none} or {@code -Xlint:-key}.
193
+ *
194
+ * <p>
195
+ * Note: It's possible the category was also enabled; this method does not check that.
196
+ *
197
+ * @param lc the {@link LintCategory} in question
198
+ * @return true if {@code lc} has been disabled
199
+ */
200
+ public boolean isLintDisabled (LintCategory lc ) {
201
+ return isLintExplicitlyDisabled (lc ) || isSet (Option .XLINT_CUSTOM , Option .LINT_CUSTOM_NONE );
202
+ }
203
+
204
+ /**
205
+ * Determine if a specific {@link LintCategory} is explicitly enabled via a custom
206
+ * option flag of the form {@code -Xlint:key}.
207
+ *
208
+ * <p>
209
+ * Note: This does not check for option flags of the form {@code -Xlint} or {@code -Xlint:all}.
210
+ *
211
+ * <p>
212
+ * Note: It's possible the category was also disabled; this method does not check that.
205
213
*
206
- * @param option the option
207
214
* @param lc the {@link LintCategory} in question
208
215
* @return true if {@code lc} has been explicitly enabled
209
216
*/
210
- public boolean isExplicitlyEnabled ( Option option , LintCategory lc ) {
211
- return isSet (option , lc , false );
217
+ public boolean isLintExplicitlyEnabled ( LintCategory lc ) {
218
+ return lc . optionList . stream (). anyMatch ( alias -> isSet (Option . XLINT_CUSTOM , alias ) );
212
219
}
213
220
214
221
/**
215
- * Determine if a specific {@link LintCategory} was explicitly disabled via a custom option flag
216
- * of the form {@code -Flag:none} or {@code -Flag:-key}.
222
+ * Determine if a specific {@link LintCategory} is explicitly disabled via a custom
223
+ * option flag of the form {@code -Xlint:-key}.
224
+ *
225
+ * <p>
226
+ * Note: This does not check for an option flag of the form {@code -Xlint:none}.
227
+ *
228
+ * <p>
229
+ * Note: It's possible the category was also enabled; this method does not check that.
217
230
*
218
- * @param option the option
219
231
* @param lc the {@link LintCategory} in question
220
232
* @return true if {@code lc} has been explicitly disabled
221
233
*/
222
- public boolean isExplicitlyDisabled ( Option option , LintCategory lc ) {
223
- return ! isSet (option , lc , true );
234
+ public boolean isLintExplicitlyDisabled ( LintCategory lc ) {
235
+ return lc . optionList . stream (). anyMatch ( alias -> isSet (Option . XLINT_CUSTOM , "-" + alias ) );
224
236
}
225
237
226
238
public void put (String name , String value ) {
0 commit comments