Index: pkg/dev_compiler/lib/src/compiler/command.dart |
diff --git a/pkg/dev_compiler/lib/src/compiler/command.dart b/pkg/dev_compiler/lib/src/compiler/command.dart |
index dfce39705c426951ebaa9a5bf0e1d53685a5c4fa..854957131594b463c098fbbd037b1ff2b56afaa7 100644 |
--- a/pkg/dev_compiler/lib/src/compiler/command.dart |
+++ b/pkg/dev_compiler/lib/src/compiler/command.dart |
@@ -281,3 +281,38 @@ class ForceCompileErrorException extends CompileErrorException { |
toString() => |
'\nForce-compilation not successful. Please check static errors.'; |
} |
+ |
+// TODO(jmesserly): fix this function in analyzer |
+List<String> filterUnknownArguments(List<String> args, ArgParser parser) { |
+ Set<String> knownOptions = new Set<String>(); |
+ Set<String> knownAbbreviations = new Set<String>(); |
+ parser.options.forEach((String name, option) { |
+ knownOptions.add(name); |
+ String abbreviation = option.abbreviation; |
+ if (abbreviation != null) { |
+ knownAbbreviations.add(abbreviation); |
+ } |
+ }); |
+ List<String> filtered = <String>[]; |
+ for (int i = 0; i < args.length; i++) { |
+ String argument = args[i]; |
+ if (argument.startsWith('--') && argument.length > 2) { |
+ int equalsOffset = argument.lastIndexOf('='); |
+ int end = equalsOffset < 0 ? argument.length : equalsOffset; |
+ if (knownOptions.contains(argument.substring(2, end))) { |
+ filtered.add(argument); |
+ } |
+ } else if (argument.startsWith('-') && argument.length > 1) { |
+ // TODO(jmesserly): fix this line in analyzer |
+ // It was discarding abbreviations such as -Da=b |
+ // Abbreviations must be 1-character (this is enforced by ArgParser), |
+ // so we don't need to use `optionName` |
+ if (knownAbbreviations.contains(argument[1])) { |
+ filtered.add(argument); |
+ } |
+ } else { |
+ filtered.add(argument); |
+ } |
+ } |
+ return filtered; |
+} |