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

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

Issue 2188523004: DartWorkManager.getLibrariesContainingPart() should ask the ResultProvider for CONTAINING_LIBRARIES. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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/lib/src/task/dart_work_manager.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/package_bundle_reader.dart
diff --git a/pkg/analyzer/lib/src/summary/package_bundle_reader.dart b/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
index 0055866490ad03745ccab3b0f80abdec02b2b9f7..5416eb8ded6c9e8e17a9c5b1c2507498f33cbca1 100644
--- a/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
+++ b/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
@@ -9,9 +9,11 @@ import 'package:analyzer/src/generated/java_io.dart';
import 'package:analyzer/src/generated/resolver.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/source_io.dart';
+import 'package:analyzer/src/generated/utilities_dart.dart';
import 'package:analyzer/src/summary/idl.dart';
import 'package:analyzer/src/summary/resynthesize.dart';
import 'package:analyzer/src/task/dart.dart';
+import 'package:analyzer/src/util/fast_uri.dart';
import 'package:analyzer/task/dart.dart';
import 'package:analyzer/task/model.dart';
import 'package:path/path.dart' as pathos;
@@ -182,6 +184,18 @@ abstract class ResynthesizerResultProvider extends ResultProvider {
return true;
}
return false;
+ } else if (result == CONTAINING_LIBRARIES) {
+ List<String> libraryUriStrings =
+ _dataStore._getContainingLibraryUris(uriString);
+ if (libraryUriStrings != null) {
+ List<Source> librarySources = libraryUriStrings
+ .map((libraryUriString) =>
+ context.sourceFactory.resolveUri(target, libraryUriString))
+ .toList(growable: false);
+ entry.setValue(result, librarySources, TargetedResult.EMPTY_LIST);
+ return true;
+ }
+ return false;
}
} else if (target is LibrarySpecificUnit) {
if (result == CREATED_RESOLVED_UNIT1 ||
@@ -300,6 +314,31 @@ class SummaryDataStore {
PackageBundle bundle = new PackageBundle.fromBuffer(buffer);
addBundle(path, bundle);
}
+
+ /**
+ * Return a list of absolute URIs of the libraries that contain the unit with
+ * the given [unitUriString], or `null` if no such library is in the store.
+ */
+ List<String> _getContainingLibraryUris(String unitUriString) {
+ // The unit is the defining unit of a library.
+ if (linkedMap.containsKey(unitUriString)) {
+ return <String>[unitUriString];
+ }
+ // Check every unlinked unit whether it uses [unitUri] as a part.
+ List<String> libraryUriStrings = <String>[];
+ unlinkedMap.forEach((unlinkedUnitUriString, unlinkedUnit) {
+ Uri libraryUri = FastUri.parse(unlinkedUnitUriString);
+ for (String partUriString in unlinkedUnit.publicNamespace.parts) {
+ Uri partUri = FastUri.parse(partUriString);
+ String partAbsoluteUriString =
+ resolveRelativeUri(libraryUri, partUri).toString();
+ if (partAbsoluteUriString == unitUriString) {
+ libraryUriStrings.add(unlinkedUnitUriString);
+ }
+ }
+ });
+ return libraryUriStrings.isNotEmpty ? libraryUriStrings : null;
+ }
}
/**
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/dart_work_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698