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

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

Issue 1591483002: Prepare for chaining resynthesizers from AC to SDK AC. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fallback to the SDK. Created 4 years, 11 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 | « pkg/analyzer/lib/src/generated/sdk_io.dart ('k') | pkg/analyzer/lib/src/summary/summary_sdk.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/resynthesize.dart
diff --git a/pkg/analyzer/lib/src/summary/resynthesize.dart b/pkg/analyzer/lib/src/summary/resynthesize.dart
index f413289e41d3eaae8ccd57d70c0e2dd82f767938..8ef351250a251f19b68e6146274d32faa66d6050 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -104,6 +104,16 @@ class SummaryResynthesizer extends ElementResynthesizer {
*/
int get resynthesisCount => _resynthesizedLibraries.length;
+ /**
+ * Perform delayed finalization of the `dart:core` and `dart:async` libraries.
+ */
+ void finalizeCoreAsyncLibraries() {
+ (_resynthesizedLibraries['dart:core'] as LibraryElementImpl)
+ .createLoadLibraryFunction(typeProvider);
+ (_resynthesizedLibraries['dart:async'] as LibraryElementImpl)
+ .createLoadLibraryFunction(typeProvider);
+ }
+
@override
Element getElement(ElementLocation location) {
List<String> components = location.components;
@@ -742,16 +752,15 @@ class _LibraryResynthesizer {
*/
LibraryElement buildLibrary() {
bool hasName = unlinkedUnits[0].libraryName.isNotEmpty;
- LibraryElementImpl libraryElement = new LibraryElementImpl(
+ LibraryElementImpl library = new LibraryElementImpl(
summaryResynthesizer.context,
unlinkedUnits[0].libraryName,
hasName ? unlinkedUnits[0].libraryNameOffset : -1,
unlinkedUnits[0].libraryNameLength);
- buildDocumentation(
- libraryElement, unlinkedUnits[0].libraryDocumentationComment);
+ buildDocumentation(library, unlinkedUnits[0].libraryDocumentationComment);
CompilationUnitElementImpl definingCompilationUnit =
new CompilationUnitElementImpl(librarySource.shortName);
- libraryElement.definingCompilationUnit = definingCompilationUnit;
+ library.definingCompilationUnit = definingCompilationUnit;
definingCompilationUnit.source = librarySource;
definingCompilationUnit.librarySource = librarySource;
List<CompilationUnitElement> parts = <CompilationUnitElement>[];
@@ -765,13 +774,13 @@ class _LibraryResynthesizer {
unlinkedUnits[i]);
parts.add(part);
}
- libraryElement.parts = parts;
+ library.parts = parts;
List<ImportElement> imports = <ImportElement>[];
for (int i = 0; i < unlinkedDefiningUnit.imports.length; i++) {
imports.add(buildImport(unlinkedDefiningUnit.imports[i],
prelinkedLibrary.importDependencies[i]));
}
- libraryElement.imports = imports;
+ library.imports = imports;
List<ExportElement> exports = <ExportElement>[];
assert(unlinkedDefiningUnit.exports.length ==
unlinkedDefiningUnit.publicNamespace.exports.length);
@@ -779,36 +788,42 @@ class _LibraryResynthesizer {
exports.add(buildExport(unlinkedDefiningUnit.publicNamespace.exports[i],
unlinkedDefiningUnit.exports[i]));
}
- libraryElement.exports = exports;
+ library.exports = exports;
populateUnit(definingCompilationUnit, 0);
for (int i = 0; i < parts.length; i++) {
populateUnit(parts[i], i + 1);
}
- BuildLibraryElementUtils.patchTopLevelAccessors(libraryElement);
+ BuildLibraryElementUtils.patchTopLevelAccessors(library);
// Update delayed Object class references.
if (isCoreLibrary) {
- ClassElement objectElement = libraryElement.getType('Object');
+ ClassElement objectElement = library.getType('Object');
assert(objectElement != null);
for (ClassElementImpl classElement in delayedObjectSubclasses) {
classElement.supertype = objectElement.type;
}
}
// Compute namespaces.
- libraryElement.publicNamespace =
- new NamespaceBuilder().createPublicNamespaceForLibrary(libraryElement);
- libraryElement.exportNamespace = buildExportNamespace(
- libraryElement.publicNamespace, prelinkedLibrary.exportNames);
+ library.publicNamespace =
+ new NamespaceBuilder().createPublicNamespaceForLibrary(library);
+ library.exportNamespace = buildExportNamespace(
+ library.publicNamespace, prelinkedLibrary.exportNames);
// Find the entry point. Note: we can't use element.isEntryPoint because
// that will trigger resynthesis of exported libraries.
Element entryPoint =
- libraryElement.exportNamespace.get(FunctionElement.MAIN_FUNCTION_NAME);
+ library.exportNamespace.get(FunctionElement.MAIN_FUNCTION_NAME);
if (entryPoint is FunctionElement) {
- libraryElement.entryPoint = entryPoint;
+ library.entryPoint = entryPoint;
}
// Create the synthetic element for `loadLibrary`.
- libraryElement.createLoadLibraryFunction(summaryResynthesizer.typeProvider);
+ // Until the client received dart:core and dart:async, we cannot do this,
+ // because the TypeProvider is not fully initialized. So, it is up to the
+ // Dart SDK client to initialize TypeProvider and finish the dart:core and
+ // dart:async libraries creation.
+ if (library.name != 'dart.core' && library.name != 'dart.async') {
+ library.createLoadLibraryFunction(summaryResynthesizer.typeProvider);
+ }
// Done.
- return libraryElement;
+ return library;
}
/**
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk_io.dart ('k') | pkg/analyzer/lib/src/summary/summary_sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698