| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 /// Whether implicit dynamic is enabled (mainly for strong mode users) | 137 /// Whether implicit dynamic is enabled (mainly for strong mode users) |
| 138 final bool implicitDynamic; | 138 final bool implicitDynamic; |
| 139 | 139 |
| 140 /// Whether to treat lints as fatal | 140 /// Whether to treat lints as fatal |
| 141 final bool lintsAreFatal; | 141 final bool lintsAreFatal; |
| 142 | 142 |
| 143 /// Whether to use memory byte store for analysis driver. | 143 /// Whether to use memory byte store for analysis driver. |
| 144 final bool useAnalysisDriverMemoryByteStore; | 144 final bool useAnalysisDriverMemoryByteStore; |
| 145 | 145 |
| 146 /// Emit output in a verbose mode. |
| 147 final bool verbose; |
| 148 |
| 146 /// Initialize options from the given parsed [args]. | 149 /// Initialize options from the given parsed [args]. |
| 147 CommandLineOptions._fromArgs(ArgResults args) | 150 CommandLineOptions._fromArgs(ArgResults args) |
| 148 : buildAnalysisOutput = args['build-analysis-output'], | 151 : buildAnalysisOutput = args['build-analysis-output'], |
| 149 buildMode = args['build-mode'], | 152 buildMode = args['build-mode'], |
| 150 buildModePersistentWorker = args['persistent_worker'], | 153 buildModePersistentWorker = args['persistent_worker'], |
| 151 buildSummaryInputs = args['build-summary-input'] as List<String>, | 154 buildSummaryInputs = args['build-summary-input'] as List<String>, |
| 152 buildSummaryOnly = args['build-summary-only'], | 155 buildSummaryOnly = args['build-summary-only'], |
| 153 buildSummaryOnlyDiet = args['build-summary-only-diet'], | 156 buildSummaryOnlyDiet = args['build-summary-only-diet'], |
| 154 buildSummaryExcludeInformative = | 157 buildSummaryExcludeInformative = |
| 155 args['build-summary-exclude-informative'], | 158 args['build-summary-exclude-informative'], |
| (...skipping 19 matching lines...) Expand all Loading... |
| 175 args['x-package-warnings-prefix'] != null, | 178 args['x-package-warnings-prefix'] != null, |
| 176 showPackageWarningsPrefix = args['x-package-warnings-prefix'], | 179 showPackageWarningsPrefix = args['x-package-warnings-prefix'], |
| 177 showSdkWarnings = args['show-sdk-warnings'] || args['warnings'], | 180 showSdkWarnings = args['show-sdk-warnings'] || args['warnings'], |
| 178 sourceFiles = args.rest, | 181 sourceFiles = args.rest, |
| 179 warningsAreFatal = args['fatal-warnings'], | 182 warningsAreFatal = args['fatal-warnings'], |
| 180 strongMode = args['strong'], | 183 strongMode = args['strong'], |
| 181 implicitCasts = !args['no-implicit-casts'], | 184 implicitCasts = !args['no-implicit-casts'], |
| 182 implicitDynamic = !args['no-implicit-dynamic'], | 185 implicitDynamic = !args['no-implicit-dynamic'], |
| 183 lintsAreFatal = args['fatal-lints'], | 186 lintsAreFatal = args['fatal-lints'], |
| 184 useAnalysisDriverMemoryByteStore = | 187 useAnalysisDriverMemoryByteStore = |
| 185 args['use-analysis-driver-memory-byte-store']; | 188 args['use-analysis-driver-memory-byte-store'], |
| 189 verbose = args['verbose']; |
| 186 | 190 |
| 187 /// The path to an analysis options file | 191 /// The path to an analysis options file |
| 188 String get analysisOptionsFile => | 192 String get analysisOptionsFile => |
| 189 contextBuilderOptions.defaultAnalysisOptionsFilePath; | 193 contextBuilderOptions.defaultAnalysisOptionsFilePath; |
| 190 | 194 |
| 191 /// A table mapping the names of defined variables to their values. | 195 /// A table mapping the names of defined variables to their values. |
| 192 Map<String, String> get definedVariables => | 196 Map<String, String> get definedVariables => |
| 193 contextBuilderOptions.declaredVariables; | 197 contextBuilderOptions.declaredVariables; |
| 194 | 198 |
| 195 /// Whether to strictly follow the specification when generating warnings on | 199 /// Whether to strictly follow the specification when generating warnings on |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 ..addFlag('version', | 301 ..addFlag('version', |
| 298 help: 'Print the analyzer version.', | 302 help: 'Print the analyzer version.', |
| 299 defaultsTo: false, | 303 defaultsTo: false, |
| 300 negatable: false) | 304 negatable: false) |
| 301 ..addFlag('lints', | 305 ..addFlag('lints', |
| 302 help: 'Show lint results.', defaultsTo: false, negatable: false) | 306 help: 'Show lint results.', defaultsTo: false, negatable: false) |
| 303 ..addFlag('no-hints', | 307 ..addFlag('no-hints', |
| 304 help: 'Do not show hint results.', | 308 help: 'Do not show hint results.', |
| 305 defaultsTo: false, | 309 defaultsTo: false, |
| 306 negatable: false) | 310 negatable: false) |
| 307 ..addFlag(ignoreUnrecognizedFlagsFlag, | |
| 308 help: 'Ignore unrecognized command line flags.', | |
| 309 defaultsTo: false, | |
| 310 negatable: false) | |
| 311 ..addFlag('fatal-hints', | 311 ..addFlag('fatal-hints', |
| 312 help: 'Treat hints as fatal.', defaultsTo: false, negatable: false) | 312 help: 'Treat hints as fatal.', defaultsTo: false, negatable: false) |
| 313 ..addFlag('fatal-warnings', | 313 ..addFlag('fatal-warnings', |
| 314 help: 'Treat non-type warnings as fatal.', | 314 help: 'Treat non-type warnings as fatal.', |
| 315 defaultsTo: false, | 315 defaultsTo: false, |
| 316 negatable: false) | 316 negatable: false) |
| 317 ..addFlag('fatal-lints', | 317 ..addFlag('fatal-lints', |
| 318 help: 'Treat lints as fatal.', defaultsTo: false, negatable: false) | 318 help: 'Treat lints as fatal.', defaultsTo: false, negatable: false) |
| 319 ..addFlag('package-warnings', | 319 ..addFlag('package-warnings', |
| 320 help: 'Show warnings from package: imports.', | 320 help: 'Show warnings from package: imports.', |
| (...skipping 14 matching lines...) Expand all Loading... |
| 335 ..addFlag('help', | 335 ..addFlag('help', |
| 336 abbr: 'h', | 336 abbr: 'h', |
| 337 help: | 337 help: |
| 338 'Display this help message. Add --verbose to show hidden options.'
, | 338 'Display this help message. Add --verbose to show hidden options.'
, |
| 339 defaultsTo: false, | 339 defaultsTo: false, |
| 340 negatable: false) | 340 negatable: false) |
| 341 ..addFlag('verbose', | 341 ..addFlag('verbose', |
| 342 abbr: 'v', | 342 abbr: 'v', |
| 343 defaultsTo: false, | 343 defaultsTo: false, |
| 344 help: 'Verbose output.', | 344 help: 'Verbose output.', |
| 345 negatable: false) | 345 negatable: false); |
| 346 ..addOption('url-mapping', | |
| 347 help: '--url-mapping=libraryUri,/path/to/library.dart directs the ' | |
| 348 'analyzer to use "library.dart" as the source for an import ' | |
| 349 'of "libraryUri".', | |
| 350 allowMultiple: true, | |
| 351 splitCommas: false); | |
| 352 | 346 |
| 353 // Build mode options. | 347 // Build mode options. |
| 354 if (!hide) { | 348 if (!hide) { |
| 355 parser.addSeparator('Build mode flags:'); | 349 parser.addSeparator('Build mode flags:'); |
| 356 } | 350 } |
| 357 | 351 |
| 358 parser | 352 parser |
| 359 ..addFlag('persistent_worker', | 353 ..addFlag('persistent_worker', |
| 360 help: 'Enable Bazel persistent worker mode.', | 354 help: 'Enable Bazel persistent worker mode.', |
| 361 defaultsTo: false, | 355 defaultsTo: false, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 if (!hide) { | 409 if (!hide) { |
| 416 parser.addSeparator('Less frequently used flags:'); | 410 parser.addSeparator('Less frequently used flags:'); |
| 417 } | 411 } |
| 418 | 412 |
| 419 parser | 413 parser |
| 420 ..addFlag('batch', | 414 ..addFlag('batch', |
| 421 help: 'Read commands from standard input (for testing).', | 415 help: 'Read commands from standard input (for testing).', |
| 422 defaultsTo: false, | 416 defaultsTo: false, |
| 423 negatable: false, | 417 negatable: false, |
| 424 hide: hide) | 418 hide: hide) |
| 419 ..addFlag(ignoreUnrecognizedFlagsFlag, |
| 420 help: 'Ignore unrecognized command line flags.', |
| 421 defaultsTo: false, |
| 422 negatable: false, |
| 423 hide: hide) |
| 425 ..addFlag('disable-cache-flushing', defaultsTo: false, hide: hide) | 424 ..addFlag('disable-cache-flushing', defaultsTo: false, hide: hide) |
| 426 ..addOption('x-perf-report', | 425 ..addOption('x-perf-report', |
| 427 help: 'Writes a performance report to the given file (experimental).', | 426 help: 'Writes a performance report to the given file (experimental).', |
| 428 hide: hide) | 427 hide: hide) |
| 429 ..addOption('x-package-warnings-prefix', | 428 ..addOption('x-package-warnings-prefix', |
| 430 help: | 429 help: |
| 431 'Show warnings from package: imports that match the given prefix', | 430 'Show warnings from package: imports that match the given prefix', |
| 432 hide: hide) | 431 hide: hide) |
| 433 ..addFlag('enable-conditional-directives', | 432 ..addFlag('enable-conditional-directives', |
| 434 help: | 433 help: |
| 435 'deprecated -- Enable support for conditional directives (DEP 40).
', | 434 'deprecated -- Enable support for conditional directives (DEP 40).
', |
| 436 defaultsTo: false, | 435 defaultsTo: false, |
| 437 negatable: false, | 436 negatable: false, |
| 438 hide: hide) | 437 hide: hide) |
| 439 ..addFlag('log', | 438 ..addFlag('log', |
| 440 help: 'Log additional messages and exceptions.', | 439 help: 'Log additional messages and exceptions.', |
| 441 defaultsTo: false, | 440 defaultsTo: false, |
| 442 negatable: false, | 441 negatable: false, |
| 443 hide: hide) | 442 hide: hide) |
| 444 ..addFlag('enable_type_checks', | 443 ..addFlag('enable_type_checks', |
| 445 help: 'Check types in constant evaluation.', | 444 help: 'Check types in constant evaluation.', |
| 446 defaultsTo: false, | 445 defaultsTo: false, |
| 447 negatable: false, | 446 negatable: false, |
| 448 hide: hide) | 447 hide: hide) |
| 449 ..addFlag('use-analysis-driver-memory-byte-store', | 448 ..addFlag('use-analysis-driver-memory-byte-store', |
| 450 help: 'Use memory byte store, not the file system cache.', | 449 help: 'Use memory byte store, not the file system cache.', |
| 451 defaultsTo: false, | 450 defaultsTo: false, |
| 452 negatable: false, | 451 negatable: false, |
| 452 hide: hide) |
| 453 ..addOption('url-mapping', |
| 454 help: '--url-mapping=libraryUri,/path/to/library.dart directs the ' |
| 455 'analyzer to use "library.dart" as the source for an import ' |
| 456 'of "libraryUri".', |
| 457 allowMultiple: true, |
| 458 splitCommas: false, |
| 453 hide: hide); | 459 hide: hide); |
| 454 | 460 |
| 455 try { | 461 try { |
| 456 if (args.contains('--$ignoreUnrecognizedFlagsFlag')) { | 462 if (args.contains('--$ignoreUnrecognizedFlagsFlag')) { |
| 457 args = filterUnknownArguments(args, parser); | 463 args = filterUnknownArguments(args, parser); |
| 458 } | 464 } |
| 459 ArgResults results = parser.parse(args); | 465 ArgResults results = parser.parse(args); |
| 460 | 466 |
| 461 // Persistent worker. | 467 // Persistent worker. |
| 462 if (args.contains('--persistent_worker')) { | 468 if (args.contains('--persistent_worker')) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 'Usage: $_binaryName [options...] <directory or list of files>'); | 532 'Usage: $_binaryName [options...] <directory or list of files>'); |
| 527 errorSink.writeln(''); | 533 errorSink.writeln(''); |
| 528 errorSink.writeln(parser.usage); | 534 errorSink.writeln(parser.usage); |
| 529 errorSink.writeln(''); | 535 errorSink.writeln(''); |
| 530 errorSink.writeln(''' | 536 errorSink.writeln(''' |
| 531 Run "dartanalyzer -h -v" for verbose help output, including less commonly used o
ptions. | 537 Run "dartanalyzer -h -v" for verbose help output, including less commonly used o
ptions. |
| 532 For more information, see http://www.dartlang.org/tools/analyzer. | 538 For more information, see http://www.dartlang.org/tools/analyzer. |
| 533 '''); | 539 '''); |
| 534 } | 540 } |
| 535 } | 541 } |
| OLD | NEW |