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

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

Issue 2572813002: update DDC and analyzer cli preprocessArgs (Closed)
Patch Set: remove unused import 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
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);
Brian Wilkerson 2016/12/13 18:48:20 Is there a reason for creating a copy of the args
danrubel 2016/12/13 18:50:08 Yes. DDC expects that.
Brian Wilkerson 2016/12/13 19:02:16 I was looking for an answer to the question of "wh
danrubel 2016/12/13 19:09:13 Yes, they modify it :-) I can revert this code ch
vsm 2016/12/13 19:14:33 Either is fine by me.
Brian Wilkerson 2016/12/13 19:18:33 Modifying the list seems strange, but given that,
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');
Brian Wilkerson 2016/12/13 19:02:16 Also, it isn't clear to me that it helps to wrap t
danrubel 2016/12/13 19:09:13 I wanted it to be clear that the @filePath was the
Brian Wilkerson 2016/12/13 19:18:33 Ah. Makes sense.
}
}
return args;
« no previous file with comments | « no previous file | pkg/analyzer/test/src/command_line/arguments_test.dart » ('j') | pkg/analyzer_cli/lib/src/options.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698