| 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 /** Whether to enable support for the proposed enum feature. */ | |
| 30 final bool enableEnum; | |
| 31 | |
| 32 /** | 29 /** |
| 33 * Whether to treat type mismatches found during constant evaluation as | 30 * Whether to treat type mismatches found during constant evaluation as |
| 34 * errors. | 31 * errors. |
| 35 */ | 32 */ |
| 36 final bool enableTypeChecks; | 33 final bool enableTypeChecks; |
| 37 | 34 |
| 38 /** Whether to ignore unrecognized flags */ | 35 /** Whether to ignore unrecognized flags */ |
| 39 final bool ignoreUnrecognizedFlags; | 36 final bool ignoreUnrecognizedFlags; |
| 40 | 37 |
| 41 /** Whether to log additional analysis messages and exceptions */ | 38 /** Whether to log additional analysis messages and exceptions */ |
| (...skipping 28 matching lines...) Expand all Loading... |
| 70 | 67 |
| 71 /** | 68 /** |
| 72 * Initialize options from the given parsed [args]. | 69 * Initialize options from the given parsed [args]. |
| 73 */ | 70 */ |
| 74 CommandLineOptions._fromArgs(ArgResults args, Map<String, | 71 CommandLineOptions._fromArgs(ArgResults args, Map<String, |
| 75 String> definedVariables) | 72 String> definedVariables) |
| 76 : dartSdkPath = args['dart-sdk'], | 73 : dartSdkPath = args['dart-sdk'], |
| 77 this.definedVariables = definedVariables, | 74 this.definedVariables = definedVariables, |
| 78 disableHints = args['no-hints'], | 75 disableHints = args['no-hints'], |
| 79 displayVersion = args['version'], | 76 displayVersion = args['version'], |
| 80 enableEnum = args['enable-enum'], | |
| 81 enableTypeChecks = args['enable_type_checks'], | 77 enableTypeChecks = args['enable_type_checks'], |
| 82 ignoreUnrecognizedFlags = args['ignore-unrecognized-flags'], | 78 ignoreUnrecognizedFlags = args['ignore-unrecognized-flags'], |
| 83 log = args['log'], | 79 log = args['log'], |
| 84 machineFormat = args['machine'] || args['format'] == 'machine', | 80 machineFormat = args['machine'] || args['format'] == 'machine', |
| 85 packageRootPath = args['package-root'], | 81 packageRootPath = args['package-root'], |
| 86 perf = args['perf'], | 82 perf = args['perf'], |
| 87 shouldBatch = args['batch'], | 83 shouldBatch = args['batch'], |
| 88 showPackageWarnings = args['show-package-warnings'] || | 84 showPackageWarnings = args['show-package-warnings'] || |
| 89 args['package-warnings'], | 85 args['package-warnings'], |
| 90 showSdkWarnings = args['show-sdk-warnings'] || args['warnings'], | 86 showSdkWarnings = args['show-sdk-warnings'] || args['warnings'], |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 402 |
| 407 _getNextFlagIndex(args, i) { | 403 _getNextFlagIndex(args, i) { |
| 408 for ( ; i < args.length; ++i) { | 404 for ( ; i < args.length; ++i) { |
| 409 if (args[i].startsWith('--')) { | 405 if (args[i].startsWith('--')) { |
| 410 return i; | 406 return i; |
| 411 } | 407 } |
| 412 } | 408 } |
| 413 return i; | 409 return i; |
| 414 } | 410 } |
| 415 } | 411 } |
| OLD | NEW |