| 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 c4f6caa80ac4ce5a58d4058c88f9e58119a9366c..f60514c7574e3a6cb13dd5555ee9be0b139c903b 100644
|
| --- a/pkg/analyzer/lib/src/summary/resynthesize.dart
|
| +++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
|
| @@ -22,6 +22,7 @@ import 'package:analyzer/src/generated/testing/ast_test_factory.dart';
|
| import 'package:analyzer/src/generated/testing/token_factory.dart';
|
| import 'package:analyzer/src/summary/format.dart';
|
| import 'package:analyzer/src/summary/idl.dart';
|
| +import 'package:analyzer/src/summary/summary_sdk.dart';
|
|
|
| /**
|
| * Implementation of [ElementResynthesizer] used when resynthesizing an element
|
| @@ -29,13 +30,6 @@ import 'package:analyzer/src/summary/idl.dart';
|
| */
|
| abstract class SummaryResynthesizer extends ElementResynthesizer {
|
| /**
|
| - * The parent [SummaryResynthesizer] which is asked to resynthesize elements
|
| - * and get summaries before this resynthesizer attempts to do this.
|
| - * Can be `null`.
|
| - */
|
| - final SummaryResynthesizer parent;
|
| -
|
| - /**
|
| * Source factory used to convert URIs to [Source] objects.
|
| */
|
| final SourceFactory sourceFactory;
|
| @@ -46,10 +40,9 @@ abstract class SummaryResynthesizer extends ElementResynthesizer {
|
| final Map<String, Source> _sources = <String, Source>{};
|
|
|
| /**
|
| - * The [TypeProvider] used to obtain core types (such as Object, int, List,
|
| - * and dynamic) during resynthesis.
|
| + * The [TypeProvider] used to obtain SDK types during resynthesis.
|
| */
|
| - final TypeProvider typeProvider;
|
| + TypeProvider _typeProvider;
|
|
|
| /**
|
| * Indicates whether the summary should be resynthesized assuming strong mode
|
| @@ -80,9 +73,11 @@ abstract class SummaryResynthesizer extends ElementResynthesizer {
|
| final Map<String, LibraryElement> _resynthesizedLibraries =
|
| <String, LibraryElement>{};
|
|
|
| - SummaryResynthesizer(this.parent, AnalysisContext context, this.typeProvider,
|
| - this.sourceFactory, this.strongMode)
|
| - : super(context);
|
| + SummaryResynthesizer(
|
| + AnalysisContext context, this.sourceFactory, this.strongMode)
|
| + : super(context) {
|
| + _buildTypeProvider();
|
| + }
|
|
|
| /**
|
| * Number of libraries that have been resynthesized so far.
|
| @@ -90,23 +85,14 @@ abstract class SummaryResynthesizer extends ElementResynthesizer {
|
| int get resynthesisCount => _resynthesizedLibraries.length;
|
|
|
| /**
|
| - * Perform delayed finalization of the `dart:core` and `dart:async` libraries.
|
| + * The [TypeProvider] used to obtain SDK types during resynthesis.
|
| */
|
| - void finalizeCoreAsyncLibraries() {
|
| - (_resynthesizedLibraries['dart:core'] as LibraryElementImpl)
|
| - .createLoadLibraryFunction(typeProvider);
|
| - (_resynthesizedLibraries['dart:async'] as LibraryElementImpl)
|
| - .createLoadLibraryFunction(typeProvider);
|
| - }
|
| + TypeProvider get typeProvider => _typeProvider;
|
|
|
| @override
|
| Element getElement(ElementLocation location) {
|
| List<String> components = location.components;
|
| String libraryUri = components[0];
|
| - // Ask the parent resynthesizer.
|
| - if (parent != null && parent._hasLibrarySummary(libraryUri)) {
|
| - return parent.getElement(location);
|
| - }
|
| // Resynthesize locally.
|
| if (components.length == 1) {
|
| return getLibraryElement(libraryUri);
|
| @@ -203,11 +189,8 @@ abstract class SummaryResynthesizer extends ElementResynthesizer {
|
| * hasn't been resynthesized already.
|
| */
|
| LibraryElement getLibraryElement(String uri) {
|
| - if (parent != null && parent._hasLibrarySummary(uri)) {
|
| - return parent.getLibraryElement(uri);
|
| - }
|
| return _resynthesizedLibraries.putIfAbsent(uri, () {
|
| - LinkedLibrary serializedLibrary = _getLinkedSummaryOrNull(uri);
|
| + LinkedLibrary serializedLibrary = getLinkedSummary(uri);
|
| Source librarySource = _getSource(uri);
|
| if (serializedLibrary == null) {
|
| LibraryElementImpl libraryElement =
|
| @@ -223,7 +206,7 @@ abstract class SummaryResynthesizer extends ElementResynthesizer {
|
| libraryElement.exportNamespace = new Namespace({});
|
| return libraryElement;
|
| }
|
| - UnlinkedUnit unlinkedSummary = _getUnlinkedSummaryOrNull(uri);
|
| + UnlinkedUnit unlinkedSummary = getUnlinkedSummary(uri);
|
| if (unlinkedSummary == null) {
|
| throw new StateError('Unable to find unlinked summary: $uri');
|
| }
|
| @@ -234,7 +217,7 @@ abstract class SummaryResynthesizer extends ElementResynthesizer {
|
| serializedUnits.add(null);
|
| } else {
|
| String partAbsUri = partSource.uri.toString();
|
| - serializedUnits.add(_getUnlinkedSummaryOrNull(partAbsUri) ??
|
| + serializedUnits.add(getUnlinkedSummary(partAbsUri) ??
|
| new UnlinkedUnitBuilder(codeRange: new CodeRangeBuilder()));
|
| }
|
| }
|
| @@ -267,15 +250,15 @@ abstract class SummaryResynthesizer extends ElementResynthesizer {
|
| */
|
| bool hasLibrarySummary(String uri);
|
|
|
| - /**
|
| - * Return the [LinkedLibrary] for the given [uri] or return `null` if it
|
| - * could not be found.
|
| - */
|
| - LinkedLibrary _getLinkedSummaryOrNull(String uri) {
|
| - if (parent != null && parent._hasLibrarySummary(uri)) {
|
| - return parent._getLinkedSummaryOrNull(uri);
|
| - }
|
| - return getLinkedSummary(uri);
|
| + void _buildTypeProvider() {
|
| + var coreLibrary = getLibraryElement('dart:core') as LibraryElementImpl;
|
| + var asyncLibrary = getLibraryElement('dart:async') as LibraryElementImpl;
|
| + SummaryTypeProvider summaryTypeProvider = new SummaryTypeProvider();
|
| + summaryTypeProvider.initializeCore(coreLibrary);
|
| + summaryTypeProvider.initializeAsync(asyncLibrary);
|
| + coreLibrary.createLoadLibraryFunction(summaryTypeProvider);
|
| + asyncLibrary.createLoadLibraryFunction(summaryTypeProvider);
|
| + _typeProvider = summaryTypeProvider;
|
| }
|
|
|
| /**
|
| @@ -284,28 +267,6 @@ abstract class SummaryResynthesizer extends ElementResynthesizer {
|
| Source _getSource(String uri) {
|
| return _sources.putIfAbsent(uri, () => sourceFactory.forUri(uri));
|
| }
|
| -
|
| - /**
|
| - * Return the [UnlinkedUnit] for the given [uri] or return `null` if it
|
| - * could not be found.
|
| - */
|
| - UnlinkedUnit _getUnlinkedSummaryOrNull(String uri) {
|
| - if (parent != null && parent._hasLibrarySummary(uri)) {
|
| - return parent._getUnlinkedSummaryOrNull(uri);
|
| - }
|
| - return getUnlinkedSummary(uri);
|
| - }
|
| -
|
| - /**
|
| - * Return `true` if this resynthesizer can provide summaries of the libraries
|
| - * with the given [uri].
|
| - */
|
| - bool _hasLibrarySummary(String uri) {
|
| - if (parent != null && parent._hasLibrarySummary(uri)) {
|
| - return true;
|
| - }
|
| - return hasLibrarySummary(uri);
|
| - }
|
| }
|
|
|
| /**
|
|
|