Added support for the -Wextra cli parameter

This commit is contained in:
Erik C. Thauvin 2024-11-28 10:44:45 -08:00
parent 53df02fa71
commit fbaa0264e1
Signed by: erik
GPG key ID: 776702A6A2DA330E
3 changed files with 37 additions and 5 deletions

View file

@ -60,6 +60,7 @@ public class CompileOptions {
private boolean progressive_;
private boolean verbose_;
private boolean wError_;
private boolean wExtra_;
/**
* Specify advanced compiler options.
@ -374,11 +375,16 @@ public class CompileOptions {
args.add("-verbose");
}
// Werror
// Wwrror
if (wError_) {
args.add("-Werror");
}
// Wextra
if (wExtra_) {
args.add("-Wextra");
}
// advanced option (X)
if (!advancedOptions_.isEmpty()) {
advancedOptions_.forEach(it -> args.add("-X" + it));
@ -597,6 +603,15 @@ public class CompileOptions {
return wError_;
}
/**
* Indicates whether additional declaration, expression, and type compiler checks emit warnings.
*
* @return {@code true} or {@code false}
*/
public boolean isWExtra() {
return wExtra_;
}
/**
* Generate metadata for Java 1.8 reflection on method parameters.
*
@ -1071,4 +1086,15 @@ public class CompileOptions {
wError_ = wError;
return this;
}
/**
* Enable additional declaration, expression, and type compiler checks that emit warnings if {@code true}.
*
* @param wExtra {@code true} or {@code false}
* @return this operation instance
*/
public CompileOptions wExtra(boolean wExtra) {
wExtra_ = wExtra;
return this;
}
}

View file

@ -71,7 +71,8 @@ class CompileOptionsTest {
.progressive(true)
.scriptTemplates("name", "name2")
.verbose(true)
.wError(true);
.wError(true)
.wExtra(true);
var matches = List.of(
"-api-version", "11",
@ -97,7 +98,8 @@ class CompileOptionsTest {
"-progressive",
"-script-templates", "name,name2",
"-verbose",
"-Werror");
"-Werror",
"-Wextra");
var args = new ArrayList<List<String>>();
args.add(options.args());
@ -234,7 +236,8 @@ class CompileOptionsTest {
.progressive(true)
.scriptTemplates("template")
.verbose(true)
.wError(true);
.wError(true)
.wExtra(true);
try (var softly = new AutoCloseableSoftAssertions()) {
for (var p : args) {
@ -340,7 +343,8 @@ class CompileOptionsTest {
.progressive(true)
.scriptTemplates("name", "name2")
.verbose(true)
.wError(true);
.wError(true)
.wExtra(true);
try (var softly = new AutoCloseableSoftAssertions()) {
softly.assertThat(options.advancedOptions()).containsExactly("xopt1", "xopt2");
@ -368,6 +372,7 @@ class CompileOptionsTest {
softly.assertThat(options.plugin()).containsExactly("id:name:value");
softly.assertThat(options.scriptTemplates()).containsExactly("name", "name2");
softly.assertThat(options.isWError()).isTrue();
softly.assertThat(options.isWExtra()).isTrue();
}
}
}

View file

@ -22,4 +22,5 @@
-script-templates
-verbose
-Werror
-Wextra
-X