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

Unified Diff: pkg/analyzer/lib/options.dart

Issue 940093003: Add ignore-unrecognized-flags as an option to the command line options of analysis server (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 months 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/analysis_server/lib/src/server/driver.dart ('k') | pkg/analyzer/test/options_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/options.dart
diff --git a/pkg/analyzer/lib/options.dart b/pkg/analyzer/lib/options.dart
index 50519dcfcc18409c41aba31340e972094c6d9528..9d3b9d930f0c83e4d94687c526fd28a927c11286 100644
--- a/pkg/analyzer/lib/options.dart
+++ b/pkg/analyzer/lib/options.dart
@@ -133,7 +133,7 @@ class CommandLineOptions {
static CommandLineOptions _parse(List<String> args) {
args = args.expand((String arg) => arg.split('=')).toList();
- var parser = new _CommandLineParser()
+ var parser = new CommandLineParser()
..addFlag(
'batch',
abbr: 'b',
@@ -208,8 +208,7 @@ class CommandLineOptions {
..addOption(
'url-mapping',
help: '--url-mapping=libraryUri,/path/to/library.dart directs the '
- 'analyzer to use "library.dart" as the source for an import '
- 'of "libraryUri"',
+ 'analyzer to use "library.dart" as the source for an import ' 'of "libraryUri"',
allowMultiple: true)
//
// Hidden flags.
@@ -282,7 +281,9 @@ class CommandLineOptions {
customUrlMappings[splitMapping[0]] = splitMapping[1];
}
return new CommandLineOptions._fromArgs(
- results, definedVariables, customUrlMappings);
+ results,
+ definedVariables,
+ customUrlMappings);
} on FormatException catch (e) {
print(e.message);
_showUsage(parser);
@@ -305,17 +306,21 @@ class CommandLineOptions {
* TODO(pquitslund): when the args package supports ignoring unrecognized
* options/flags, this class can be replaced with a simple [ArgParser] instance.
*/
-class _CommandLineParser {
+class CommandLineParser {
final List<String> _knownFlags;
+ final bool _alwaysIgnoreUnrecognized;
final ArgParser _parser;
/** Creates a new command line parser */
- _CommandLineParser()
+ CommandLineParser({bool alwaysIgnoreUnrecognized: false})
: _knownFlags = <String>[],
+ _alwaysIgnoreUnrecognized = alwaysIgnoreUnrecognized,
_parser = new ArgParser(allowTrailingOptions: true);
+ ArgParser get parser => _parser;
+
/**
* Defines a flag.
*
@@ -393,33 +398,37 @@ class _CommandLineParser {
List<String> _filterUnknowns(args) {
- // Only filter args if the ignore flag is specified.
- if (!args.contains('--ignore-unrecognized-flags')) {
- return args;
- }
- //TODO(pquitslund): replace w/ the following once library skew issues are
- // sorted out
- //return args.where((arg) => !arg.startsWith('--') ||
- // _knownFlags.contains(arg.substring(2)));
-
- // Filter all unrecognized flags and options.
- var filtered = <String>[];
- for (var i = 0; i < args.length; ++i) {
- var arg = args[i];
- if (arg.startsWith('--') && arg.length > 2) {
- if (!_knownFlags.contains(arg.substring(2))) {
- print('remove: $arg');
- //"eat" params by advancing to the next flag/option
- i = _getNextFlagIndex(args, i);
+ // Only filter args if the ignore flag is specified, or if
+ // _alwaysIgnoreUnrecognized was set to true
+ if (_alwaysIgnoreUnrecognized ||
+ args.contains('--ignore-unrecognized-flags')) {
+
+ //TODO(pquitslund): replace w/ the following once library skew issues are
+ // sorted out
+ //return args.where((arg) => !arg.startsWith('--') ||
+ // _knownFlags.contains(arg.substring(2)));
+
+ // Filter all unrecognized flags and options.
+ var filtered = <String>[];
+ for (var i = 0; i < args.length; ++i) {
+ var arg = args[i];
+ if (arg.startsWith('--') && arg.length > 2) {
+ if (!_knownFlags.contains(arg.substring(2))) {
+ //print('remove: $arg');
+ //"eat" params by advancing to the next flag/option
+ i = _getNextFlagIndex(args, i);
+ } else {
+ filtered.add(arg);
+ }
} else {
filtered.add(arg);
}
- } else {
- filtered.add(arg);
}
- }
- return filtered;
+ return filtered;
+ } else {
+ return args;
+ }
}
_getNextFlagIndex(args, i) {
« no previous file with comments | « pkg/analysis_server/lib/src/server/driver.dart ('k') | pkg/analyzer/test/options_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698