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