| 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_cli/src/driver.dart'; | 9 import 'package:analyzer_cli/src/driver.dart'; |
| 10 import 'package:args/args.dart'; | 10 import 'package:args/args.dart'; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 /// Whether to use build mode. | 39 /// Whether to use build mode. |
| 40 final bool buildMode; | 40 final bool buildMode; |
| 41 | 41 |
| 42 /// List of summary file paths to use in build mode. | 42 /// List of summary file paths to use in build mode. |
| 43 final List<String> buildSummaryInputs; | 43 final List<String> buildSummaryInputs; |
| 44 | 44 |
| 45 /// Whether to skip analysis when creating summaries in build mode. | 45 /// Whether to skip analysis when creating summaries in build mode. |
| 46 final bool buildSummaryOnly; | 46 final bool buildSummaryOnly; |
| 47 | 47 |
| 48 /// Whether to use diet parsing, i.e. skip function bodies. We don't need to |
| 49 /// analyze function bodies to use summaries during future compilation steps. |
| 50 final bool buildSummaryOnlyDiet; |
| 51 |
| 48 /// The path to output the summary when creating summaries in build mode. | 52 /// The path to output the summary when creating summaries in build mode. |
| 49 final String buildSummaryOutput; | 53 final String buildSummaryOutput; |
| 50 | 54 |
| 51 /// Whether to suppress a nonzero exit code in build mode. | 55 /// Whether to suppress a nonzero exit code in build mode. |
| 52 final bool buildSuppressExitCode; | 56 final bool buildSuppressExitCode; |
| 53 | 57 |
| 54 /// The path to the dart SDK | 58 /// The path to the dart SDK |
| 55 String dartSdkPath; | 59 String dartSdkPath; |
| 56 | 60 |
| 57 /// A table mapping the names of defined variables to their values. | 61 /// A table mapping the names of defined variables to their values. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 /// Whether to use strong static checking. | 130 /// Whether to use strong static checking. |
| 127 final bool strongMode; | 131 final bool strongMode; |
| 128 | 132 |
| 129 /// Initialize options from the given parsed [args]. | 133 /// Initialize options from the given parsed [args]. |
| 130 CommandLineOptions._fromArgs( | 134 CommandLineOptions._fromArgs( |
| 131 ArgResults args, Map<String, String> definedVariables) | 135 ArgResults args, Map<String, String> definedVariables) |
| 132 : buildAnalysisOutput = args['build-analysis-output'], | 136 : buildAnalysisOutput = args['build-analysis-output'], |
| 133 buildMode = args['build-mode'], | 137 buildMode = args['build-mode'], |
| 134 buildSummaryInputs = args['build-summary-input'], | 138 buildSummaryInputs = args['build-summary-input'], |
| 135 buildSummaryOnly = args['build-summary-only'], | 139 buildSummaryOnly = args['build-summary-only'], |
| 140 buildSummaryOnlyDiet = args['build-summary-only-diet'], |
| 136 buildSummaryOutput = args['build-summary-output'], | 141 buildSummaryOutput = args['build-summary-output'], |
| 137 buildSuppressExitCode = args['build-suppress-exit-code'], | 142 buildSuppressExitCode = args['build-suppress-exit-code'], |
| 138 dartSdkPath = args['dart-sdk'], | 143 dartSdkPath = args['dart-sdk'], |
| 139 definedVariables = definedVariables, | 144 definedVariables = definedVariables, |
| 140 analysisOptionsFile = args['options'], | 145 analysisOptionsFile = args['options'], |
| 141 disableHints = args['no-hints'], | 146 disableHints = args['no-hints'], |
| 142 displayVersion = args['version'], | 147 displayVersion = args['version'], |
| 143 enableConditionalDirectives = args['enable-conditional-directives'], | 148 enableConditionalDirectives = args['enable-conditional-directives'], |
| 144 enableNullAwareOperators = args['enable-null-aware-operators'], | 149 enableNullAwareOperators = args['enable-null-aware-operators'], |
| 145 enableStrictCallChecks = args['enable-strict-call-checks'], | 150 enableStrictCallChecks = args['enable-strict-call-checks'], |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 } | 207 } |
| 203 } | 208 } |
| 204 | 209 |
| 205 // OK. Report deprecated options. | 210 // OK. Report deprecated options. |
| 206 if (options.enableNullAwareOperators) { | 211 if (options.enableNullAwareOperators) { |
| 207 errorSink.writeln( | 212 errorSink.writeln( |
| 208 "Info: Option '--enable-null-aware-operators' is no longer needed. " | 213 "Info: Option '--enable-null-aware-operators' is no longer needed. " |
| 209 "Null aware operators are supported by default."); | 214 "Null aware operators are supported by default."); |
| 210 } | 215 } |
| 211 | 216 |
| 217 // Build mode. |
| 218 if (options.buildSummaryOnlyDiet && !options.buildSummaryOnly) { |
| 219 printAndFail('The option --build-summary-only-diet can be used only ' |
| 220 'together with --build-summary-only.'); |
| 221 } |
| 222 |
| 212 return options; | 223 return options; |
| 213 } | 224 } |
| 214 | 225 |
| 215 static String _getVersion() { | 226 static String _getVersion() { |
| 216 try { | 227 try { |
| 217 // This is relative to bin/snapshot, so ../.. | 228 // This is relative to bin/snapshot, so ../.. |
| 218 String versionPath = | 229 String versionPath = |
| 219 Platform.script.resolve('../../version').toFilePath(); | 230 Platform.script.resolve('../../version').toFilePath(); |
| 220 File versionFile = new File(versionPath); | 231 File versionFile = new File(versionPath); |
| 221 return versionFile.readAsStringSync().trim(); | 232 return versionFile.readAsStringSync().trim(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 hide: true) | 334 hide: true) |
| 324 ..addOption('build-summary-output', | 335 ..addOption('build-summary-output', |
| 325 help: 'Specifies the path to the file where the summary information ' | 336 help: 'Specifies the path to the file where the summary information ' |
| 326 'should be written.', | 337 'should be written.', |
| 327 hide: true) | 338 hide: true) |
| 328 ..addFlag('build-summary-only', | 339 ..addFlag('build-summary-only', |
| 329 help: 'Disable analysis (only generate summaries).', | 340 help: 'Disable analysis (only generate summaries).', |
| 330 defaultsTo: false, | 341 defaultsTo: false, |
| 331 negatable: false, | 342 negatable: false, |
| 332 hide: true) | 343 hide: true) |
| 344 ..addFlag('build-summary-only-diet', |
| 345 help: 'Diet parse function bodies.', |
| 346 defaultsTo: false, |
| 347 negatable: false, |
| 348 hide: true) |
| 333 ..addFlag('build-suppress-exit-code', | 349 ..addFlag('build-suppress-exit-code', |
| 334 help: 'Exit with code 0 even if errors are found.', | 350 help: 'Exit with code 0 even if errors are found.', |
| 335 defaultsTo: false, | 351 defaultsTo: false, |
| 336 negatable: false, | 352 negatable: false, |
| 337 hide: true) | 353 hide: true) |
| 338 // | 354 // |
| 339 // Hidden flags. | 355 // Hidden flags. |
| 340 // | 356 // |
| 341 ..addFlag('enable-async', | 357 ..addFlag('enable-async', |
| 342 help: 'Enable support for the proposed async feature.', | 358 help: 'Enable support for the proposed async feature.', |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 | 586 |
| 571 int _getNextFlagIndex(args, i) { | 587 int _getNextFlagIndex(args, i) { |
| 572 for (; i < args.length; ++i) { | 588 for (; i < args.length; ++i) { |
| 573 if (args[i].startsWith('--')) { | 589 if (args[i].startsWith('--')) { |
| 574 return i; | 590 return i; |
| 575 } | 591 } |
| 576 } | 592 } |
| 577 return i; | 593 return i; |
| 578 } | 594 } |
| 579 } | 595 } |
| OLD | NEW |