| 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'; |
| 11 import 'package:analyzer/src/context/builder.dart'; | 11 import 'package:analyzer/src/context/builder.dart'; |
| 12 import 'package:analyzer_cli/src/ansi.dart' as ansi; |
| 12 import 'package:analyzer_cli/src/driver.dart'; | 13 import 'package:analyzer_cli/src/driver.dart'; |
| 13 import 'package:args/args.dart'; | 14 import 'package:args/args.dart'; |
| 14 import 'package:cli_util/cli_util.dart' show getSdkDir; | 15 import 'package:cli_util/cli_util.dart' show getSdkDir; |
| 15 | 16 |
| 16 const _binaryName = 'dartanalyzer'; | 17 const _binaryName = 'dartanalyzer'; |
| 17 | 18 |
| 18 /// Shared exit handler. | 19 /// Shared exit handler. |
| 19 /// | 20 /// |
| 20 /// *Visible for testing.* | 21 /// *Visible for testing.* |
| 21 ExitHandler exitHandler = exit; | 22 ExitHandler exitHandler = exit; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 137 |
| 137 /// Whether to treat lints as fatal | 138 /// Whether to treat lints as fatal |
| 138 final bool lintsAreFatal; | 139 final bool lintsAreFatal; |
| 139 | 140 |
| 140 /// Whether to use memory byte store for analysis driver. | 141 /// Whether to use memory byte store for analysis driver. |
| 141 final bool useAnalysisDriverMemoryByteStore; | 142 final bool useAnalysisDriverMemoryByteStore; |
| 142 | 143 |
| 143 /// Emit output in a verbose mode. | 144 /// Emit output in a verbose mode. |
| 144 final bool verbose; | 145 final bool verbose; |
| 145 | 146 |
| 147 /// Use ANSI color codes for output. |
| 148 final bool color; |
| 149 |
| 146 /// Initialize options from the given parsed [args]. | 150 /// Initialize options from the given parsed [args]. |
| 147 CommandLineOptions._fromArgs(ArgResults args) | 151 CommandLineOptions._fromArgs(ArgResults args) |
| 148 : buildAnalysisOutput = args['build-analysis-output'], | 152 : buildAnalysisOutput = args['build-analysis-output'], |
| 149 buildMode = args['build-mode'], | 153 buildMode = args['build-mode'], |
| 150 buildModePersistentWorker = args['persistent_worker'], | 154 buildModePersistentWorker = args['persistent_worker'], |
| 151 buildSummaryInputs = args['build-summary-input'] as List<String>, | 155 buildSummaryInputs = args['build-summary-input'] as List<String>, |
| 152 buildSummaryOnly = args['build-summary-only'], | 156 buildSummaryOnly = args['build-summary-only'], |
| 153 buildSummaryOnlyDiet = args['build-summary-only-diet'], | 157 buildSummaryOnlyDiet = args['build-summary-only-diet'], |
| 154 buildSummaryOutput = args['build-summary-output'], | 158 buildSummaryOutput = args['build-summary-output'], |
| 155 buildSummaryOutputSemantic = args['build-summary-output-semantic'], | 159 buildSummaryOutputSemantic = args['build-summary-output-semantic'], |
| (...skipping 18 matching lines...) Expand all Loading... |
| 174 showPackageWarningsPrefix = args['x-package-warnings-prefix'], | 178 showPackageWarningsPrefix = args['x-package-warnings-prefix'], |
| 175 showSdkWarnings = args['sdk-warnings'], | 179 showSdkWarnings = args['sdk-warnings'], |
| 176 _sourceFiles = args.rest, | 180 _sourceFiles = args.rest, |
| 177 warningsAreFatal = args['fatal-warnings'], | 181 warningsAreFatal = args['fatal-warnings'], |
| 178 strongMode = args['strong'], | 182 strongMode = args['strong'], |
| 179 implicitCasts = !args['no-implicit-casts'], | 183 implicitCasts = !args['no-implicit-casts'], |
| 180 implicitDynamic = !args['no-implicit-dynamic'], | 184 implicitDynamic = !args['no-implicit-dynamic'], |
| 181 lintsAreFatal = args['fatal-lints'], | 185 lintsAreFatal = args['fatal-lints'], |
| 182 useAnalysisDriverMemoryByteStore = | 186 useAnalysisDriverMemoryByteStore = |
| 183 args['use-analysis-driver-memory-byte-store'], | 187 args['use-analysis-driver-memory-byte-store'], |
| 184 verbose = args['verbose']; | 188 verbose = args['verbose'], |
| 189 color = args['color']; |
| 185 | 190 |
| 186 /// The path to an analysis options file | 191 /// The path to an analysis options file |
| 187 String get analysisOptionsFile => | 192 String get analysisOptionsFile => |
| 188 contextBuilderOptions.defaultAnalysisOptionsFilePath; | 193 contextBuilderOptions.defaultAnalysisOptionsFilePath; |
| 189 | 194 |
| 190 /// A table mapping the names of defined variables to their values. | 195 /// A table mapping the names of defined variables to their values. |
| 191 Map<String, String> get definedVariables => | 196 Map<String, String> get definedVariables => |
| 192 contextBuilderOptions.declaredVariables; | 197 contextBuilderOptions.declaredVariables; |
| 193 | 198 |
| 194 /// Whether to strictly follow the specification when generating warnings on | 199 /// Whether to strictly follow the specification when generating warnings on |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 hide: hide) | 381 hide: hide) |
| 377 ..addFlag('build-summary-only-diet', | 382 ..addFlag('build-summary-only-diet', |
| 378 help: 'Diet parse function bodies.', | 383 help: 'Diet parse function bodies.', |
| 379 defaultsTo: false, | 384 defaultsTo: false, |
| 380 negatable: false, | 385 negatable: false, |
| 381 hide: hide) | 386 hide: hide) |
| 382 ..addFlag('build-suppress-exit-code', | 387 ..addFlag('build-suppress-exit-code', |
| 383 help: 'Exit with code 0 even if errors are found.', | 388 help: 'Exit with code 0 even if errors are found.', |
| 384 defaultsTo: false, | 389 defaultsTo: false, |
| 385 negatable: false, | 390 negatable: false, |
| 391 hide: hide) |
| 392 ..addFlag('color', |
| 393 help: 'Use asni colors when printing messages.', |
| 394 defaultsTo: ansi.terminalSupportsAnsi(), |
| 386 hide: hide); | 395 hide: hide); |
| 387 | 396 |
| 388 // Hidden flags. | 397 // Hidden flags. |
| 389 if (!hide) { | 398 if (!hide) { |
| 390 parser.addSeparator('Less frequently used flags:'); | 399 parser.addSeparator('Less frequently used flags:'); |
| 391 } | 400 } |
| 392 | 401 |
| 393 parser | 402 parser |
| 394 ..addFlag('batch', | 403 ..addFlag('batch', |
| 395 help: 'Read commands from standard input (for testing).', | 404 help: 'Read commands from standard input (for testing).', |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 'Usage: $_binaryName [options...] <directory or list of files>'); | 525 'Usage: $_binaryName [options...] <directory or list of files>'); |
| 517 errorSink.writeln(''); | 526 errorSink.writeln(''); |
| 518 errorSink.writeln(parser.usage); | 527 errorSink.writeln(parser.usage); |
| 519 errorSink.writeln(''); | 528 errorSink.writeln(''); |
| 520 errorSink.writeln(''' | 529 errorSink.writeln(''' |
| 521 Run "dartanalyzer -h -v" for verbose help output, including less commonly used o
ptions. | 530 Run "dartanalyzer -h -v" for verbose help output, including less commonly used o
ptions. |
| 522 For more information, see http://www.dartlang.org/tools/analyzer. | 531 For more information, see http://www.dartlang.org/tools/analyzer. |
| 523 '''); | 532 '''); |
| 524 } | 533 } |
| 525 } | 534 } |
| OLD | NEW |