Added support for the -Wextra cli parameter
This commit is contained in:
parent
53df02fa71
commit
fbaa0264e1
3 changed files with 37 additions and 5 deletions
|
@ -60,6 +60,7 @@ public class CompileOptions {
|
||||||
private boolean progressive_;
|
private boolean progressive_;
|
||||||
private boolean verbose_;
|
private boolean verbose_;
|
||||||
private boolean wError_;
|
private boolean wError_;
|
||||||
|
private boolean wExtra_;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify advanced compiler options.
|
* Specify advanced compiler options.
|
||||||
|
@ -374,11 +375,16 @@ public class CompileOptions {
|
||||||
args.add("-verbose");
|
args.add("-verbose");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Werror
|
// Wwrror
|
||||||
if (wError_) {
|
if (wError_) {
|
||||||
args.add("-Werror");
|
args.add("-Werror");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wextra
|
||||||
|
if (wExtra_) {
|
||||||
|
args.add("-Wextra");
|
||||||
|
}
|
||||||
|
|
||||||
// advanced option (X)
|
// advanced option (X)
|
||||||
if (!advancedOptions_.isEmpty()) {
|
if (!advancedOptions_.isEmpty()) {
|
||||||
advancedOptions_.forEach(it -> args.add("-X" + it));
|
advancedOptions_.forEach(it -> args.add("-X" + it));
|
||||||
|
@ -597,6 +603,15 @@ public class CompileOptions {
|
||||||
return wError_;
|
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.
|
* Generate metadata for Java 1.8 reflection on method parameters.
|
||||||
*
|
*
|
||||||
|
@ -1071,4 +1086,15 @@ public class CompileOptions {
|
||||||
wError_ = wError;
|
wError_ = wError;
|
||||||
return this;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,8 @@ class CompileOptionsTest {
|
||||||
.progressive(true)
|
.progressive(true)
|
||||||
.scriptTemplates("name", "name2")
|
.scriptTemplates("name", "name2")
|
||||||
.verbose(true)
|
.verbose(true)
|
||||||
.wError(true);
|
.wError(true)
|
||||||
|
.wExtra(true);
|
||||||
|
|
||||||
var matches = List.of(
|
var matches = List.of(
|
||||||
"-api-version", "11",
|
"-api-version", "11",
|
||||||
|
@ -97,7 +98,8 @@ class CompileOptionsTest {
|
||||||
"-progressive",
|
"-progressive",
|
||||||
"-script-templates", "name,name2",
|
"-script-templates", "name,name2",
|
||||||
"-verbose",
|
"-verbose",
|
||||||
"-Werror");
|
"-Werror",
|
||||||
|
"-Wextra");
|
||||||
|
|
||||||
var args = new ArrayList<List<String>>();
|
var args = new ArrayList<List<String>>();
|
||||||
args.add(options.args());
|
args.add(options.args());
|
||||||
|
@ -234,7 +236,8 @@ class CompileOptionsTest {
|
||||||
.progressive(true)
|
.progressive(true)
|
||||||
.scriptTemplates("template")
|
.scriptTemplates("template")
|
||||||
.verbose(true)
|
.verbose(true)
|
||||||
.wError(true);
|
.wError(true)
|
||||||
|
.wExtra(true);
|
||||||
|
|
||||||
try (var softly = new AutoCloseableSoftAssertions()) {
|
try (var softly = new AutoCloseableSoftAssertions()) {
|
||||||
for (var p : args) {
|
for (var p : args) {
|
||||||
|
@ -340,7 +343,8 @@ class CompileOptionsTest {
|
||||||
.progressive(true)
|
.progressive(true)
|
||||||
.scriptTemplates("name", "name2")
|
.scriptTemplates("name", "name2")
|
||||||
.verbose(true)
|
.verbose(true)
|
||||||
.wError(true);
|
.wError(true)
|
||||||
|
.wExtra(true);
|
||||||
|
|
||||||
try (var softly = new AutoCloseableSoftAssertions()) {
|
try (var softly = new AutoCloseableSoftAssertions()) {
|
||||||
softly.assertThat(options.advancedOptions()).containsExactly("xopt1", "xopt2");
|
softly.assertThat(options.advancedOptions()).containsExactly("xopt1", "xopt2");
|
||||||
|
@ -368,6 +372,7 @@ class CompileOptionsTest {
|
||||||
softly.assertThat(options.plugin()).containsExactly("id:name:value");
|
softly.assertThat(options.plugin()).containsExactly("id:name:value");
|
||||||
softly.assertThat(options.scriptTemplates()).containsExactly("name", "name2");
|
softly.assertThat(options.scriptTemplates()).containsExactly("name", "name2");
|
||||||
softly.assertThat(options.isWError()).isTrue();
|
softly.assertThat(options.isWError()).isTrue();
|
||||||
|
softly.assertThat(options.isWExtra()).isTrue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,4 +22,5 @@
|
||||||
-script-templates
|
-script-templates
|
||||||
-verbose
|
-verbose
|
||||||
-Werror
|
-Werror
|
||||||
|
-Wextra
|
||||||
-X
|
-X
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue