Skip to content

Commit

Permalink
getRemainingArgs: just return an ImmutableList.
Browse files Browse the repository at this point in the history
The one (prod) place it's used just copies to an ImmutableList anyway. Via an `asList`..

PiperOrigin-RevId: 565053575
  • Loading branch information
graememorgan authored and Error Prone Team committed Sep 13, 2023
1 parent 0a2f025 commit aa9fd7e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@
import java.io.PrintWriter;
import java.io.Writer;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.Set;
Expand Down Expand Up @@ -78,8 +76,7 @@ public CompilationTask getTask(
Iterable<String> classes,
Iterable<? extends JavaFileObject> compilationUnits) {
ErrorProneOptions errorProneOptions = ErrorProneOptions.processArgs(options);
List<String> remainingOptions = Arrays.asList(errorProneOptions.getRemainingArgs());
ImmutableList<String> javacOpts = ImmutableList.copyOf(remainingOptions);
ImmutableList<String> javacOpts = errorProneOptions.getRemainingArgs();
javacOpts = defaultToLatestSupportedLanguageLevel(javacOpts);
javacOpts = setCompilePolicyToByFile(javacOpts);
JavacTask task =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ private ErrorProneOptions(
this.ignoreLargeCodeGenerators = ignoreLargeCodeGenerators;
}

public String[] getRemainingArgs() {
return remainingArgs.toArray(new String[remainingArgs.size()]);
public ImmutableList<String> getRemainingArgs() {
return remainingArgs;
}

public ImmutableMap<String, Severity> getSeverityMap() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class ErrorProneOptionsTest {
public void nonErrorProneFlagsPlacedInRemainingArgs() {
String[] args = {"-nonErrorProneFlag", "value"};
ErrorProneOptions options = ErrorProneOptions.processArgs(args);
assertThat(options.getRemainingArgs()).isEqualTo(args);
assertThat(options.getRemainingArgs()).containsExactlyElementsIn(args);
}

@Test
Expand Down Expand Up @@ -111,7 +111,7 @@ public void combineErrorProneFlagsWithNonErrorProneFlags() {
};
ErrorProneOptions options = ErrorProneOptions.processArgs(args);
String[] expectedRemainingArgs = {"-classpath", "/this/is/classpath", "-verbose"};
assertThat(options.getRemainingArgs()).isEqualTo(expectedRemainingArgs);
assertThat(options.getRemainingArgs()).containsExactlyElementsIn(expectedRemainingArgs);
ImmutableMap<String, Severity> expectedSeverityMap =
ImmutableMap.<String, Severity>builder()
.put("Check1", Severity.WARN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ private JCCompilationUnit doCompile(
new PrintWriter(out, true),
FileManagers.testFileManager(),
diagnosticsCollector,
ImmutableList.copyOf(errorProneOptions.getRemainingArgs()),
errorProneOptions.getRemainingArgs(),
/* classes= */ null,
files,
context);
Expand Down

0 comments on commit aa9fd7e

Please sign in to comment.