Add support for -Xlint options in JavacOptions

This commit is contained in:
Erik C. Thauvin 2025-12-28 00:49:19 -08:00
parent 9c5928f9b1
commit 7a419ed197
No known key found for this signature in database
GPG key ID: 776702A6A2DA330E

View file

@ -35,6 +35,49 @@ public class JavacOptions extends ArrayList<String> {
FULL, NONE, ONLY
}
public enum XLintKey {
ALL,
AUXILIARYCLASS,
CAST,
CLASSFILE,
DANGLING_DOC_COMMENTS,
DEP_ANN,
DEPRECATION,
DIVZERO,
EMPTY,
EXPORTS,
FALLTHROUGH,
FINALLY,
IDENTITY,
INCUBATING,
LOSSY_CONVERSIONS,
MISSING_EXPLICIT_CTOR,
MODULE,
NONE,
OPENS,
OPTIONS,
OUTPUT_FILE_CLASH,
OVERLOADS,
OVERRIDES,
PATH,
PREVIEW,
PROCESSING,
RAWTYPES,
REMOVAL,
REQUIRES_AUTOMATIC,
REQUIRES_TRANSITIVE_AUTOMATIC,
RESTRICTED,
SERIAL,
STATIC,
STRICTFP,
SYNCHRONIZATION,
TEXT_BLOCKS,
THIS_ESCAPE,
TRY,
UNCHECKED,
VARARGS
}
/**
* Option to pass to annotation processors
*
@ -776,4 +819,56 @@ public class JavacOptions extends ArrayList<String> {
add("-Werror");
return this;
}
/**
* Enable recommended warning categories
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions xLint() {
add("-Xlint");
return this;
}
/**
* Warning categories to enable
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions xLint(XLintKey... keys) {
return xLint(Arrays.asList(keys));
}
/**
* Warning categories to enable
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions xLint(List<XLintKey> keys) {
add("-Xlint:" + StringUtils.join(keys, ",").replaceAll("_", "-").toLowerCase());
return this;
}
/**
* Warning categories to disable
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions xLintDisable(XLintKey... keys) {
return xLintDisable(Arrays.asList(keys));
}
/**
* Warning categories to disable
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions xLintDisable(List<XLintKey> keys) {
add("-Xlint:-" + StringUtils.join(keys, ",-").replaceAll("_", "-").toLowerCase());
return this;
}
}