Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1192)

Side by Side Diff: pkg/analyzer_cli/lib/src/options.dart

Issue 2844663003: Fix some issues with options handling (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer_cli/lib/src/driver.dart ('k') | no next file » | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 import 'dart:io'; 5 import 'dart:io';
6 6
7 import 'package:analyzer/file_system/physical_file_system.dart'; 7 import 'package:analyzer/file_system/physical_file_system.dart';
8 import 'package:analyzer/src/command_line/arguments.dart'; 8 import 'package:analyzer/src/command_line/arguments.dart';
9 import 'package:analyzer/src/context/builder.dart'; 9 import 'package:analyzer/src/context/builder.dart';
10 import 'package:analyzer_cli/src/ansi.dart' as ansi; 10 import 'package:analyzer_cli/src/ansi.dart' as ansi;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 bool get enableSuperMixins => 218 bool get enableSuperMixins =>
219 contextBuilderOptions.defaultOptions.enableSuperMixins; 219 contextBuilderOptions.defaultOptions.enableSuperMixins;
220 220
221 /// The path to a `.packages` configuration file 221 /// The path to a `.packages` configuration file
222 String get packageConfigPath => contextBuilderOptions.defaultPackageFilePath; 222 String get packageConfigPath => contextBuilderOptions.defaultPackageFilePath;
223 223
224 /// The path to the package root 224 /// The path to the package root
225 String get packageRootPath => 225 String get packageRootPath =>
226 contextBuilderOptions.defaultPackagesDirectoryPath; 226 contextBuilderOptions.defaultPackagesDirectoryPath;
227 227
228 /// The source files to analyze
229 List<String> get sourceFiles => _sourceFiles;
230
231 /// Replace the sourceFiles parsed from the command line.
232 void rewriteSourceFiles(List<String> newSourceFiles) {
233 _sourceFiles = newSourceFiles;
234 }
235
228 /// Parse [args] into [CommandLineOptions] describing the specified 236 /// Parse [args] into [CommandLineOptions] describing the specified
229 /// analyzer options. In case of a format error, calls [printAndFail], which 237 /// analyzer options. In case of a format error, calls [printAndFail], which
230 /// by default prints an error message to stderr and exits. 238 /// by default prints an error message to stderr and exits.
231 static CommandLineOptions parse(List<String> args, 239 static CommandLineOptions parse(List<String> args,
232 [printAndFail(String msg) = printAndFail]) { 240 [printAndFail(String msg) = printAndFail]) {
233 CommandLineOptions options = _parse(args); 241 CommandLineOptions options = _parse(args);
234 // Check SDK. 242 // Check SDK.
235 if (!options.buildModePersistentWorker) { 243 if (!options.buildModePersistentWorker) {
236 // Infer if unspecified. 244 // Infer if unspecified.
237 if (options.dartSdkPath == null) { 245 if (options.dartSdkPath == null) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 options.buildSummaryUnlinkedInputs.isNotEmpty) { 295 options.buildSummaryUnlinkedInputs.isNotEmpty) {
288 printAndFail('No summaries should be provided in combination with ' 296 printAndFail('No summaries should be provided in combination with '
289 '--build-summary-only-unlinked, they aren\'t needed.'); 297 '--build-summary-only-unlinked, they aren\'t needed.');
290 return null; // Only reachable in testing. 298 return null; // Only reachable in testing.
291 } 299 }
292 } 300 }
293 301
294 return options; 302 return options;
295 } 303 }
296 304
297 /// The source files to analyze
298 List<String> get sourceFiles => _sourceFiles;
299
300 /// Replace the sourceFiles parsed from the command line.
301 void rewriteSourceFiles(List<String> newSourceFiles) {
302 _sourceFiles = newSourceFiles;
303 }
304
305 static String _getVersion() { 305 static String _getVersion() {
306 try { 306 try {
307 // This is relative to bin/snapshot, so ../.. 307 // This is relative to bin/snapshot, so ../..
308 String versionPath = 308 String versionPath =
309 Platform.script.resolve('../../version').toFilePath(); 309 Platform.script.resolve('../../version').toFilePath();
310 File versionFile = new File(versionPath); 310 File versionFile = new File(versionPath);
311 return versionFile.readAsStringSync().trim(); 311 return versionFile.readAsStringSync().trim();
312 } catch (_) { 312 } catch (_) {
313 // This happens when the script is not running in the context of an SDK. 313 // This happens when the script is not running in the context of an SDK.
314 return "<unknown>"; 314 return "<unknown>";
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 defaultsTo: false, 477 defaultsTo: false,
478 negatable: false, 478 negatable: false,
479 hide: hide) 479 hide: hide)
480 ..addFlag('enable_type_checks', 480 ..addFlag('enable_type_checks',
481 help: 'Check types in constant evaluation.', 481 help: 'Check types in constant evaluation.',
482 defaultsTo: false, 482 defaultsTo: false,
483 negatable: false, 483 negatable: false,
484 hide: hide) 484 hide: hide)
485 ..addFlag('enable-assert-initializers', 485 ..addFlag('enable-assert-initializers',
486 help: 'Enable parsing of asserts in constructor initializers.', 486 help: 'Enable parsing of asserts in constructor initializers.',
487 defaultsTo: false, 487 defaultsTo: null,
488 negatable: false, 488 negatable: false,
489 hide: hide) 489 hide: hide)
490 ..addFlag('use-analysis-driver-memory-byte-store', 490 ..addFlag('use-analysis-driver-memory-byte-store',
491 help: 'Use memory byte store, not the file system cache.', 491 help: 'Use memory byte store, not the file system cache.',
492 defaultsTo: false, 492 defaultsTo: false,
493 negatable: false, 493 negatable: false,
494 hide: hide) 494 hide: hide)
495 ..addOption('url-mapping', 495 ..addOption('url-mapping',
496 help: '--url-mapping=libraryUri,/path/to/library.dart directs the ' 496 help: '--url-mapping=libraryUri,/path/to/library.dart directs the '
497 'analyzer to use "library.dart" as the source for an import ' 497 'analyzer to use "library.dart" as the source for an import '
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 'Usage: $_binaryName [options...] <directory or list of files>'); 568 'Usage: $_binaryName [options...] <directory or list of files>');
569 errorSink.writeln(''); 569 errorSink.writeln('');
570 errorSink.writeln(parser.usage); 570 errorSink.writeln(parser.usage);
571 errorSink.writeln(''); 571 errorSink.writeln('');
572 errorSink.writeln(''' 572 errorSink.writeln('''
573 Run "dartanalyzer -h -v" for verbose help output, including less commonly used o ptions. 573 Run "dartanalyzer -h -v" for verbose help output, including less commonly used o ptions.
574 For more information, see http://www.dartlang.org/tools/analyzer. 574 For more information, see http://www.dartlang.org/tools/analyzer.
575 '''); 575 ''');
576 } 576 }
577 } 577 }
OLDNEW
« no previous file with comments | « pkg/analyzer_cli/lib/src/driver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698