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

Unified Diff: pkg/analyzer/test/src/summary/resynthesize_test.dart

Issue 1530303005: Separate prelinked and unlinked parts of summaries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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
Index: pkg/analyzer/test/src/summary/resynthesize_test.dart
diff --git a/pkg/analyzer/test/src/summary/resynthesize_test.dart b/pkg/analyzer/test/src/summary/resynthesize_test.dart
index ec846a587063947c800725e865a9bfd81cfd8ae7..cffd7d90fc538f2c9f9234b1f539f1d8929272da 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_test.dart
@@ -417,12 +417,6 @@ class ResynthTest extends ResolverTestCase {
// TODO(paulberry): test initializer
}
- PrelinkedLibrary getSummaryFor(LibraryElement lib) {
- BuilderContext ctx = new BuilderContext();
- List<int> summary = serializeLibrary(ctx, lib, typeProvider).toBuffer();
- return new PrelinkedLibrary.fromBuffer(summary);
- }
-
LibraryElementImpl resynthesizeLibrary(
Source source, LibraryElementImpl original, bool allowErrors) {
if (!allowErrors) {
@@ -435,23 +429,43 @@ class ResynthTest extends ResolverTestCase {
LibraryElementImpl resynthesizeLibraryElement(
String uri, LibraryElementImpl original) {
- Map<String, PrelinkedLibrary> summaries = <String, PrelinkedLibrary>{
- uri: getSummaryFor(original)
- };
+ Map<String, UnlinkedUnit> unlinkedSummaries = <String, UnlinkedUnit>{};
+ PrelinkedLibrary getPrelinkedSummaryFor(LibraryElement lib) {
+ BuilderContext ctx = new BuilderContext();
+ LibrarySerializationResult serialized =
+ serializeLibrary(ctx, lib, typeProvider);
+ for (int i = 0; i < serialized.unlinkedUnits.length; i++) {
+ unlinkedSummaries[serialized.unitUris[i]] =
+ new UnlinkedUnit.fromBuffer(serialized.unlinkedUnits[i].toBuffer());
+ }
+ return new PrelinkedLibrary.fromBuffer(serialized.prelinked.toBuffer());
+ }
+ Map<String, PrelinkedLibrary> prelinkedSummaries =
+ <String, PrelinkedLibrary>{uri: getPrelinkedSummaryFor(original)};
for (Source source in otherLibrarySources) {
LibraryElement original = resolve2(source);
String uri = source.uri.toString();
- summaries[uri] = getSummaryFor(original);
+ prelinkedSummaries[uri] = getPrelinkedSummaryFor(original);
}
- PrelinkedLibrary getSummary(String uri) {
- PrelinkedLibrary serializedLibrary = summaries[uri];
+ PrelinkedLibrary getPrelinkedSummary(String uri) {
+ PrelinkedLibrary serializedLibrary = prelinkedSummaries[uri];
if (serializedLibrary == null) {
- fail('Unexpectedly tried to get serialized library for $uri');
+ fail('Unexpectedly tried to get prelinked summary for $uri');
}
return serializedLibrary;
}
+ UnlinkedUnit getUnlinkedSummary(String uri) {
+ UnlinkedUnit serializedUnit = unlinkedSummaries[uri];
+ if (serializedUnit == null) {
+ fail('Unexpectedly tried to get unlinked summary for $uri');
+ }
+ return serializedUnit;
+ }
SummaryResynthesizer resynthesizer = new SummaryResynthesizer(
- analysisContext, getSummary, analysisContext.sourceFactory);
+ analysisContext,
+ getPrelinkedSummary,
+ getUnlinkedSummary,
+ analysisContext.sourceFactory);
LibraryElementImpl resynthesized = resynthesizer.getLibraryElement(uri);
// Check that no other summaries needed to be resynthesized to resynthesize
// the library element.
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_elements.dart ('k') | pkg/analyzer/test/src/summary/summary_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698