| OLD | NEW |
| 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 286 |
| 287 static CommandLineOptions _parse(List<String> args) { | 287 static CommandLineOptions _parse(List<String> args) { |
| 288 args = preprocessArgs(PhysicalResourceProvider.INSTANCE, args); | 288 args = preprocessArgs(PhysicalResourceProvider.INSTANCE, args); |
| 289 | 289 |
| 290 bool verbose = args.contains('-v') || args.contains('--verbose'); | 290 bool verbose = args.contains('-v') || args.contains('--verbose'); |
| 291 bool hide = !verbose; | 291 bool hide = !verbose; |
| 292 | 292 |
| 293 var parser = new ArgParser(allowTrailingOptions: true); | 293 var parser = new ArgParser(allowTrailingOptions: true); |
| 294 defineAnalysisArguments(parser, hide: hide); | 294 defineAnalysisArguments(parser, hide: hide); |
| 295 parser | 295 parser |
| 296 ..addFlag('batch', | |
| 297 abbr: 'b', | |
| 298 help: 'Read commands from standard input (for testing).', | |
| 299 defaultsTo: false, | |
| 300 negatable: false) | |
| 301 ..addOption('format', | 296 ..addOption('format', |
| 302 help: 'Specifies the format in which errors are displayed.') | 297 help: |
| 303 ..addFlag('machine', | 298 'Specifies the format in which errors are displayed. The only curr
ently allowed value is \'machine\'.') |
| 304 help: 'Print errors in a format suitable for parsing (deprecated).', | |
| 305 defaultsTo: false, | |
| 306 negatable: false) | |
| 307 ..addFlag('version', | 299 ..addFlag('version', |
| 308 help: 'Print the analyzer version.', | 300 help: 'Print the analyzer version.', |
| 309 defaultsTo: false, | 301 defaultsTo: false, |
| 310 negatable: false) | 302 negatable: false) |
| 311 ..addFlag('lints', | 303 ..addFlag('lints', |
| 312 help: 'Show lint results.', defaultsTo: false, negatable: false) | 304 help: 'Show lint results.', defaultsTo: false, negatable: false) |
| 313 ..addFlag('no-hints', | 305 ..addFlag('no-hints', |
| 314 help: 'Do not show hint results.', | 306 help: 'Do not show hint results.', |
| 315 defaultsTo: false, | 307 defaultsTo: false, |
| 316 negatable: false) | 308 negatable: false) |
| 317 ..addFlag('disable-cache-flushing', defaultsTo: false, hide: true) | |
| 318 ..addFlag(ignoreUnrecognizedFlagsFlag, | 309 ..addFlag(ignoreUnrecognizedFlagsFlag, |
| 319 help: 'Ignore unrecognized command line flags.', | 310 help: 'Ignore unrecognized command line flags.', |
| 320 defaultsTo: false, | 311 defaultsTo: false, |
| 321 negatable: false) | 312 negatable: false) |
| 322 ..addFlag('fatal-hints', | 313 ..addFlag('fatal-hints', |
| 323 help: 'Treat hints as fatal.', defaultsTo: false, negatable: false) | 314 help: 'Treat hints as fatal.', defaultsTo: false, negatable: false) |
| 324 ..addFlag('fatal-warnings', | 315 ..addFlag('fatal-warnings', |
| 325 help: 'Treat non-type warnings as fatal.', | 316 help: 'Treat non-type warnings as fatal.', |
| 326 defaultsTo: false, | 317 defaultsTo: false, |
| 327 negatable: false) | 318 negatable: false) |
| 328 ..addFlag('fatal-lints', | 319 ..addFlag('fatal-lints', |
| 329 help: 'Treat lints as fatal.', defaultsTo: false, negatable: false) | 320 help: 'Treat lints as fatal.', defaultsTo: false, negatable: false) |
| 330 ..addFlag('package-warnings', | 321 ..addFlag('package-warnings', |
| 331 help: 'Show warnings from package: imports.', | 322 help: 'Show warnings from package: imports.', |
| 332 defaultsTo: false, | 323 defaultsTo: false, |
| 333 negatable: false) | 324 negatable: false) |
| 334 ..addFlag('show-package-warnings', | 325 ..addFlag('show-package-warnings', |
| 335 help: 'Show warnings from package: imports (deprecated).', | 326 help: 'Show warnings from package: imports (deprecated).', |
| 336 defaultsTo: false, | 327 defaultsTo: false, |
| 337 negatable: false) | 328 negatable: false) |
| 338 ..addFlag('warnings', | 329 ..addFlag('warnings', |
| 339 help: 'Show warnings from SDK imports.', | 330 help: 'Show warnings from SDK imports.', |
| 340 defaultsTo: false, | 331 defaultsTo: false, |
| 341 negatable: false) | 332 negatable: false) |
| 342 ..addFlag('show-sdk-warnings', | 333 ..addFlag('show-sdk-warnings', |
| 343 help: 'Show warnings from SDK imports (deprecated).', | 334 help: 'Show warnings from SDK imports (deprecated).', |
| 344 defaultsTo: false, | 335 defaultsTo: false, |
| 345 negatable: false) | 336 negatable: false) |
| 346 ..addOption('x-package-warnings-prefix', | |
| 347 help: | |
| 348 'Show warnings from package: imports that match the given prefix', | |
| 349 hide: true) | |
| 350 ..addOption('x-perf-report', | |
| 351 help: 'Writes a performance report to the given file (experimental).') | |
| 352 ..addFlag('help', | 337 ..addFlag('help', |
| 353 abbr: 'h', | 338 abbr: 'h', |
| 354 help: 'Display this help message.\n' | 339 help: |
| 355 'Add --verbose to show hidden options.', | 340 'Display this help message. Add --verbose to show hidden options.'
, |
| 356 defaultsTo: false, | 341 defaultsTo: false, |
| 357 negatable: false) | 342 negatable: false) |
| 358 ..addFlag('verbose', | 343 ..addFlag('verbose', |
| 359 abbr: 'v', defaultsTo: false, help: 'Verbose output.') | 344 abbr: 'v', |
| 345 defaultsTo: false, |
| 346 help: 'Verbose output.', |
| 347 negatable: false) |
| 360 ..addOption('url-mapping', | 348 ..addOption('url-mapping', |
| 361 help: '--url-mapping=libraryUri,/path/to/library.dart directs the ' | 349 help: '--url-mapping=libraryUri,/path/to/library.dart directs the ' |
| 362 'analyzer to use "library.dart" as the source for an import ' | 350 'analyzer to use "library.dart" as the source for an import ' |
| 363 'of "libraryUri".', | 351 'of "libraryUri".', |
| 364 allowMultiple: true, | 352 allowMultiple: true, |
| 365 splitCommas: false) | 353 splitCommas: false) |
| 354 |
| 366 // | 355 // |
| 367 // Build mode. | 356 // Build mode. |
| 368 // | 357 // |
| 369 ..addFlag('persistent_worker', | 358 ..addFlag('persistent_worker', |
| 370 help: 'Enable Bazel persistent worker mode.', | 359 help: 'Enable Bazel persistent worker mode.', |
| 371 defaultsTo: false, | 360 defaultsTo: false, |
| 372 negatable: false, | 361 negatable: false, |
| 373 hide: hide) | 362 hide: hide) |
| 374 ..addOption('build-analysis-output', | 363 ..addOption('build-analysis-output', |
| 375 help: | 364 help: |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 help: 'Exclude @informative information (docs, offsets, etc). ' | 402 help: 'Exclude @informative information (docs, offsets, etc). ' |
| 414 'Deprecated: please use --build-summary-output-semantic instead.', | 403 'Deprecated: please use --build-summary-output-semantic instead.', |
| 415 defaultsTo: false, | 404 defaultsTo: false, |
| 416 negatable: false, | 405 negatable: false, |
| 417 hide: hide) | 406 hide: hide) |
| 418 ..addFlag('build-suppress-exit-code', | 407 ..addFlag('build-suppress-exit-code', |
| 419 help: 'Exit with code 0 even if errors are found.', | 408 help: 'Exit with code 0 even if errors are found.', |
| 420 defaultsTo: false, | 409 defaultsTo: false, |
| 421 negatable: false, | 410 negatable: false, |
| 422 hide: hide) | 411 hide: hide) |
| 412 |
| 423 // | 413 // |
| 424 // Hidden flags. | 414 // Hidden flags. |
| 425 // | 415 // |
| 426 ..addFlag('enable-async', | 416 ..addFlag('machine', |
| 427 help: 'Enable support for the proposed async feature.', | 417 help: 'Print errors in a format suitable for parsing (deprecated).', |
| 428 defaultsTo: false, | 418 defaultsTo: false, |
| 429 negatable: false, | 419 negatable: false, |
| 430 hide: hide) | 420 hide: hide) |
| 431 ..addFlag('enable-enum', | 421 ..addFlag('batch', |
| 432 help: 'Enable support for the proposed enum feature.', | 422 help: 'Read commands from standard input (for testing).', |
| 433 defaultsTo: false, | 423 defaultsTo: false, |
| 434 negatable: false, | 424 negatable: false, |
| 435 hide: hide) | 425 hide: hide) |
| 426 ..addFlag('disable-cache-flushing', defaultsTo: false, hide: hide) |
| 427 ..addOption('x-perf-report', |
| 428 help: 'Writes a performance report to the given file (experimental).', |
| 429 hide: hide) |
| 430 ..addOption('x-package-warnings-prefix', |
| 431 help: |
| 432 'Show warnings from package: imports that match the given prefix', |
| 433 hide: hide) |
| 436 ..addFlag('enable-conditional-directives', | 434 ..addFlag('enable-conditional-directives', |
| 437 help: | 435 help: |
| 438 'deprecated -- Enable support for conditional directives (DEP 40).
', | 436 'deprecated -- Enable support for conditional directives (DEP 40).
', |
| 439 defaultsTo: false, | 437 defaultsTo: false, |
| 440 negatable: false, | 438 negatable: false, |
| 441 hide: hide) | 439 hide: hide) |
| 442 ..addFlag('enable-null-aware-operators', | 440 ..addFlag('enable-null-aware-operators', |
| 443 help: 'Enable support for null-aware operators (DEP 9).', | 441 help: 'Enable support for null-aware operators (DEP 9).', |
| 444 defaultsTo: false, | 442 defaultsTo: false, |
| 445 negatable: false, | 443 negatable: false, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 459 defaultsTo: false, | 457 defaultsTo: false, |
| 460 negatable: false, | 458 negatable: false, |
| 461 hide: hide) | 459 hide: hide) |
| 462 ..addFlag('use-analysis-driver-memory-byte-store', | 460 ..addFlag('use-analysis-driver-memory-byte-store', |
| 463 help: 'Use memory byte store, not the file system cache.', | 461 help: 'Use memory byte store, not the file system cache.', |
| 464 defaultsTo: false, | 462 defaultsTo: false, |
| 465 negatable: false, | 463 negatable: false, |
| 466 hide: hide); | 464 hide: hide); |
| 467 | 465 |
| 468 try { | 466 try { |
| 469 // TODO(scheglov) https://code.google.com/p/dart/issues/detail?id=11061 | |
| 470 args = | |
| 471 args.map((String arg) => arg == '-batch' ? '--batch' : arg).toList(); | |
| 472 if (args.contains('--$ignoreUnrecognizedFlagsFlag')) { | 467 if (args.contains('--$ignoreUnrecognizedFlagsFlag')) { |
| 473 args = filterUnknownArguments(args, parser); | 468 args = filterUnknownArguments(args, parser); |
| 474 } | 469 } |
| 475 var results = parser.parse(args); | 470 var results = parser.parse(args); |
| 476 | 471 |
| 477 // Persistent worker. | 472 // Persistent worker. |
| 478 if (args.contains('--persistent_worker')) { | 473 if (args.contains('--persistent_worker')) { |
| 479 bool validArgs; | 474 bool validArgs; |
| 480 if (!args.contains('--build-mode')) { | 475 if (!args.contains('--build-mode')) { |
| 481 validArgs = false; | 476 validArgs = false; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 | 534 |
| 540 static _showUsage(parser) { | 535 static _showUsage(parser) { |
| 541 errorSink | 536 errorSink |
| 542 .writeln('Usage: $_binaryName [options...] <libraries to analyze...>'); | 537 .writeln('Usage: $_binaryName [options...] <libraries to analyze...>'); |
| 543 errorSink.writeln(parser.getUsage()); | 538 errorSink.writeln(parser.getUsage()); |
| 544 errorSink.writeln(''); | 539 errorSink.writeln(''); |
| 545 errorSink.writeln( | 540 errorSink.writeln( |
| 546 'For more information, see http://www.dartlang.org/tools/analyzer.'); | 541 'For more information, see http://www.dartlang.org/tools/analyzer.'); |
| 547 } | 542 } |
| 548 } | 543 } |
| OLD | NEW |