Chromium Code Reviews| 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 9b6e9f81f69d57a9fed1a88de6fd72d9f490739c..941075f21217cc2f63f2cd5ca3ebe61686424306 100644 |
| --- a/pkg/analyzer/lib/src/command_line/arguments.dart |
| +++ b/pkg/analyzer/lib/src/command_line/arguments.dart |
| @@ -165,6 +165,35 @@ void defineAnalysisArguments(ArgParser parser) { |
| } |
| /** |
| + * Find arguments of the form -Dkey=value |
| + * or argument pairs of the form -Dkey value |
| + * and place those key/value pairs into [definedVariables]. |
| + * Return a list of arguments with the key/value arguments removed. |
| + */ |
| +List<String> extractDefinedVariables( |
|
Brian Wilkerson
2016/12/14 17:47:35
This is already being done as part of createContex
danrubel
2016/12/14 18:06:56
That makes sense as a long term goal, but I'd like
|
| + 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")) { |
| + if (i + 1 < count) { |
| + definedVariables[arg.substring(2)] = args[++i]; |
| + } else { |
| + remainingArgs.add(arg); |
| + } |
| + } else { |
| + remainingArgs.add(arg); |
| + } |
| + } |
| + return remainingArgs; |
| +} |
| + |
| +/** |
| * Return a list of command-line arguments containing all of the given [args] |
| * that are defined by the given [parser]. An argument is considered to be |
| * defined by the parser if |