| 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'; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 return new DartSdkManager( | 97 return new DartSdkManager( |
| 98 sdkPath ?? FolderBasedDartSdk.defaultSdkDirectory(resourceProvider), | 98 sdkPath ?? FolderBasedDartSdk.defaultSdkDirectory(resourceProvider), |
| 99 canUseSummaries); | 99 canUseSummaries); |
| 100 } | 100 } |
| 101 | 101 |
| 102 /** | 102 /** |
| 103 * Add the standard flags and options to the given [parser]. The standard flags | 103 * Add the standard flags and options to the given [parser]. The standard flags |
| 104 * are those that are typically used to control the way in which the code is | 104 * are those that are typically used to control the way in which the code is |
| 105 * analyzed. | 105 * analyzed. |
| 106 */ | 106 */ |
| 107 void defineAnalysisArguments(ArgParser parser) { | 107 void defineAnalysisArguments(ArgParser parser, {bool hide: true}) { |
| 108 parser.addOption(defineVariableOption, | 108 defineDDCAnalysisArguments(parser, hide: hide); |
| 109 abbr: 'D', | 109 |
| 110 allowMultiple: true, | |
| 111 help: 'Define environment variables. For example, "-Dfoo=bar" defines an ' | |
| 112 'environment variable named "foo" whose value is "bar".'); | |
| 113 parser.addOption(sdkPathOption, help: 'The path to the Dart SDK.'); | |
| 114 parser.addOption(sdkSummaryPathOption, | |
| 115 help: 'The path to the Dart SDK summary file.', hide: true); | |
| 116 parser.addOption(analysisOptionsFileOption, | 110 parser.addOption(analysisOptionsFileOption, |
| 117 help: 'Path to an analysis options file.'); | 111 help: 'Path to an analysis options file.'); |
| 118 parser.addOption(packagesOption, | 112 parser.addOption(packagesOption, |
| 119 help: 'The path to the package resolution configuration file, which ' | 113 help: 'The path to the package resolution configuration file, which ' |
| 120 'supplies a mapping of package names to paths. This option cannot be ' | 114 'supplies a mapping of package names to paths. This option cannot be ' |
| 121 'used with --package-root.'); | 115 'used with --package-root.'); |
| 122 parser.addOption(packageRootOption, | |
| 123 abbr: 'p', | |
| 124 help: 'The path to a package root directory (deprecated). This option ' | |
| 125 'cannot be used with --packages.'); | |
| 126 | 116 |
| 127 parser.addFlag(strongModeFlag, | 117 parser.addFlag(strongModeFlag, |
| 128 help: 'Enable strong static checks (https://goo.gl/DqcBsw)'); | 118 help: 'Enable strong static checks (https://goo.gl/DqcBsw)'); |
| 129 parser.addFlag(noImplicitCastsFlag, | 119 parser.addFlag(noImplicitCastsFlag, |
| 130 negatable: false, | 120 negatable: false, |
| 131 help: 'Disable implicit casts in strong mode (https://goo.gl/cTLz40)'); | 121 help: 'Disable implicit casts in strong mode (https://goo.gl/cTLz40)'); |
| 132 parser.addFlag(noImplicitDynamicFlag, | 122 parser.addFlag(noImplicitDynamicFlag, |
| 133 negatable: false, | 123 negatable: false, |
| 134 help: 'Disable implicit dynamic (https://goo.gl/m0UgXD)'); | 124 help: 'Disable implicit dynamic (https://goo.gl/m0UgXD)'); |
| 135 // | 125 // |
| 136 // Hidden flags and options. | 126 // Hidden flags and options. |
| 137 // | 127 // |
| 138 // parser.addFlag(enableNullAwareOperatorsFlag, // 'enable-null-aware-operators
' | 128 // parser.addFlag(enableNullAwareOperatorsFlag, // 'enable-null-aware-operators
' |
| 139 // help: 'Enable support for null-aware operators (DEP 9).', | 129 // help: 'Enable support for null-aware operators (DEP 9).', |
| 140 // defaultsTo: false, | 130 // defaultsTo: false, |
| 141 // negatable: false, | 131 // negatable: false, |
| 142 // hide: true); | 132 // hide: hide); |
| 143 parser.addFlag(enableStrictCallChecksFlag, | 133 parser.addFlag(enableStrictCallChecksFlag, |
| 144 help: 'Fix issue 21938.', | 134 help: 'Fix issue 21938.', |
| 145 defaultsTo: false, | 135 defaultsTo: false, |
| 146 negatable: false, | 136 negatable: false, |
| 147 hide: true); | 137 hide: hide); |
| 148 parser.addFlag(enableInitializingFormalAccessFlag, | 138 parser.addFlag(enableInitializingFormalAccessFlag, |
| 149 help: | 139 help: |
| 150 'Enable support for allowing access to field formal parameters in a ' | 140 'Enable support for allowing access to field formal parameters in a ' |
| 151 'constructor\'s initializer list', | 141 'constructor\'s initializer list', |
| 152 defaultsTo: false, | 142 defaultsTo: false, |
| 153 negatable: false, | 143 negatable: false, |
| 154 hide: true); | 144 hide: hide); |
| 155 parser.addFlag(enableSuperInMixinFlag, | 145 parser.addFlag(enableSuperInMixinFlag, |
| 156 help: 'Relax restrictions on mixins (DEP 34).', | 146 help: 'Relax restrictions on mixins (DEP 34).', |
| 157 defaultsTo: false, | 147 defaultsTo: false, |
| 158 negatable: false, | 148 negatable: false, |
| 159 hide: true); | 149 hide: hide); |
| 160 // parser.addFlag('enable_type_checks', | 150 // parser.addFlag('enable_type_checks', |
| 161 // help: 'Check types in constant evaluation.', | 151 // help: 'Check types in constant evaluation.', |
| 162 // defaultsTo: false, | 152 // defaultsTo: false, |
| 163 // negatable: false, | 153 // negatable: false, |
| 164 // hide: true); | 154 // hide: hide); |
| 165 } | 155 } |
| 166 | 156 |
| 167 /** | 157 /** |
| 158 * Add the DDC analysis flags and options to the given [parser]. |
| 159 * |
| 160 * TODO(danrubel) Update DDC to support all the options defined in |
| 161 * the [defineAnalysisOptions] method above, then have DDC call that method |
| 162 * and remove this method. |
| 163 */ |
| 164 void defineDDCAnalysisArguments(ArgParser parser, {bool hide: true}) { |
| 165 parser.addOption(defineVariableOption, |
| 166 abbr: 'D', |
| 167 allowMultiple: true, |
| 168 help: 'Define environment variables. For example, "-Dfoo=bar" defines an ' |
| 169 'environment variable named "foo" whose value is "bar".'); |
| 170 parser.addOption(sdkPathOption, help: 'The path to the Dart SDK.'); |
| 171 parser.addOption(sdkSummaryPathOption, |
| 172 help: 'The path to the Dart SDK summary file.', hide: hide); |
| 173 parser.addOption(packageRootOption, |
| 174 abbr: 'p', |
| 175 help: 'The path to a package root directory (deprecated). ' |
| 176 'This option cannot be used with --packages.'); |
| 177 } |
| 178 |
| 179 /** |
| 168 * Find arguments of the form -Dkey=value | 180 * Find arguments of the form -Dkey=value |
| 169 * or argument pairs of the form -Dkey value | 181 * or argument pairs of the form -Dkey value |
| 170 * and place those key/value pairs into [definedVariables]. | 182 * and place those key/value pairs into [definedVariables]. |
| 171 * Return a list of arguments with the key/value arguments removed. | 183 * Return a list of arguments with the key/value arguments removed. |
| 172 */ | 184 */ |
| 173 List<String> extractDefinedVariables( | 185 List<String> extractDefinedVariables( |
| 174 List<String> args, Map<String, String> definedVariables) { | 186 List<String> args, Map<String, String> definedVariables) { |
| 175 //TODO(danrubel) extracting defined variables is already handled by the | 187 //TODO(danrubel) extracting defined variables is already handled by the |
| 176 // createContextBuilderOptions method. | 188 // createContextBuilderOptions method. |
| 177 // Long term we should switch to using that instead. | 189 // Long term we should switch to using that instead. |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 .replaceAll('\r\n', '\n') | 294 .replaceAll('\r\n', '\n') |
| 283 .replaceAll('\r', '\n') | 295 .replaceAll('\r', '\n') |
| 284 .split('\n') | 296 .split('\n') |
| 285 .where((String line) => line.isNotEmpty)); | 297 .where((String line) => line.isNotEmpty)); |
| 286 } on FileSystemException catch (e) { | 298 } on FileSystemException catch (e) { |
| 287 throw new Exception('Failed to read file specified by $lastArg : $e'); | 299 throw new Exception('Failed to read file specified by $lastArg : $e'); |
| 288 } | 300 } |
| 289 } | 301 } |
| 290 return args; | 302 return args; |
| 291 } | 303 } |
| OLD | NEW |