Index: pkg/analyzer/lib/src/summary/bazel_summary.dart |
diff --git a/pkg/analyzer/lib/src/summary/bazel_summary.dart b/pkg/analyzer/lib/src/summary/bazel_summary.dart |
index 6c65cc2ea4cf2f2f7ab3052dc80edd5a3b9054f7..f98c835d51a80cfc62124744fc7010cd0052bb10 100644 |
--- a/pkg/analyzer/lib/src/summary/bazel_summary.dart |
+++ b/pkg/analyzer/lib/src/summary/bazel_summary.dart |
@@ -27,6 +27,49 @@ import 'package:meta/meta.dart'; |
typedef Folder GetOutputFolder(Uri absoluteUri); |
/** |
+ * Load linked packages on demand from [SummaryProvider]. |
+ */ |
+class BazelResultProvider extends ResynthesizerResultProvider { |
+ final SummaryDataStore dataStore; |
+ final SummaryProvider summaryProvider; |
+ |
+ final Map<Source, bool> sourceToSuccessMap = <Source, bool>{}; |
+ final Set<Package> addedPackages = new Set<Package>(); |
+ |
+ factory BazelResultProvider(SummaryProvider summaryProvider) { |
+ SummaryDataStore dataStore = new SummaryDataStore(const <String>[]); |
+ return new BazelResultProvider._( |
+ summaryProvider.context, dataStore, summaryProvider); |
+ } |
+ |
+ BazelResultProvider._(InternalAnalysisContext context, |
Brian Wilkerson
2016/09/29 21:54:07
Should the context always be the same as the one i
|
+ SummaryDataStore dataStore, this.summaryProvider) |
+ : dataStore = dataStore, |
+ super(context, dataStore) { |
+ AnalysisContext sdkContext = context.sourceFactory.dartSdk.context; |
+ createResynthesizer(sdkContext, sdkContext.typeProvider); |
+ } |
+ |
+ @override |
+ bool hasResultsForSource(Source source) { |
+ return sourceToSuccessMap.putIfAbsent(source, () { |
+ List<Package> packages = summaryProvider.getLinkedPackages(source); |
+ if (packages == null) { |
+ return false; |
+ } |
+ for (Package package in packages) { |
+ if (addedPackages.add(package)) { |
+ dataStore.addBundle(null, package.unlinked); |
+ dataStore.addBundle(null, package.linked); |
+ } |
+ } |
+ String uriString = source.uri.toString(); |
+ return resynthesizer.hasLibrarySummary(uriString); |
+ }); |
+ } |
+} |
+ |
+/** |
* Information about a Dart package in Bazel. |
*/ |
class Package { |