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

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

Issue 1986943002: CLI cleanup. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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/build_mode.dart ('k') | pkg/analyzer_cli/lib/starter.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) 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 library analyzer_cli.src.driver; 5 library analyzer_cli.src.driver;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 10
11 import 'package:analyzer/file_system/file_system.dart' as fileSystem; 11 import 'package:analyzer/file_system/file_system.dart' as file_system;
12 import 'package:analyzer/file_system/physical_file_system.dart'; 12 import 'package:analyzer/file_system/physical_file_system.dart';
13 import 'package:analyzer/plugin/embedded_resolver_provider.dart'; 13 import 'package:analyzer/plugin/embedded_resolver_provider.dart';
14 import 'package:analyzer/plugin/options.dart'; 14 import 'package:analyzer/plugin/options.dart';
15 import 'package:analyzer/plugin/resolver_provider.dart'; 15 import 'package:analyzer/plugin/resolver_provider.dart';
16 import 'package:analyzer/source/analysis_options_provider.dart'; 16 import 'package:analyzer/source/analysis_options_provider.dart';
17 import 'package:analyzer/source/embedder.dart'; 17 import 'package:analyzer/source/embedder.dart';
18 import 'package:analyzer/source/package_map_provider.dart'; 18 import 'package:analyzer/source/package_map_provider.dart';
19 import 'package:analyzer/source/package_map_resolver.dart'; 19 import 'package:analyzer/source/package_map_resolver.dart';
20 import 'package:analyzer/source/pub_package_map_provider.dart'; 20 import 'package:analyzer/source/pub_package_map_provider.dart';
21 import 'package:analyzer/source/sdk_ext.dart'; 21 import 'package:analyzer/source/sdk_ext.dart';
(...skipping 12 matching lines...) Expand all
34 import 'package:analyzer/src/services/lint.dart'; 34 import 'package:analyzer/src/services/lint.dart';
35 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk; 35 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk;
36 import 'package:analyzer/src/task/options.dart'; 36 import 'package:analyzer/src/task/options.dart';
37 import 'package:analyzer_cli/src/analyzer_impl.dart'; 37 import 'package:analyzer_cli/src/analyzer_impl.dart';
38 import 'package:analyzer_cli/src/build_mode.dart'; 38 import 'package:analyzer_cli/src/build_mode.dart';
39 import 'package:analyzer_cli/src/error_formatter.dart'; 39 import 'package:analyzer_cli/src/error_formatter.dart';
40 import 'package:analyzer_cli/src/options.dart'; 40 import 'package:analyzer_cli/src/options.dart';
41 import 'package:analyzer_cli/src/perf_report.dart'; 41 import 'package:analyzer_cli/src/perf_report.dart';
42 import 'package:analyzer_cli/starter.dart'; 42 import 'package:analyzer_cli/starter.dart';
43 import 'package:linter/src/plugin/linter_plugin.dart'; 43 import 'package:linter/src/plugin/linter_plugin.dart';
44 import 'package:package_config/discovery.dart' as pkgDiscovery; 44 import 'package:package_config/discovery.dart' as pkg_discovery;
45 import 'package:package_config/packages.dart' show Packages; 45 import 'package:package_config/packages.dart' show Packages;
46 import 'package:package_config/packages_file.dart' as pkgfile show parse; 46 import 'package:package_config/packages_file.dart' as pkgfile show parse;
47 import 'package:package_config/src/packages_impl.dart' show MapPackages; 47 import 'package:package_config/src/packages_impl.dart' show MapPackages;
48 import 'package:path/path.dart' as path; 48 import 'package:path/path.dart' as path;
49 import 'package:plugin/manager.dart'; 49 import 'package:plugin/manager.dart';
50 import 'package:plugin/plugin.dart'; 50 import 'package:plugin/plugin.dart';
51 import 'package:yaml/yaml.dart'; 51 import 'package:yaml/yaml.dart';
52 52
53 /// Shared IO sink for standard error reporting. 53 /// Shared IO sink for standard error reporting.
54 /// 54 ///
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 /// Collected analysis statistics. 98 /// Collected analysis statistics.
99 final AnalysisStats stats = new AnalysisStats(); 99 final AnalysisStats stats = new AnalysisStats();
100 100
101 /// This Driver's current analysis context. 101 /// This Driver's current analysis context.
102 /// 102 ///
103 /// *Visible for testing.* 103 /// *Visible for testing.*
104 AnalysisContext get context => _context; 104 AnalysisContext get context => _context;
105 105
106 @override 106 @override
107 void set userDefinedPlugins(List<Plugin> plugins) { 107 set userDefinedPlugins(List<Plugin> plugins) {
Brian Wilkerson 2016/05/18 14:42:19 Personally, I like having "void" for setters. I kn
pquitslund 2016/05/18 17:26:40 Got it. It should come as no surprise that I tend
108 _userDefinedPlugins = plugins ?? <Plugin>[]; 108 _userDefinedPlugins = plugins ?? <Plugin>[];
109 } 109 }
110 110
111 @override 111 @override
112 void start(List<String> args) { 112 void start(List<String> args) {
113 if (_context != null) { 113 if (_context != null) {
114 throw new StateError("start() can only be called once"); 114 throw new StateError("start() can only be called once");
115 } 115 }
116 int startTime = new DateTime.now().millisecondsSinceEpoch; 116 int startTime = new DateTime.now().millisecondsSinceEpoch;
117 117
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 // diagnostics. (Full parse is still needed for "self" packages.) 324 // diagnostics. (Full parse is still needed for "self" packages.)
325 return true; 325 return true;
326 } 326 }
327 }; 327 };
328 } 328 }
329 329
330 /// Decide on the appropriate method for resolving URIs based on the given 330 /// Decide on the appropriate method for resolving URIs based on the given
331 /// [options] and [customUrlMappings] settings, and return a 331 /// [options] and [customUrlMappings] settings, and return a
332 /// [SourceFactory] that has been configured accordingly. 332 /// [SourceFactory] that has been configured accordingly.
333 SourceFactory _chooseUriResolutionPolicy(CommandLineOptions options, 333 SourceFactory _chooseUriResolutionPolicy(CommandLineOptions options,
334 Map<fileSystem.Folder, YamlMap> embedderMap, _PackageInfo packageInfo) { 334 Map<file_system.Folder, YamlMap> embedderMap, _PackageInfo packageInfo) {
335 // Create a custom package resolver if one has been specified. 335 // Create a custom package resolver if one has been specified.
336 if (packageResolverProvider != null) { 336 if (packageResolverProvider != null) {
337 fileSystem.Folder folder = 337 file_system.Folder folder =
338 PhysicalResourceProvider.INSTANCE.getResource('.'); 338 PhysicalResourceProvider.INSTANCE.getResource('.');
339 UriResolver resolver = packageResolverProvider(folder); 339 UriResolver resolver = packageResolverProvider(folder);
340 if (resolver != null) { 340 if (resolver != null) {
341 UriResolver sdkResolver; 341 UriResolver sdkResolver;
342 342
343 // Check for a resolver provider. 343 // Check for a resolver provider.
344 if (embeddedUriResolverProvider != null) { 344 if (embeddedUriResolverProvider != null) {
345 EmbedderUriResolver embedderUriResolver = 345 EmbedderUriResolver embedderUriResolver =
346 embeddedUriResolverProvider(folder); 346 embeddedUriResolverProvider(folder);
347 if (embedderUriResolver != null && embedderUriResolver.length != 0) { 347 if (embedderUriResolver != null && embedderUriResolver.length != 0) {
(...skipping 18 matching lines...) Expand all
366 366
367 if (options.packageRootPath != null) { 367 if (options.packageRootPath != null) {
368 JavaFile packageDirectory = new JavaFile(options.packageRootPath); 368 JavaFile packageDirectory = new JavaFile(options.packageRootPath);
369 packageUriResolver = new PackageUriResolver([packageDirectory]); 369 packageUriResolver = new PackageUriResolver([packageDirectory]);
370 } else if (options.packageConfigPath == null) { 370 } else if (options.packageConfigPath == null) {
371 // TODO(pq): remove? 371 // TODO(pq): remove?
372 if (packageInfo.packageMap == null) { 372 if (packageInfo.packageMap == null) {
373 // Fall back to pub list-package-dirs. 373 // Fall back to pub list-package-dirs.
374 PubPackageMapProvider pubPackageMapProvider = 374 PubPackageMapProvider pubPackageMapProvider =
375 new PubPackageMapProvider(PhysicalResourceProvider.INSTANCE, sdk); 375 new PubPackageMapProvider(PhysicalResourceProvider.INSTANCE, sdk);
376 fileSystem.Resource cwd = 376 file_system.Resource cwd =
377 PhysicalResourceProvider.INSTANCE.getResource('.'); 377 PhysicalResourceProvider.INSTANCE.getResource('.');
378 PackageMapInfo packageMapInfo = 378 PackageMapInfo packageMapInfo =
379 pubPackageMapProvider.computePackageMap(cwd); 379 pubPackageMapProvider.computePackageMap(cwd);
380 Map<String, List<fileSystem.Folder>> packageMap = 380 Map<String, List<file_system.Folder>> packageMap =
381 packageMapInfo.packageMap; 381 packageMapInfo.packageMap;
382 382
383 // Only create a packageUriResolver if pub list-package-dirs succeeded. 383 // Only create a packageUriResolver if pub list-package-dirs succeeded.
384 // If it failed, that's not a problem; it simply means we have no way 384 // If it failed, that's not a problem; it simply means we have no way
385 // to resolve packages. 385 // to resolve packages.
386 if (packageMapInfo.packageMap != null) { 386 if (packageMapInfo.packageMap != null) {
387 packageUriResolver = new PackageMapUriResolver( 387 packageUriResolver = new PackageMapUriResolver(
388 PhysicalResourceProvider.INSTANCE, packageMap); 388 PhysicalResourceProvider.INSTANCE, packageMap);
389 } 389 }
390 } 390 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 _chooseDietParsingPolicy(options); 485 _chooseDietParsingPolicy(options);
486 setAnalysisContextOptions(_context, options, 486 setAnalysisContextOptions(_context, options,
487 (AnalysisOptionsImpl contextOptions) { 487 (AnalysisOptionsImpl contextOptions) {
488 contextOptions.analyzeFunctionBodiesPredicate = dietParsingPolicy; 488 contextOptions.analyzeFunctionBodiesPredicate = dietParsingPolicy;
489 }); 489 });
490 490
491 // Find package info. 491 // Find package info.
492 _PackageInfo packageInfo = _findPackages(options); 492 _PackageInfo packageInfo = _findPackages(options);
493 493
494 // Process embedders. 494 // Process embedders.
495 Map<fileSystem.Folder, YamlMap> embedderMap = 495 Map<file_system.Folder, YamlMap> embedderMap =
496 _findEmbedders(packageInfo.packageMap); 496 _findEmbedders(packageInfo.packageMap);
497 497
498 // Scan for SDK extenders. 498 // Scan for SDK extenders.
499 bool hasSdkExt = _hasSdkExt(packageInfo.packageMap?.values); 499 bool hasSdkExt = _hasSdkExt(packageInfo.packageMap?.values);
500 500
501 // No summaries in the presence of embedders or extenders. 501 // No summaries in the presence of embedders or extenders.
502 bool useSummaries = embedderMap.isEmpty && !hasSdkExt; 502 bool useSummaries = embedderMap.isEmpty && !hasSdkExt;
503 503
504 // Once options and embedders are processed, setup the SDK. 504 // Once options and embedders are processed, setup the SDK.
505 _setupSdk(options, useSummaries); 505 _setupSdk(options, useSummaries);
506 506
507 // Choose a package resolution policy and a diet parsing policy based on 507 // Choose a package resolution policy and a diet parsing policy based on
508 // the command-line options. 508 // the command-line options.
509 SourceFactory sourceFactory = 509 SourceFactory sourceFactory =
510 _chooseUriResolutionPolicy(options, embedderMap, packageInfo); 510 _chooseUriResolutionPolicy(options, embedderMap, packageInfo);
511 511
512 _context.sourceFactory = sourceFactory; 512 _context.sourceFactory = sourceFactory;
513 } 513 }
514 514
515 /// Return discovered packagespec, or `null` if none is found. 515 /// Return discovered packagespec, or `null` if none is found.
516 Packages _discoverPackagespec(Uri root) { 516 Packages _discoverPackagespec(Uri root) {
517 try { 517 try {
518 Packages packages = pkgDiscovery.findPackagesFromFile(root); 518 Packages packages = pkg_discovery.findPackagesFromFile(root);
519 if (packages != Packages.noPackages) { 519 if (packages != Packages.noPackages) {
520 return packages; 520 return packages;
521 } 521 }
522 } catch (_) { 522 } catch (_) {
523 // Ignore and fall through to null. 523 // Ignore and fall through to null.
524 } 524 }
525 525
526 return null; 526 return null;
527 } 527 }
528 528
529 Map<fileSystem.Folder, YamlMap> _findEmbedders( 529 Map<file_system.Folder, YamlMap> _findEmbedders(
530 Map<String, List<fileSystem.Folder>> packageMap) { 530 Map<String, List<file_system.Folder>> packageMap) {
531 EmbedderYamlLocator locator = 531 EmbedderYamlLocator locator =
532 (_context as InternalAnalysisContext).embedderYamlLocator; 532 (_context as InternalAnalysisContext).embedderYamlLocator;
533 locator.refresh(packageMap); 533 locator.refresh(packageMap);
534 return locator.embedderYamls; 534 return locator.embedderYamls;
535 } 535 }
536 536
537 _PackageInfo _findPackages(CommandLineOptions options) { 537 _PackageInfo _findPackages(CommandLineOptions options) {
538 if (packageResolverProvider != null) { 538 if (packageResolverProvider != null) {
539 // The resolver provider will do all the work later. 539 // The resolver provider will do all the work later.
540 return null; 540 return null;
541 } 541 }
542 542
543 Packages packages; 543 Packages packages;
544 Map<String, List<fileSystem.Folder>> packageMap; 544 Map<String, List<file_system.Folder>> packageMap;
545 545
546 if (options.packageConfigPath != null) { 546 if (options.packageConfigPath != null) {
547 String packageConfigPath = options.packageConfigPath; 547 String packageConfigPath = options.packageConfigPath;
548 Uri fileUri = new Uri.file(packageConfigPath); 548 Uri fileUri = new Uri.file(packageConfigPath);
549 try { 549 try {
550 File configFile = new File.fromUri(fileUri).absolute; 550 File configFile = new File.fromUri(fileUri).absolute;
551 List<int> bytes = configFile.readAsBytesSync(); 551 List<int> bytes = configFile.readAsBytesSync();
552 Map<String, Uri> map = pkgfile.parse(bytes, configFile.uri); 552 Map<String, Uri> map = pkgfile.parse(bytes, configFile.uri);
553 packages = new MapPackages(map); 553 packages = new MapPackages(map);
554 packageMap = _getPackageMap(packages); 554 packageMap = _getPackageMap(packages);
555 } catch (e) { 555 } catch (e) {
556 printAndFail( 556 printAndFail(
557 'Unable to read package config data from $packageConfigPath: $e'); 557 'Unable to read package config data from $packageConfigPath: $e');
558 } 558 }
559 } else if (options.packageRootPath != null) { 559 } else if (options.packageRootPath != null) {
560 packageMap = _PackageRootPackageMapBuilder 560 packageMap = _PackageRootPackageMapBuilder
561 .buildPackageMap(options.packageRootPath); 561 .buildPackageMap(options.packageRootPath);
562 } else { 562 } else {
563 fileSystem.Resource cwd = 563 file_system.Resource cwd =
564 PhysicalResourceProvider.INSTANCE.getResource('.'); 564 PhysicalResourceProvider.INSTANCE.getResource('.');
565 // Look for .packages. 565 // Look for .packages.
566 packages = _discoverPackagespec(new Uri.directory(cwd.path)); 566 packages = _discoverPackagespec(new Uri.directory(cwd.path));
567 packageMap = _getPackageMap(packages); 567 packageMap = _getPackageMap(packages);
568 } 568 }
569 569
570 return new _PackageInfo(packages, packageMap); 570 return new _PackageInfo(packages, packageMap);
571 } 571 }
572 572
573 Map<String, List<fileSystem.Folder>> _getPackageMap(Packages packages) { 573 Map<String, List<file_system.Folder>> _getPackageMap(Packages packages) {
574 if (packages == null) { 574 if (packages == null) {
575 return null; 575 return null;
576 } 576 }
577 577
578 Map<String, List<fileSystem.Folder>> folderMap = 578 Map<String, List<file_system.Folder>> folderMap =
579 new Map<String, List<fileSystem.Folder>>(); 579 new Map<String, List<file_system.Folder>>();
580 packages.asMap().forEach((String packagePath, Uri uri) { 580 packages.asMap().forEach((String packagePath, Uri uri) {
581 folderMap[packagePath] = [ 581 folderMap[packagePath] = [
582 PhysicalResourceProvider.INSTANCE.getFolder(path.fromUri(uri)) 582 PhysicalResourceProvider.INSTANCE.getFolder(path.fromUri(uri))
583 ]; 583 ];
584 }); 584 });
585 return folderMap; 585 return folderMap;
586 } 586 }
587 587
588 bool _hasSdkExt(Iterable<List<fileSystem.Folder>> folders) { 588 bool _hasSdkExt(Iterable<List<file_system.Folder>> folders) {
589 if (folders != null) { 589 if (folders != null) {
590 //TODO: ideally share this traversal with SdkExtUriResolver 590 //TODO: ideally share this traversal with SdkExtUriResolver
591 for (Iterable<fileSystem.Folder> libDirs in folders) { 591 for (Iterable<file_system.Folder> libDirs in folders) {
592 if (libDirs.any((fileSystem.Folder libDir) => 592 if (libDirs.any((file_system.Folder libDir) =>
593 libDir.getChild(SdkExtUriResolver.SDK_EXT_NAME).exists)) { 593 libDir.getChild(SdkExtUriResolver.SDK_EXT_NAME).exists)) {
594 return true; 594 return true;
595 } 595 }
596 } 596 }
597 } 597 }
598 return false; 598 return false;
599 } 599 }
600 600
601 /// Returns `true` if this relative path is a hidden directory. 601 /// Returns `true` if this relative path is a hidden directory.
602 bool _isInHiddenDir(String relative) => 602 bool _isInHiddenDir(String relative) =>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 contextOptions.lint = options.lints; 662 contextOptions.lint = options.lints;
663 contextOptions.strongMode = options.strongMode; 663 contextOptions.strongMode = options.strongMode;
664 return contextOptions; 664 return contextOptions;
665 } 665 }
666 666
667 static void setAnalysisContextOptions( 667 static void setAnalysisContextOptions(
668 AnalysisContext context, 668 AnalysisContext context,
669 CommandLineOptions options, 669 CommandLineOptions options,
670 void configureContextOptions(AnalysisOptionsImpl contextOptions)) { 670 void configureContextOptions(AnalysisOptionsImpl contextOptions)) {
671 Map<String, String> definedVariables = options.definedVariables; 671 Map<String, String> definedVariables = options.definedVariables;
672 if (!definedVariables.isEmpty) { 672 if (definedVariables.isNotEmpty) {
673 DeclaredVariables declaredVariables = context.declaredVariables; 673 DeclaredVariables declaredVariables = context.declaredVariables;
674 definedVariables.forEach((String variableName, String value) { 674 definedVariables.forEach((String variableName, String value) {
675 declaredVariables.define(variableName, value); 675 declaredVariables.define(variableName, value);
676 }); 676 });
677 } 677 }
678 678
679 if (options.log) { 679 if (options.log) {
680 AnalysisEngine.instance.logger = new StdLogger(); 680 AnalysisEngine.instance.logger = new StdLogger();
681 } 681 }
682 682
(...skipping 15 matching lines...) Expand all
698 return false; 698 return false;
699 } 699 }
700 for (String key in m1.keys) { 700 for (String key in m1.keys) {
701 if (!m2.containsKey(key) || m1[key] != m2[key]) { 701 if (!m2.containsKey(key) || m1[key] != m2[key]) {
702 return false; 702 return false;
703 } 703 }
704 } 704 }
705 return true; 705 return true;
706 } 706 }
707 707
708 static fileSystem.File _getOptionsFile(CommandLineOptions options) { 708 static file_system.File _getOptionsFile(CommandLineOptions options) {
709 fileSystem.File file; 709 file_system.File file;
710 String filePath = options.analysisOptionsFile; 710 String filePath = options.analysisOptionsFile;
711 if (filePath != null) { 711 if (filePath != null) {
712 file = PhysicalResourceProvider.INSTANCE.getFile(filePath); 712 file = PhysicalResourceProvider.INSTANCE.getFile(filePath);
713 if (!file.exists) { 713 if (!file.exists) {
714 printAndFail('Options file not found: $filePath', 714 printAndFail('Options file not found: $filePath',
715 exitCode: ErrorSeverity.ERROR.ordinal); 715 exitCode: ErrorSeverity.ERROR.ordinal);
716 } 716 }
717 } else { 717 } else {
718 filePath = AnalysisEngine.ANALYSIS_OPTIONS_FILE; 718 filePath = AnalysisEngine.ANALYSIS_OPTIONS_FILE;
719 file = PhysicalResourceProvider.INSTANCE.getFile(filePath); 719 file = PhysicalResourceProvider.INSTANCE.getFile(filePath);
720 if (!file.exists) { 720 if (!file.exists) {
721 filePath = AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE; 721 filePath = AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE;
722 file = PhysicalResourceProvider.INSTANCE.getFile(filePath); 722 file = PhysicalResourceProvider.INSTANCE.getFile(filePath);
723 } 723 }
724 } 724 }
725 return file; 725 return file;
726 } 726 }
727 727
728 /// Convert [sourcePath] into an absolute path. 728 /// Convert [sourcePath] into an absolute path.
729 static String _normalizeSourcePath(String sourcePath) => 729 static String _normalizeSourcePath(String sourcePath) =>
730 path.normalize(new File(sourcePath).absolute.path); 730 path.normalize(new File(sourcePath).absolute.path);
731 731
732 static void _processAnalysisOptions( 732 static void _processAnalysisOptions(
733 AnalysisContext context, CommandLineOptions options) { 733 AnalysisContext context, CommandLineOptions options) {
734 fileSystem.File file = _getOptionsFile(options); 734 file_system.File file = _getOptionsFile(options);
735 List<OptionsProcessor> optionsProcessors = 735 List<OptionsProcessor> optionsProcessors =
736 AnalysisEngine.instance.optionsPlugin.optionsProcessors; 736 AnalysisEngine.instance.optionsPlugin.optionsProcessors;
737 try { 737 try {
738 AnalysisOptionsProvider analysisOptionsProvider = 738 AnalysisOptionsProvider analysisOptionsProvider =
739 new AnalysisOptionsProvider(); 739 new AnalysisOptionsProvider();
740 Map<String, YamlNode> optionMap = 740 Map<String, YamlNode> optionMap =
741 analysisOptionsProvider.getOptionsFromFile(file); 741 analysisOptionsProvider.getOptionsFromFile(file);
742 optionsProcessors.forEach( 742 optionsProcessors.forEach(
743 (OptionsProcessor p) => p.optionsProcessed(context, optionMap)); 743 (OptionsProcessor p) => p.optionsProcessed(context, optionMap));
744 744
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 } 816 }
817 } 817 }
818 818
819 class _DriverError implements Exception { 819 class _DriverError implements Exception {
820 String msg; 820 String msg;
821 _DriverError(this.msg); 821 _DriverError(this.msg);
822 } 822 }
823 823
824 class _PackageInfo { 824 class _PackageInfo {
825 Packages packages; 825 Packages packages;
826 Map<String, List<fileSystem.Folder>> packageMap; 826 Map<String, List<file_system.Folder>> packageMap;
827 _PackageInfo(this.packages, this.packageMap); 827 _PackageInfo(this.packages, this.packageMap);
828 } 828 }
829 829
830 /// [SdkExtUriResolver] needs a Map from package name to folder. In the case 830 /// [SdkExtUriResolver] needs a Map from package name to folder. In the case
831 /// that the analyzer is invoked with a --package-root option, we need to 831 /// that the analyzer is invoked with a --package-root option, we need to
832 /// manually create this mapping. Given [packageRootPath], 832 /// manually create this mapping. Given [packageRootPath],
833 /// [_PackageRootPackageMapBuilder] creates a simple mapping from package name 833 /// [_PackageRootPackageMapBuilder] creates a simple mapping from package name
834 /// to full path on disk (resolving any symbolic links). 834 /// to full path on disk (resolving any symbolic links).
835 class _PackageRootPackageMapBuilder { 835 class _PackageRootPackageMapBuilder {
836 static Map<String, List<fileSystem.Folder>> buildPackageMap( 836 static Map<String, List<file_system.Folder>> buildPackageMap(
837 String packageRootPath) { 837 String packageRootPath) {
838 var packageRoot = new Directory(packageRootPath); 838 var packageRoot = new Directory(packageRootPath);
839 if (!packageRoot.existsSync()) { 839 if (!packageRoot.existsSync()) {
840 throw new _DriverError( 840 throw new _DriverError(
841 'Package root directory ($packageRootPath) does not exist.'); 841 'Package root directory ($packageRootPath) does not exist.');
842 } 842 }
843 var packages = packageRoot.listSync(followLinks: false); 843 var packages = packageRoot.listSync(followLinks: false);
844 var result = new Map<String, List<fileSystem.Folder>>(); 844 var result = new Map<String, List<file_system.Folder>>();
845 for (var package in packages) { 845 for (var package in packages) {
846 var packageName = path.basename(package.path); 846 var packageName = path.basename(package.path);
847 var realPath = package.resolveSymbolicLinksSync(); 847 var realPath = package.resolveSymbolicLinksSync();
848 result[packageName] = [ 848 result[packageName] = [
849 PhysicalResourceProvider.INSTANCE.getFolder(realPath) 849 PhysicalResourceProvider.INSTANCE.getFolder(realPath)
850 ]; 850 ];
851 } 851 }
852 return result; 852 return result;
853 } 853 }
854 } 854 }
OLDNEW
« no previous file with comments | « pkg/analyzer_cli/lib/src/build_mode.dart ('k') | pkg/analyzer_cli/lib/starter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698