| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 /// List of summary file paths to use in build mode. | 48 /// List of summary file paths to use in build mode. |
| 49 final List<String> buildSummaryInputs; | 49 final List<String> buildSummaryInputs; |
| 50 | 50 |
| 51 /// Whether to skip analysis when creating summaries in build mode. | 51 /// Whether to skip analysis when creating summaries in build mode. |
| 52 final bool buildSummaryOnly; | 52 final bool buildSummaryOnly; |
| 53 | 53 |
| 54 /// Whether to use diet parsing, i.e. skip function bodies. We don't need to | 54 /// Whether to use diet parsing, i.e. skip function bodies. We don't need to |
| 55 /// analyze function bodies to use summaries during future compilation steps. | 55 /// analyze function bodies to use summaries during future compilation steps. |
| 56 final bool buildSummaryOnlyDiet; | 56 final bool buildSummaryOnlyDiet; |
| 57 | 57 |
| 58 /// Whether to only produce unlinked summaries instead of linked summaries. |
| 59 /// Must be used in combination with `buildSummaryOnly`. |
| 60 final bool buildSummaryOnlyUnlinked; |
| 61 |
| 58 /// The path to output the summary when creating summaries in build mode. | 62 /// The path to output the summary when creating summaries in build mode. |
| 59 final String buildSummaryOutput; | 63 final String buildSummaryOutput; |
| 60 | 64 |
| 61 /// The path to output the semantic-only summary when creating summaries in | 65 /// The path to output the semantic-only summary when creating summaries in |
| 62 /// build mode. | 66 /// build mode. |
| 63 final String buildSummaryOutputSemantic; | 67 final String buildSummaryOutputSemantic; |
| 64 | 68 |
| 65 /// Whether to suppress a nonzero exit code in build mode. | 69 /// Whether to suppress a nonzero exit code in build mode. |
| 66 final bool buildSuppressExitCode; | 70 final bool buildSuppressExitCode; |
| 67 | 71 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 final bool color; | 152 final bool color; |
| 149 | 153 |
| 150 /// Initialize options from the given parsed [args]. | 154 /// Initialize options from the given parsed [args]. |
| 151 CommandLineOptions._fromArgs(ArgResults args) | 155 CommandLineOptions._fromArgs(ArgResults args) |
| 152 : buildAnalysisOutput = args['build-analysis-output'], | 156 : buildAnalysisOutput = args['build-analysis-output'], |
| 153 buildMode = args['build-mode'], | 157 buildMode = args['build-mode'], |
| 154 buildModePersistentWorker = args['persistent_worker'], | 158 buildModePersistentWorker = args['persistent_worker'], |
| 155 buildSummaryInputs = args['build-summary-input'] as List<String>, | 159 buildSummaryInputs = args['build-summary-input'] as List<String>, |
| 156 buildSummaryOnly = args['build-summary-only'], | 160 buildSummaryOnly = args['build-summary-only'], |
| 157 buildSummaryOnlyDiet = args['build-summary-only-diet'], | 161 buildSummaryOnlyDiet = args['build-summary-only-diet'], |
| 162 buildSummaryOnlyUnlinked = args['build-summary-only-unlinked'], |
| 158 buildSummaryOutput = args['build-summary-output'], | 163 buildSummaryOutput = args['build-summary-output'], |
| 159 buildSummaryOutputSemantic = args['build-summary-output-semantic'], | 164 buildSummaryOutputSemantic = args['build-summary-output-semantic'], |
| 160 buildSuppressExitCode = args['build-suppress-exit-code'], | 165 buildSuppressExitCode = args['build-suppress-exit-code'], |
| 161 contextBuilderOptions = createContextBuilderOptions(args), | 166 contextBuilderOptions = createContextBuilderOptions(args), |
| 162 dartSdkPath = args['dart-sdk'], | 167 dartSdkPath = args['dart-sdk'], |
| 163 dartSdkSummaryPath = args['dart-sdk-summary'], | 168 dartSdkSummaryPath = args['dart-sdk-summary'], |
| 164 disableCacheFlushing = args['disable-cache-flushing'], | 169 disableCacheFlushing = args['disable-cache-flushing'], |
| 165 disableHints = args['no-hints'], | 170 disableHints = args['no-hints'], |
| 166 displayVersion = args['version'], | 171 displayVersion = args['version'], |
| 167 enableTypeChecks = args['enable_type_checks'], | 172 enableTypeChecks = args['enable_type_checks'], |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 printAndFail('The option --persisten_worker can be used only ' | 261 printAndFail('The option --persisten_worker can be used only ' |
| 257 'together with --build-mode.'); | 262 'together with --build-mode.'); |
| 258 return null; // Only reachable in testing. | 263 return null; // Only reachable in testing. |
| 259 } | 264 } |
| 260 if (options.buildSummaryOnlyDiet && !options.buildSummaryOnly) { | 265 if (options.buildSummaryOnlyDiet && !options.buildSummaryOnly) { |
| 261 printAndFail('The option --build-summary-only-diet can be used only ' | 266 printAndFail('The option --build-summary-only-diet can be used only ' |
| 262 'together with --build-summary-only.'); | 267 'together with --build-summary-only.'); |
| 263 return null; // Only reachable in testing. | 268 return null; // Only reachable in testing. |
| 264 } | 269 } |
| 265 | 270 |
| 271 if (options.buildSummaryOnlyUnlinked) { |
| 272 if (!options.buildSummaryOnly) { |
| 273 printAndFail( |
| 274 'The option --build-summary-only-unlinked can be used only ' |
| 275 'together with --build-summary-only.'); |
| 276 return null; // Only reachable in testing. |
| 277 } |
| 278 if (options.buildSummaryInputs.isNotEmpty) { |
| 279 printAndFail('No summaries should be provided in combination with ' |
| 280 '--build-summary-only-unlinked, they aren\'t needed.'); |
| 281 return null; // Only reachable in testing. |
| 282 } |
| 283 } |
| 284 |
| 266 return options; | 285 return options; |
| 267 } | 286 } |
| 268 | 287 |
| 269 /// The source files to analyze | 288 /// The source files to analyze |
| 270 List<String> get sourceFiles => _sourceFiles; | 289 List<String> get sourceFiles => _sourceFiles; |
| 271 | 290 |
| 272 /// Replace the sourceFiles parsed from the command line. | 291 /// Replace the sourceFiles parsed from the command line. |
| 273 void rewriteSourceFiles(List<String> newSourceFiles) { | 292 void rewriteSourceFiles(List<String> newSourceFiles) { |
| 274 _sourceFiles = newSourceFiles; | 293 _sourceFiles = newSourceFiles; |
| 275 } | 294 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 ..addFlag('build-summary-only', | 396 ..addFlag('build-summary-only', |
| 378 help: 'Disable analysis (only generate summaries).', | 397 help: 'Disable analysis (only generate summaries).', |
| 379 defaultsTo: false, | 398 defaultsTo: false, |
| 380 negatable: false, | 399 negatable: false, |
| 381 hide: hide) | 400 hide: hide) |
| 382 ..addFlag('build-summary-only-diet', | 401 ..addFlag('build-summary-only-diet', |
| 383 help: 'Diet parse function bodies.', | 402 help: 'Diet parse function bodies.', |
| 384 defaultsTo: false, | 403 defaultsTo: false, |
| 385 negatable: false, | 404 negatable: false, |
| 386 hide: hide) | 405 hide: hide) |
| 406 ..addFlag('build-summary-only-unlinked', |
| 407 help: 'Only output the unlinked summary.', |
| 408 defaultsTo: false, |
| 409 negatable: false, |
| 410 hide: hide) |
| 387 ..addFlag('build-suppress-exit-code', | 411 ..addFlag('build-suppress-exit-code', |
| 388 help: 'Exit with code 0 even if errors are found.', | 412 help: 'Exit with code 0 even if errors are found.', |
| 389 defaultsTo: false, | 413 defaultsTo: false, |
| 390 negatable: false, | 414 negatable: false, |
| 391 hide: hide) | 415 hide: hide) |
| 392 ..addFlag('color', | 416 ..addFlag('color', |
| 393 help: 'Use asni colors when printing messages.', | 417 help: 'Use asni colors when printing messages.', |
| 394 defaultsTo: ansi.terminalSupportsAnsi(), | 418 defaultsTo: ansi.terminalSupportsAnsi(), |
| 395 hide: hide); | 419 hide: hide); |
| 396 | 420 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 'Usage: $_binaryName [options...] <directory or list of files>'); | 549 'Usage: $_binaryName [options...] <directory or list of files>'); |
| 526 errorSink.writeln(''); | 550 errorSink.writeln(''); |
| 527 errorSink.writeln(parser.usage); | 551 errorSink.writeln(parser.usage); |
| 528 errorSink.writeln(''); | 552 errorSink.writeln(''); |
| 529 errorSink.writeln(''' | 553 errorSink.writeln(''' |
| 530 Run "dartanalyzer -h -v" for verbose help output, including less commonly used o
ptions. | 554 Run "dartanalyzer -h -v" for verbose help output, including less commonly used o
ptions. |
| 531 For more information, see http://www.dartlang.org/tools/analyzer. | 555 For more information, see http://www.dartlang.org/tools/analyzer. |
| 532 '''); | 556 '''); |
| 533 } | 557 } |
| 534 } | 558 } |
| OLD | NEW |