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

Side by Side Diff: pkg/analyzer_cli/lib/src/options.dart

Issue 2580933002: refactor DDC and Analyzer CLI parser option declaration (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 analyzer_cli.src.options; 5 library analyzer_cli.src.options;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:analyzer/file_system/physical_file_system.dart'; 9 import 'package:analyzer/file_system/physical_file_system.dart';
10 import 'package:analyzer/src/command_line/arguments.dart'; 10 import 'package:analyzer/src/command_line/arguments.dart';
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 return "<unknown>"; 273 return "<unknown>";
274 } 274 }
275 } 275 }
276 276
277 static CommandLineOptions _parse(List<String> args) { 277 static CommandLineOptions _parse(List<String> args) {
278 args = preprocessArgs(PhysicalResourceProvider.INSTANCE, args); 278 args = preprocessArgs(PhysicalResourceProvider.INSTANCE, args);
279 279
280 bool verbose = args.contains('-v') || args.contains('--verbose'); 280 bool verbose = args.contains('-v') || args.contains('--verbose');
281 bool hide = !verbose; 281 bool hide = !verbose;
282 282
283 var parser = new ArgParser(allowTrailingOptions: true) 283 var parser = new ArgParser(allowTrailingOptions: true);
284 defineAnalysisArguments(parser, hide: hide);
285 parser
284 ..addFlag('batch', 286 ..addFlag('batch',
285 abbr: 'b', 287 abbr: 'b',
286 help: 'Read commands from standard input (for testing).', 288 help: 'Read commands from standard input (for testing).',
287 defaultsTo: false, 289 defaultsTo: false,
288 negatable: false) 290 negatable: false)
289 ..addOption('dart-sdk', help: 'The path to the Dart SDK.')
290 ..addOption('dart-sdk-summary',
291 help: 'The path to the Dart SDK summary file.', hide: true)
292 ..addOption('packages',
293 help:
294 'Path to the package resolution configuration file, which supplies '
295 'a mapping of package names to paths. This option cannot be '
296 'used with --package-root.')
297 ..addOption('package-root',
298 abbr: 'p',
299 help: 'Path to a package root directory (deprecated). This option '
300 'cannot be used with --packages.')
301 ..addOption('options', help: 'Path to an analysis options file.')
302 ..addOption('format', 291 ..addOption('format',
303 help: 'Specifies the format in which errors are displayed.') 292 help: 'Specifies the format in which errors are displayed.')
304 ..addFlag('machine', 293 ..addFlag('machine',
305 help: 'Print errors in a format suitable for parsing (deprecated).', 294 help: 'Print errors in a format suitable for parsing (deprecated).',
306 defaultsTo: false, 295 defaultsTo: false,
307 negatable: false) 296 negatable: false)
308 ..addFlag('version', 297 ..addFlag('version',
309 help: 'Print the analyzer version.', 298 help: 'Print the analyzer version.',
310 defaultsTo: false, 299 defaultsTo: false,
311 negatable: false) 300 negatable: false)
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 help: 427 help:
439 'deprecated -- Enable support for conditional directives (DEP 40). ', 428 'deprecated -- Enable support for conditional directives (DEP 40). ',
440 defaultsTo: false, 429 defaultsTo: false,
441 negatable: false, 430 negatable: false,
442 hide: hide) 431 hide: hide)
443 ..addFlag('enable-null-aware-operators', 432 ..addFlag('enable-null-aware-operators',
444 help: 'Enable support for null-aware operators (DEP 9).', 433 help: 'Enable support for null-aware operators (DEP 9).',
445 defaultsTo: false, 434 defaultsTo: false,
446 negatable: false, 435 negatable: false,
447 hide: hide) 436 hide: hide)
448 ..addFlag('enable-strict-call-checks',
449 help: 'Fix issue 21938.',
450 defaultsTo: false,
451 negatable: false,
452 hide: hide)
453 ..addFlag('enable-new-task-model', 437 ..addFlag('enable-new-task-model',
454 help: 'deprecated -- Ennable new task model.', 438 help: 'deprecated -- Ennable new task model.',
455 defaultsTo: false, 439 defaultsTo: false,
456 negatable: false, 440 negatable: false,
457 hide: hide) 441 hide: hide)
458 ..addFlag('initializing-formal-access',
459 help:
460 'Enable support for allowing access to field formal parameters in a constructor\'s initializer list',
461 defaultsTo: false,
462 negatable: false,
463 hide: hide)
464 ..addFlag('supermixin',
465 help: 'Relax restrictions on mixins (DEP 34).',
466 defaultsTo: false,
467 negatable: false,
468 hide: hide)
469 ..addFlag('log', 442 ..addFlag('log',
470 help: 'Log additional messages and exceptions.', 443 help: 'Log additional messages and exceptions.',
471 defaultsTo: false, 444 defaultsTo: false,
472 negatable: false, 445 negatable: false,
473 hide: hide) 446 hide: hide)
474 ..addFlag('enable_type_checks', 447 ..addFlag('enable_type_checks',
475 help: 'Check types in constant evaluation.', 448 help: 'Check types in constant evaluation.',
476 defaultsTo: false, 449 defaultsTo: false,
477 negatable: false, 450 negatable: false,
478 hide: hide) 451 hide: hide);
479 ..addFlag('strong',
480 help: 'Enable strong static checks (https://goo.gl/DqcBsw)')
481 ..addFlag('no-implicit-casts',
482 negatable: false,
483 help: 'Disable implicit casts in strong mode (https://goo.gl/cTLz40)')
484 ..addFlag('no-implicit-dynamic',
485 negatable: false,
486 help: 'Disable implicit dynamic (https://goo.gl/m0UgXD)');
487 452
488 try { 453 try {
489 // TODO(scheglov) https://code.google.com/p/dart/issues/detail?id=11061 454 // TODO(scheglov) https://code.google.com/p/dart/issues/detail?id=11061
490 args = 455 args =
491 args.map((String arg) => arg == '-batch' ? '--batch' : arg).toList(); 456 args.map((String arg) => arg == '-batch' ? '--batch' : arg).toList();
492 Map<String, String> definedVariables = <String, String>{}; 457 Map<String, String> definedVariables = <String, String>{};
493 args = extractDefinedVariables(args, definedVariables); 458 args = extractDefinedVariables(args, definedVariables);
494 if (args.contains('--$ignoreUnrecognizedFlagsFlag')) { 459 if (args.contains('--$ignoreUnrecognizedFlagsFlag')) {
495 args = filterUnknownArguments(args, parser); 460 args = filterUnknownArguments(args, parser);
496 } 461 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 526
562 static _showUsage(parser) { 527 static _showUsage(parser) {
563 errorSink 528 errorSink
564 .writeln('Usage: $_binaryName [options...] <libraries to analyze...>'); 529 .writeln('Usage: $_binaryName [options...] <libraries to analyze...>');
565 errorSink.writeln(parser.getUsage()); 530 errorSink.writeln(parser.getUsage());
566 errorSink.writeln(''); 531 errorSink.writeln('');
567 errorSink.writeln( 532 errorSink.writeln(
568 'For more information, see http://www.dartlang.org/tools/analyzer.'); 533 'For more information, see http://www.dartlang.org/tools/analyzer.');
569 } 534 }
570 } 535 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698