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

Unified Diff: pkg/analyzer/lib/src/summary/bazel_summary.dart

Issue 2386463002: Add BazelResultProvider for on-demand packages loading. (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/bazel_summary_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/bazel_summary_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698