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

Unified Diff: pkg/analyzer_cli/lib/src/options.dart

Issue 2571583007: move extractDefinedVariables from analyzer cli to analyzer (Closed)
Patch Set: add TODO indicating future work 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 | « pkg/analyzer/test/src/command_line/arguments_test.dart ('k') | pkg/analyzer_cli/test/options_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_cli/lib/src/options.dart
diff --git a/pkg/analyzer_cli/lib/src/options.dart b/pkg/analyzer_cli/lib/src/options.dart
index 6686e97c1b487288ea9618460f44475089d75b80..9b786410e0776a9589e37666b991de742cba38b2 100644
--- a/pkg/analyzer_cli/lib/src/options.dart
+++ b/pkg/analyzer_cli/lib/src/options.dart
@@ -491,7 +491,8 @@ class CommandLineOptions {
args =
args.map((String arg) => arg == '-batch' ? '--batch' : arg).toList();
Map<String, String> definedVariables = <String, String>{};
- var results = parser.parse(args, definedVariables);
+ args = extractDefinedVariables(args, definedVariables);
+ var results = parser.parse(args);
// Persistent worker.
if (args.contains('--persistent_worker')) {
@@ -633,31 +634,9 @@ class CommandLineParser {
String getUsage() => _parser.usage;
/// Parses [args], a list of command-line arguments, matches them against the
- /// flags and options defined by this parser, and returns the result. The
- /// values of any defined variables are captured in the given map.
+ /// flags and options defined by this parser, and returns the result.
/// See [ArgParser].
- ArgResults parse(List<String> args, Map<String, String> definedVariables) =>
- _parser.parse(
- _filterUnknowns(parseDefinedVariables(args, definedVariables)));
-
- List<String> parseDefinedVariables(
- List<String> args, Map<String, String> definedVariables) {
- int count = args.length;
- List<String> remainingArgs = <String>[];
- for (int i = 0; i < count; i++) {
- String arg = args[i];
- if (arg == '--') {
- while (i < count) {
- remainingArgs.add(args[i++]);
- }
- } else if (arg.startsWith("-D")) {
- definedVariables[arg.substring(2)] = args[++i];
- } else {
- remainingArgs.add(arg);
- }
- }
- return remainingArgs;
- }
+ ArgResults parse(List<String> args) => _parser.parse(_filterUnknowns(args));
List<String> _filterUnknowns(List<String> args) {
// Only filter args if the ignore flag is specified, or if
« no previous file with comments | « pkg/analyzer/test/src/command_line/arguments_test.dart ('k') | pkg/analyzer_cli/test/options_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698