Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: pkg/analyzer/lib/src/command_line/arguments.dart

Issue 2572813002: update DDC and analyzer cli preprocessArgs (Closed)
Patch Set: merge Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/command_line/arguments_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/command_line/arguments.dart
diff --git a/pkg/analyzer/lib/src/command_line/arguments.dart b/pkg/analyzer/lib/src/command_line/arguments.dart
index 939623d9d8ccda6a3280c8e1127d4faa7c1e03af..9b6e9f81f69d57a9fed1a88de6fd72d9f490739c 100644
--- a/pkg/analyzer/lib/src/command_line/arguments.dart
+++ b/pkg/analyzer/lib/src/command_line/arguments.dart
@@ -227,10 +227,13 @@ ArgResults parse(
}
/**
- * Preprocess the given list of command line [args] by checking whether the real
- * arguments are in a file (Bazel worker mode).
+ * Preprocess the given list of command line [args].
+ * If the final arg is `@file_path` (Bazel worker mode),
+ * then read in all the lines of that file and add those as args.
+ * Always returns a new modifiable list.
*/
List<String> preprocessArgs(ResourceProvider provider, List<String> args) {
+ args = new List.from(args);
if (args.isEmpty) {
return args;
}
@@ -238,16 +241,15 @@ List<String> preprocessArgs(ResourceProvider provider, List<String> args) {
if (lastArg.startsWith('@')) {
File argsFile = provider.getFile(lastArg.substring(1));
try {
- List<String> newArgs = args.sublist(0, args.length - 1).toList();
- newArgs.addAll(argsFile
+ args.removeLast();
+ args.addAll(argsFile
.readAsStringSync()
.replaceAll('\r\n', '\n')
.replaceAll('\r', '\n')
.split('\n')
.where((String line) => line.isNotEmpty));
- return newArgs;
- } on FileSystemException {
- // Don't modify args if the file does not exist or cannot be read.
+ } on FileSystemException catch (e) {
+ throw new Exception('Failed to read file specified by $lastArg : $e');
}
}
return args;
« no previous file with comments | « no previous file | pkg/analyzer/test/src/command_line/arguments_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698