Chromium Code Reviews

Side by Side Diff: pkg/analyzer/lib/src/command_line/arguments.dart

Issue 2598593003: support --options flag and other analysis options flags in DDC (Closed)
Patch Set: merge Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « no previous file | pkg/dev_compiler/lib/src/analyzer/context.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 35 matching lines...)
46 } 46 }
47 if (args.wasParsed(strongModeFlag)) { 47 if (args.wasParsed(strongModeFlag)) {
48 options.strongMode = args[strongModeFlag]; 48 options.strongMode = args[strongModeFlag];
49 } 49 }
50 } 50 }
51 51
52 /** 52 /**
53 * Use the given [resourceProvider], [contentCache] and command-line [args] to 53 * Use the given [resourceProvider], [contentCache] and command-line [args] to
54 * create a context builder. 54 * create a context builder.
55 */ 55 */
56 ContextBuilderOptions createContextBuilderOptions(ArgResults args) { 56 ContextBuilderOptions createContextBuilderOptions(ArgResults args,
57 {bool strongMode, bool trackCacheDependencies}) {
57 ContextBuilderOptions builderOptions = new ContextBuilderOptions(); 58 ContextBuilderOptions builderOptions = new ContextBuilderOptions();
58 builderOptions.argResults = args; 59 builderOptions.argResults = args;
59 // 60 //
60 // File locations. 61 // File locations.
61 // 62 //
62 builderOptions.dartSdkSummaryPath = args[sdkSummaryPathOption]; 63 builderOptions.dartSdkSummaryPath = args[sdkSummaryPathOption];
63 builderOptions.defaultAnalysisOptionsFilePath = 64 builderOptions.defaultAnalysisOptionsFilePath =
64 args[analysisOptionsFileOption]; 65 args[analysisOptionsFileOption];
65 builderOptions.defaultPackageFilePath = args[packagesOption]; 66 builderOptions.defaultPackageFilePath = args[packagesOption];
66 builderOptions.defaultPackagesDirectoryPath = args[packageRootOption]; 67 builderOptions.defaultPackagesDirectoryPath = args[packageRootOption];
67 // 68 //
68 // Analysis options. 69 // Analysis options.
69 // 70 //
70 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); 71 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl();
71 applyAnalysisOptionFlags(defaultOptions, args); 72 applyAnalysisOptionFlags(defaultOptions, args);
73 if (strongMode != null) {
74 defaultOptions.strongMode = strongMode;
75 }
76 if (trackCacheDependencies != null) {
77 defaultOptions.trackCacheDependencies = trackCacheDependencies;
78 }
72 builderOptions.defaultOptions = defaultOptions; 79 builderOptions.defaultOptions = defaultOptions;
73 // 80 //
74 // Declared variables. 81 // Declared variables.
75 // 82 //
76 Map<String, String> declaredVariables = <String, String>{}; 83 Map<String, String> declaredVariables = <String, String>{};
77 List<String> variables = args[defineVariableOption] as List<String>; 84 List<String> variables = args[defineVariableOption] as List<String>;
78 for (String variable in variables) { 85 for (String variable in variables) {
79 int index = variable.indexOf('='); 86 int index = variable.indexOf('=');
80 if (index < 0) { 87 if (index < 0) {
81 // TODO (brianwilkerson) Decide the semantics we want in this case. 88 // TODO (brianwilkerson) Decide the semantics we want in this case.
(...skipping 48 matching lines...)
130 abbr: 'D', 137 abbr: 'D',
131 allowMultiple: true, 138 allowMultiple: true,
132 help: 'Define environment variables. For example, "-Dfoo=bar" defines an ' 139 help: 'Define environment variables. For example, "-Dfoo=bar" defines an '
133 'environment variable named "foo" whose value is "bar".'); 140 'environment variable named "foo" whose value is "bar".');
134 141
135 parser.addOption(sdkPathOption, help: 'The path to the Dart SDK.'); 142 parser.addOption(sdkPathOption, help: 'The path to the Dart SDK.');
136 parser.addOption(sdkSummaryPathOption, 143 parser.addOption(sdkSummaryPathOption,
137 help: 'The path to the Dart SDK summary file.', hide: hide); 144 help: 'The path to the Dart SDK summary file.', hide: hide);
138 145
139 parser.addOption(analysisOptionsFileOption, 146 parser.addOption(analysisOptionsFileOption,
140 help: 'Path to an analysis options file.', hide: ddc); 147 help: 'Path to an analysis options file.');
141 148
142 parser.addOption(packageRootOption, 149 parser.addOption(packageRootOption,
143 abbr: 'p', 150 abbr: 'p',
144 help: 'The path to a package root directory (deprecated). ' 151 help: 'The path to a package root directory (deprecated). '
145 'This option cannot be used with --packages.'); 152 'This option cannot be used with --packages.');
146 parser.addOption(packagesOption, 153 parser.addOption(packagesOption,
147 help: 'The path to the package resolution configuration file, which ' 154 help: 'The path to the package resolution configuration file, which '
148 'supplies a mapping of package names to paths. This option cannot be ' 155 'supplies a mapping of package names to paths. This option cannot be '
149 'used with --package-root.', 156 'used with --package-root.',
150 hide: ddc); 157 hide: ddc);
151 158
152 parser.addFlag(strongModeFlag, 159 parser.addFlag(strongModeFlag,
153 help: 'Enable strong static checks (https://goo.gl/DqcBsw)', 160 help: 'Enable strong static checks (https://goo.gl/DqcBsw)',
154 defaultsTo: ddc, 161 defaultsTo: ddc);
155 hide: ddc);
156 parser.addFlag(noImplicitCastsFlag, 162 parser.addFlag(noImplicitCastsFlag,
157 negatable: false, 163 negatable: false,
158 help: 'Disable implicit casts in strong mode (https://goo.gl/cTLz40)', 164 help: 'Disable implicit casts in strong mode (https://goo.gl/cTLz40)');
159 hide: ddc);
160 parser.addFlag(noImplicitDynamicFlag, 165 parser.addFlag(noImplicitDynamicFlag,
161 negatable: false, 166 negatable: false,
162 help: 'Disable implicit dynamic (https://goo.gl/m0UgXD)', 167 help: 'Disable implicit dynamic (https://goo.gl/m0UgXD)');
163 hide: ddc);
164 // 168 //
165 // Hidden flags and options. 169 // Hidden flags and options.
166 // 170 //
167 // parser.addFlag(enableNullAwareOperatorsFlag, // 'enable-null-aware-operators ' 171 // parser.addFlag(enableNullAwareOperatorsFlag, // 'enable-null-aware-operators '
168 // help: 'Enable support for null-aware operators (DEP 9).', 172 // help: 'Enable support for null-aware operators (DEP 9).',
169 // defaultsTo: false, 173 // defaultsTo: false,
170 // negatable: false, 174 // negatable: false,
171 // hide: hide || ddc); 175 // hide: hide || ddc);
172 parser.addFlag(enableStrictCallChecksFlag, 176 parser.addFlag(enableStrictCallChecksFlag,
173 help: 'Fix issue 21938.', 177 help: 'Fix issue 21938.',
174 defaultsTo: false, 178 defaultsTo: false,
175 negatable: false, 179 negatable: false,
176 hide: hide || ddc); 180 hide: hide);
177 parser.addFlag(enableInitializingFormalAccessFlag, 181 parser.addFlag(enableInitializingFormalAccessFlag,
178 help: 182 help:
179 'Enable support for allowing access to field formal parameters in a ' 183 'Enable support for allowing access to field formal parameters in a '
180 'constructor\'s initializer list', 184 'constructor\'s initializer list',
181 defaultsTo: false, 185 defaultsTo: false,
182 negatable: false, 186 negatable: false,
183 hide: hide || ddc); 187 hide: hide || ddc);
184 parser.addFlag(enableSuperMixinFlag, 188 parser.addFlag(enableSuperMixinFlag,
185 help: 'Relax restrictions on mixins (DEP 34).', 189 help: 'Relax restrictions on mixins (DEP 34).',
186 defaultsTo: false, 190 defaultsTo: false,
187 negatable: false, 191 negatable: false,
188 hide: hide || ddc); 192 hide: hide);
189 // parser.addFlag('enable_type_checks', 193 // parser.addFlag('enable_type_checks',
190 // help: 'Check types in constant evaluation.', 194 // help: 'Check types in constant evaluation.',
191 // defaultsTo: false, 195 // defaultsTo: false,
192 // negatable: false, 196 // negatable: false,
193 // hide: hide || ddc); 197 // hide: hide || ddc);
194 } 198 }
195 199
196 /** 200 /**
197 * Find arguments of the form -Dkey=value 201 * Find arguments of the form -Dkey=value
198 * or argument pairs of the form -Dkey value 202 * or argument pairs of the form -Dkey value
(...skipping 112 matching lines...)
311 .replaceAll('\r\n', '\n') 315 .replaceAll('\r\n', '\n')
312 .replaceAll('\r', '\n') 316 .replaceAll('\r', '\n')
313 .split('\n') 317 .split('\n')
314 .where((String line) => line.isNotEmpty)); 318 .where((String line) => line.isNotEmpty));
315 } on FileSystemException catch (e) { 319 } on FileSystemException catch (e) {
316 throw new Exception('Failed to read file specified by $lastArg : $e'); 320 throw new Exception('Failed to read file specified by $lastArg : $e');
317 } 321 }
318 } 322 }
319 return args; 323 return args;
320 } 324 }
OLDNEW
« no previous file with comments | « no previous file | pkg/dev_compiler/lib/src/analyzer/context.dart » ('j') | no next file with comments »

Powered by Google App Engine