| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 /// Whether to use build mode. | 46 /// Whether to use build mode. |
| 47 final bool buildMode; | 47 final bool buildMode; |
| 48 | 48 |
| 49 /// Whether to use build mode as a Bazel persistent worker. | 49 /// Whether to use build mode as a Bazel persistent worker. |
| 50 final bool buildModePersistentWorker; | 50 final bool buildModePersistentWorker; |
| 51 | 51 |
| 52 /// List of summary file paths to use in build mode. | 52 /// List of summary file paths to use in build mode. |
| 53 final List<String> buildSummaryInputs; | 53 final List<String> buildSummaryInputs; |
| 54 | 54 |
| 55 /// List of unlinked summary file paths to use in build mode. |
| 56 final List<String> buildSummaryUnlinkedInputs; |
| 57 |
| 55 /// Whether to skip analysis when creating summaries in build mode. | 58 /// Whether to skip analysis when creating summaries in build mode. |
| 56 final bool buildSummaryOnly; | 59 final bool buildSummaryOnly; |
| 57 | 60 |
| 58 /// Whether to use diet parsing, i.e. skip function bodies. We don't need to | 61 /// Whether to use diet parsing, i.e. skip function bodies. We don't need to |
| 59 /// analyze function bodies to use summaries during future compilation steps. | 62 /// analyze function bodies to use summaries during future compilation steps. |
| 60 final bool buildSummaryOnlyDiet; | 63 final bool buildSummaryOnlyDiet; |
| 61 | 64 |
| 62 /// Whether to only produce unlinked summaries instead of linked summaries. | 65 /// Whether to only produce unlinked summaries instead of linked summaries. |
| 63 /// Must be used in combination with `buildSummaryOnly`. | 66 /// Must be used in combination with `buildSummaryOnly`. |
| 64 final bool buildSummaryOnlyUnlinked; | 67 final bool buildSummaryOnlyUnlinked; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 157 |
| 155 /// Use ANSI color codes for output. | 158 /// Use ANSI color codes for output. |
| 156 final bool color; | 159 final bool color; |
| 157 | 160 |
| 158 /// Initialize options from the given parsed [args]. | 161 /// Initialize options from the given parsed [args]. |
| 159 CommandLineOptions._fromArgs(ArgResults args) | 162 CommandLineOptions._fromArgs(ArgResults args) |
| 160 : buildAnalysisOutput = args['build-analysis-output'], | 163 : buildAnalysisOutput = args['build-analysis-output'], |
| 161 buildMode = args['build-mode'], | 164 buildMode = args['build-mode'], |
| 162 buildModePersistentWorker = args['persistent_worker'], | 165 buildModePersistentWorker = args['persistent_worker'], |
| 163 buildSummaryInputs = args['build-summary-input'] as List<String>, | 166 buildSummaryInputs = args['build-summary-input'] as List<String>, |
| 167 buildSummaryUnlinkedInputs = |
| 168 args['build-summary-unlinked-input'] as List<String>, |
| 164 buildSummaryOnly = args['build-summary-only'], | 169 buildSummaryOnly = args['build-summary-only'], |
| 165 buildSummaryOnlyDiet = args['build-summary-only-diet'], | 170 buildSummaryOnlyDiet = args['build-summary-only-diet'], |
| 166 buildSummaryOnlyUnlinked = args['build-summary-only-unlinked'], | 171 buildSummaryOnlyUnlinked = args['build-summary-only-unlinked'], |
| 167 buildSummaryOutput = args['build-summary-output'], | 172 buildSummaryOutput = args['build-summary-output'], |
| 168 buildSummaryOutputSemantic = args['build-summary-output-semantic'], | 173 buildSummaryOutputSemantic = args['build-summary-output-semantic'], |
| 169 buildSuppressExitCode = args['build-suppress-exit-code'], | 174 buildSuppressExitCode = args['build-suppress-exit-code'], |
| 170 contextBuilderOptions = createContextBuilderOptions(args), | 175 contextBuilderOptions = createContextBuilderOptions(args), |
| 171 dartSdkPath = args['dart-sdk'], | 176 dartSdkPath = args['dart-sdk'], |
| 172 dartSdkSummaryPath = args['dart-sdk-summary'], | 177 dartSdkSummaryPath = args['dart-sdk-summary'], |
| 173 disableCacheFlushing = args['disable-cache-flushing'], | 178 disableCacheFlushing = args['disable-cache-flushing'], |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 return null; // Only reachable in testing. | 278 return null; // Only reachable in testing. |
| 274 } | 279 } |
| 275 | 280 |
| 276 if (options.buildSummaryOnlyUnlinked) { | 281 if (options.buildSummaryOnlyUnlinked) { |
| 277 if (!options.buildSummaryOnly) { | 282 if (!options.buildSummaryOnly) { |
| 278 printAndFail( | 283 printAndFail( |
| 279 'The option --build-summary-only-unlinked can be used only ' | 284 'The option --build-summary-only-unlinked can be used only ' |
| 280 'together with --build-summary-only.'); | 285 'together with --build-summary-only.'); |
| 281 return null; // Only reachable in testing. | 286 return null; // Only reachable in testing. |
| 282 } | 287 } |
| 283 if (options.buildSummaryInputs.isNotEmpty) { | 288 if (options.buildSummaryInputs.isNotEmpty || |
| 289 options.buildSummaryUnlinkedInputs.isNotEmpty) { |
| 284 printAndFail('No summaries should be provided in combination with ' | 290 printAndFail('No summaries should be provided in combination with ' |
| 285 '--build-summary-only-unlinked, they aren\'t needed.'); | 291 '--build-summary-only-unlinked, they aren\'t needed.'); |
| 286 return null; // Only reachable in testing. | 292 return null; // Only reachable in testing. |
| 287 } | 293 } |
| 288 } | 294 } |
| 289 | 295 |
| 290 return options; | 296 return options; |
| 291 } | 297 } |
| 292 | 298 |
| 293 /// The source files to analyze | 299 /// The source files to analyze |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 help: | 385 help: |
| 380 'Specifies the path to the file where analysis results should be w
ritten.', | 386 'Specifies the path to the file where analysis results should be w
ritten.', |
| 381 hide: hide) | 387 hide: hide) |
| 382 ..addFlag('build-mode', | 388 ..addFlag('build-mode', |
| 383 // TODO(paulberry): add more documentation. | 389 // TODO(paulberry): add more documentation. |
| 384 help: 'Enable build mode.', | 390 help: 'Enable build mode.', |
| 385 defaultsTo: false, | 391 defaultsTo: false, |
| 386 negatable: false, | 392 negatable: false, |
| 387 hide: hide) | 393 hide: hide) |
| 388 ..addOption('build-summary-input', | 394 ..addOption('build-summary-input', |
| 389 help: 'Path to a summary file that contains information from a ' | 395 help: 'Path to a linked summary file that contains information from ' |
| 390 'previous analysis run; may be specified multiple times.', | 396 'a previous analysis run; may be specified multiple times.', |
| 397 allowMultiple: true, |
| 398 hide: hide) |
| 399 ..addOption('build-summary-unlinked-input', |
| 400 help: 'Path to an unlinked summary file that contains information ' |
| 401 'from a previous analysis run; may be specified multiple times.', |
| 391 allowMultiple: true, | 402 allowMultiple: true, |
| 392 hide: hide) | 403 hide: hide) |
| 393 ..addOption('build-summary-output', | 404 ..addOption('build-summary-output', |
| 394 help: 'Specifies the path to the file where the full summary ' | 405 help: 'Specifies the path to the file where the full summary ' |
| 395 'information should be written.', | 406 'information should be written.', |
| 396 hide: hide) | 407 hide: hide) |
| 397 ..addOption('build-summary-output-semantic', | 408 ..addOption('build-summary-output-semantic', |
| 398 help: 'Specifies the path to the file where the semantic summary ' | 409 help: 'Specifies the path to the file where the semantic summary ' |
| 399 'information should be written.', | 410 'information should be written.', |
| 400 hide: hide) | 411 hide: hide) |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 'Usage: $_binaryName [options...] <directory or list of files>'); | 570 'Usage: $_binaryName [options...] <directory or list of files>'); |
| 560 errorSink.writeln(''); | 571 errorSink.writeln(''); |
| 561 errorSink.writeln(parser.usage); | 572 errorSink.writeln(parser.usage); |
| 562 errorSink.writeln(''); | 573 errorSink.writeln(''); |
| 563 errorSink.writeln(''' | 574 errorSink.writeln(''' |
| 564 Run "dartanalyzer -h -v" for verbose help output, including less commonly used o
ptions. | 575 Run "dartanalyzer -h -v" for verbose help output, including less commonly used o
ptions. |
| 565 For more information, see http://www.dartlang.org/tools/analyzer. | 576 For more information, see http://www.dartlang.org/tools/analyzer. |
| 566 '''); | 577 '''); |
| 567 } | 578 } |
| 568 } | 579 } |
| OLD | NEW |