| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 options; | 5 library options; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:args/args.dart'; | 9 import 'package:args/args.dart'; |
| 10 | 10 |
| 11 const _BINARY_NAME = 'dartanalyzer'; | 11 const _BINARY_NAME = 'dartanalyzer'; |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Analyzer commandline configuration options. | 14 * Analyzer commandline configuration options. |
| 15 */ | 15 */ |
| 16 class CommandLineOptions { | 16 class CommandLineOptions { |
| 17 /** The path to the dart SDK */ | 17 /** The path to the dart SDK */ |
| 18 final String dartSdkPath; | 18 final String dartSdkPath; |
| 19 | 19 |
| 20 /** A table mapping the names of defined variables to their values. */ | 20 /** A table mapping the names of defined variables to their values. */ |
| 21 final Map<String, String> definedVariables; | 21 final Map<String, String> definedVariables; |
| 22 | 22 |
| 23 /** Whether to report hints */ | 23 /** Whether to report hints */ |
| 24 final bool disableHints; | 24 final bool disableHints; |
| 25 | 25 |
| 26 /** Whether to display version information */ | 26 /** Whether to display version information */ |
| 27 final bool displayVersion; | 27 final bool displayVersion; |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * Whether to strictly follow the specification when generating warnings on |
| 31 * "call" methods (fixes dartbug.com/21938). |
| 32 */ |
| 33 final bool enableStrictCallChecks; |
| 34 |
| 35 /** |
| 30 * Whether to treat type mismatches found during constant evaluation as | 36 * Whether to treat type mismatches found during constant evaluation as |
| 31 * errors. | 37 * errors. |
| 32 */ | 38 */ |
| 33 final bool enableTypeChecks; | 39 final bool enableTypeChecks; |
| 34 | 40 |
| 35 /** Whether to ignore unrecognized flags */ | 41 /** Whether to ignore unrecognized flags */ |
| 36 final bool ignoreUnrecognizedFlags; | 42 final bool ignoreUnrecognizedFlags; |
| 37 | 43 |
| 38 /** Whether to log additional analysis messages and exceptions */ | 44 /** Whether to log additional analysis messages and exceptions */ |
| 39 final bool log; | 45 final bool log; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 /** | 79 /** |
| 74 * Initialize options from the given parsed [args]. | 80 * Initialize options from the given parsed [args]. |
| 75 */ | 81 */ |
| 76 CommandLineOptions._fromArgs(ArgResults args, | 82 CommandLineOptions._fromArgs(ArgResults args, |
| 77 Map<String, String> definedVariables, | 83 Map<String, String> definedVariables, |
| 78 Map<String, String> customUrlMappings) | 84 Map<String, String> customUrlMappings) |
| 79 : dartSdkPath = args['dart-sdk'], | 85 : dartSdkPath = args['dart-sdk'], |
| 80 this.definedVariables = definedVariables, | 86 this.definedVariables = definedVariables, |
| 81 disableHints = args['no-hints'], | 87 disableHints = args['no-hints'], |
| 82 displayVersion = args['version'], | 88 displayVersion = args['version'], |
| 89 enableStrictCallChecks = args['enable-strict-call-checks'], |
| 83 enableTypeChecks = args['enable_type_checks'], | 90 enableTypeChecks = args['enable_type_checks'], |
| 84 ignoreUnrecognizedFlags = args['ignore-unrecognized-flags'], | 91 ignoreUnrecognizedFlags = args['ignore-unrecognized-flags'], |
| 85 log = args['log'], | 92 log = args['log'], |
| 86 machineFormat = args['machine'] || args['format'] == 'machine', | 93 machineFormat = args['machine'] || args['format'] == 'machine', |
| 87 packageRootPath = args['package-root'], | 94 packageRootPath = args['package-root'], |
| 88 perf = args['perf'], | 95 perf = args['perf'], |
| 89 shouldBatch = args['batch'], | 96 shouldBatch = args['batch'], |
| 90 showPackageWarnings = args['show-package-warnings'] || | 97 showPackageWarnings = args['show-package-warnings'] || |
| 91 args['package-warnings'], | 98 args['package-warnings'], |
| 92 showSdkWarnings = args['show-sdk-warnings'] || args['warnings'], | 99 showSdkWarnings = args['show-sdk-warnings'] || args['warnings'], |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 ..addFlag('enable-async', | 206 ..addFlag('enable-async', |
| 200 help: 'Enable support for the proposed async feature', | 207 help: 'Enable support for the proposed async feature', |
| 201 defaultsTo: false, | 208 defaultsTo: false, |
| 202 negatable: false, | 209 negatable: false, |
| 203 hide: true) | 210 hide: true) |
| 204 ..addFlag('enable-enum', | 211 ..addFlag('enable-enum', |
| 205 help: 'Enable support for the proposed enum feature', | 212 help: 'Enable support for the proposed enum feature', |
| 206 defaultsTo: false, | 213 defaultsTo: false, |
| 207 negatable: false, | 214 negatable: false, |
| 208 hide: true) | 215 hide: true) |
| 216 ..addFlag('enable-strict-call-checks', |
| 217 help: 'Fix issue 21938', |
| 218 defaultsTo: false, |
| 219 negatable: false, |
| 220 hide: true) |
| 209 ..addFlag('log', | 221 ..addFlag('log', |
| 210 help: 'Log additional messages and exceptions', | 222 help: 'Log additional messages and exceptions', |
| 211 defaultsTo: false, | 223 defaultsTo: false, |
| 212 negatable: false, | 224 negatable: false, |
| 213 hide: true) | 225 hide: true) |
| 214 ..addFlag('warm-perf', | 226 ..addFlag('warm-perf', |
| 215 help: 'Show both cold and warm performance statistics', | 227 help: 'Show both cold and warm performance statistics', |
| 216 defaultsTo: false, | 228 defaultsTo: false, |
| 217 negatable: false, | 229 negatable: false, |
| 218 hide: true) | 230 hide: true) |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 | 423 |
| 412 _getNextFlagIndex(args, i) { | 424 _getNextFlagIndex(args, i) { |
| 413 for (; i < args.length; ++i) { | 425 for (; i < args.length; ++i) { |
| 414 if (args[i].startsWith('--')) { | 426 if (args[i].startsWith('--')) { |
| 415 return i; | 427 return i; |
| 416 } | 428 } |
| 417 } | 429 } |
| 418 return i; | 430 return i; |
| 419 } | 431 } |
| 420 } | 432 } |
| OLD | NEW |