| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.src.command_line.arguments; | 5 library analyzer.src.command_line.arguments; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/file_system/file_system.dart'; | 9 import 'package:analyzer/file_system/file_system.dart'; |
| 10 import 'package:analyzer/src/context/builder.dart'; | 10 import 'package:analyzer/src/context/builder.dart'; |
| 11 import 'package:analyzer/src/dart/sdk/sdk.dart'; | 11 import 'package:analyzer/src/dart/sdk/sdk.dart'; |
| 12 import 'package:analyzer/src/generated/engine.dart'; | 12 import 'package:analyzer/src/generated/engine.dart'; |
| 13 import 'package:analyzer/src/generated/sdk.dart'; | 13 import 'package:analyzer/src/generated/sdk.dart'; |
| 14 import 'package:args/args.dart'; | 14 import 'package:args/args.dart'; |
| 15 import 'package:path/path.dart'; | 15 import 'package:path/path.dart'; |
| 16 | 16 |
| 17 const String analysisOptionsFileOption = 'options'; | 17 const String analysisOptionsFileOption = 'options'; |
| 18 const String defineVariableOption = 'D'; | 18 const String defineVariableOption = 'D'; |
| 19 const String enableInitializingFormalAccessFlag = 'initializing-formal-access'; | 19 const String enableInitializingFormalAccessFlag = 'initializing-formal-access'; |
| 20 const String enableStrictCallChecksFlag = 'enable-strict-call-checks'; | 20 const String enableStrictCallChecksFlag = 'enable-strict-call-checks'; |
| 21 const String enableSuperMixinFlag = 'supermixin'; | 21 const String enableSuperMixinFlag = 'supermixin'; |
| 22 const String ignoreUnrecognizedFlagsFlag = 'ignore-unrecognized-flags'; | 22 const String ignoreUnrecognizedFlagsFlag = 'ignore-unrecognized-flags'; |
| 23 const String lintsFlag = 'lints'; |
| 23 const String noImplicitCastsFlag = 'no-implicit-casts'; | 24 const String noImplicitCastsFlag = 'no-implicit-casts'; |
| 24 const String noImplicitDynamicFlag = 'no-implicit-dynamic'; | 25 const String noImplicitDynamicFlag = 'no-implicit-dynamic'; |
| 25 const String packageRootOption = 'package-root'; | 26 const String packageRootOption = 'package-root'; |
| 26 const String packagesOption = 'packages'; | 27 const String packagesOption = 'packages'; |
| 27 const String sdkPathOption = 'dart-sdk'; | 28 const String sdkPathOption = 'dart-sdk'; |
| 28 const String sdkSummaryPathOption = 'dart-sdk-summary'; | 29 const String sdkSummaryPathOption = 'dart-sdk-summary'; |
| 29 const String strongModeFlag = 'strong'; | 30 const String strongModeFlag = 'strong'; |
| 30 | 31 |
| 31 /** | 32 /** |
| 32 * Update [options] with the value of each analysis option command line flag. | 33 * Update [options] with the value of each analysis option command line flag. |
| 33 */ | 34 */ |
| 34 void applyAnalysisOptionFlags(AnalysisOptionsImpl options, ArgResults args) { | 35 void applyAnalysisOptionFlags(AnalysisOptionsImpl options, ArgResults args) { |
| 35 if (args.wasParsed(enableStrictCallChecksFlag)) { | 36 if (args.wasParsed(enableStrictCallChecksFlag)) { |
| 36 options.enableStrictCallChecks = args[enableStrictCallChecksFlag]; | 37 options.enableStrictCallChecks = args[enableStrictCallChecksFlag]; |
| 37 } | 38 } |
| 38 if (args.wasParsed(enableSuperMixinFlag)) { | 39 if (args.wasParsed(enableSuperMixinFlag)) { |
| 39 options.enableSuperMixins = args[enableSuperMixinFlag]; | 40 options.enableSuperMixins = args[enableSuperMixinFlag]; |
| 40 } | 41 } |
| 41 if (args.wasParsed(noImplicitCastsFlag)) { | 42 if (args.wasParsed(noImplicitCastsFlag)) { |
| 42 options.implicitCasts = !args[noImplicitCastsFlag]; | 43 options.implicitCasts = !args[noImplicitCastsFlag]; |
| 43 } | 44 } |
| 44 if (args.wasParsed(noImplicitDynamicFlag)) { | 45 if (args.wasParsed(noImplicitDynamicFlag)) { |
| 45 options.implicitDynamic = !args[noImplicitDynamicFlag]; | 46 options.implicitDynamic = !args[noImplicitDynamicFlag]; |
| 46 } | 47 } |
| 47 if (args.wasParsed(strongModeFlag)) { | 48 if (args.wasParsed(strongModeFlag)) { |
| 48 options.strongMode = args[strongModeFlag]; | 49 options.strongMode = args[strongModeFlag]; |
| 49 } | 50 } |
| 51 if (args.wasParsed(lintsFlag)) { |
| 52 options.lint = args[lintsFlag]; |
| 53 } |
| 50 } | 54 } |
| 51 | 55 |
| 52 /** | 56 /** |
| 53 * Use the given [resourceProvider], [contentCache] and command-line [args] to | 57 * Use the given [resourceProvider], [contentCache] and command-line [args] to |
| 54 * create a context builder. | 58 * create a context builder. |
| 55 */ | 59 */ |
| 56 ContextBuilderOptions createContextBuilderOptions(ArgResults args, | 60 ContextBuilderOptions createContextBuilderOptions(ArgResults args, |
| 57 {bool strongMode, bool trackCacheDependencies}) { | 61 {bool strongMode, bool trackCacheDependencies}) { |
| 58 ContextBuilderOptions builderOptions = new ContextBuilderOptions(); | 62 ContextBuilderOptions builderOptions = new ContextBuilderOptions(); |
| 59 builderOptions.argResults = args; | 63 builderOptions.argResults = args; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 'Enable support for allowing access to field formal parameters in a ' | 179 'Enable support for allowing access to field formal parameters in a ' |
| 176 'constructor\'s initializer list', | 180 'constructor\'s initializer list', |
| 177 defaultsTo: false, | 181 defaultsTo: false, |
| 178 negatable: false, | 182 negatable: false, |
| 179 hide: hide || ddc); | 183 hide: hide || ddc); |
| 180 parser.addFlag(enableSuperMixinFlag, | 184 parser.addFlag(enableSuperMixinFlag, |
| 181 help: 'Relax restrictions on mixins (DEP 34).', | 185 help: 'Relax restrictions on mixins (DEP 34).', |
| 182 defaultsTo: false, | 186 defaultsTo: false, |
| 183 negatable: false, | 187 negatable: false, |
| 184 hide: hide); | 188 hide: hide); |
| 189 if (!ddc) { |
| 190 parser.addFlag(lintsFlag, |
| 191 help: 'Show lint results.', defaultsTo: false, negatable: true); |
| 192 } |
| 185 } | 193 } |
| 186 | 194 |
| 187 /** | 195 /** |
| 188 * Find arguments of the form -Dkey=value | 196 * Find arguments of the form -Dkey=value |
| 189 * or argument pairs of the form -Dkey value | 197 * or argument pairs of the form -Dkey value |
| 190 * and place those key/value pairs into [definedVariables]. | 198 * and place those key/value pairs into [definedVariables]. |
| 191 * Return a list of arguments with the key/value arguments removed. | 199 * Return a list of arguments with the key/value arguments removed. |
| 192 */ | 200 */ |
| 193 List<String> extractDefinedVariables( | 201 List<String> extractDefinedVariables( |
| 194 List<String> args, Map<String, String> definedVariables) { | 202 List<String> args, Map<String, String> definedVariables) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 .replaceAll('\r\n', '\n') | 310 .replaceAll('\r\n', '\n') |
| 303 .replaceAll('\r', '\n') | 311 .replaceAll('\r', '\n') |
| 304 .split('\n') | 312 .split('\n') |
| 305 .where((String line) => line.isNotEmpty)); | 313 .where((String line) => line.isNotEmpty)); |
| 306 } on FileSystemException catch (e) { | 314 } on FileSystemException catch (e) { |
| 307 throw new Exception('Failed to read file specified by $lastArg : $e'); | 315 throw new Exception('Failed to read file specified by $lastArg : $e'); |
| 308 } | 316 } |
| 309 } | 317 } |
| 310 return args; | 318 return args; |
| 311 } | 319 } |
| OLD | NEW |