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