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

Side by Side Diff: pkg/analyzer/lib/options.dart

Issue 944073003: Fix for filtering unknown options. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analyzer/test/options_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library options; 5 library options;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:args/args.dart'; 9 import 'package:args/args.dart';
10 10
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 389 }
390 } else if (arg.startsWith("-D")) { 390 } else if (arg.startsWith("-D")) {
391 definedVariables[arg.substring(2)] = args[++i]; 391 definedVariables[arg.substring(2)] = args[++i];
392 } else { 392 } else {
393 remainingArgs.add(arg); 393 remainingArgs.add(arg);
394 } 394 }
395 } 395 }
396 return remainingArgs; 396 return remainingArgs;
397 } 397 }
398 398
399 List<String> _filterUnknowns(args) { 399 List<String> _filterUnknowns(List<String> args) {
400 400
401 // Only filter args if the ignore flag is specified, or if 401 // Only filter args if the ignore flag is specified, or if
402 // _alwaysIgnoreUnrecognized was set to true 402 // _alwaysIgnoreUnrecognized was set to true
403 if (_alwaysIgnoreUnrecognized || 403 if (_alwaysIgnoreUnrecognized ||
404 args.contains('--ignore-unrecognized-flags')) { 404 args.contains('--ignore-unrecognized-flags')) {
405 405
406 //TODO(pquitslund): replace w/ the following once library skew issues are 406 //TODO(pquitslund): replace w/ the following once library skew issues are
407 // sorted out 407 // sorted out
408 //return args.where((arg) => !arg.startsWith('--') || 408 //return args.where((arg) => !arg.startsWith('--') ||
409 // _knownFlags.contains(arg.substring(2))); 409 // _knownFlags.contains(arg.substring(2)));
410 410
411 // Filter all unrecognized flags and options. 411 // Filter all unrecognized flags and options.
412 var filtered = <String>[]; 412 List<String> filtered = <String>[];
413 for (var i = 0; i < args.length; ++i) { 413 for (int i = 0; i < args.length; ++i) {
414 var arg = args[i]; 414 String arg = args[i];
415 if (arg.startsWith('--') && arg.length > 2) { 415 if (arg.startsWith('--') && arg.length > 2) {
416 if (!_knownFlags.contains(arg.substring(2))) { 416 String option = arg.substring(2);
417 // strip the last '=value'
418 int equalsOffset = option.lastIndexOf('=');
419 if (equalsOffset != -1) {
420 option = option.substring(0, equalsOffset);
421 }
422 // check the option
423 if (!_knownFlags.contains(option)) {
417 //print('remove: $arg'); 424 //print('remove: $arg');
418 //"eat" params by advancing to the next flag/option 425 //"eat" params by advancing to the next flag/option
419 i = _getNextFlagIndex(args, i); 426 i = _getNextFlagIndex(args, i);
420 } else { 427 } else {
421 filtered.add(arg); 428 filtered.add(arg);
422 } 429 }
423 } else { 430 } else {
424 filtered.add(arg); 431 filtered.add(arg);
425 } 432 }
426 } 433 }
427 434
428 return filtered; 435 return filtered;
429 } else { 436 } else {
430 return args; 437 return args;
431 } 438 }
432 } 439 }
433 440
434 _getNextFlagIndex(args, i) { 441 _getNextFlagIndex(args, i) {
435 for ( ; i < args.length; ++i) { 442 for ( ; i < args.length; ++i) {
436 if (args[i].startsWith('--')) { 443 if (args[i].startsWith('--')) {
437 return i; 444 return i;
438 } 445 }
439 } 446 }
440 return i; 447 return i;
441 } 448 }
442 } 449 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/options_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698