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