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

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

Issue 2652823002: Use single InputPackagesResultProvider, without SdkSummaryResultProvider. (Closed)
Patch Set: Fixes for analyzer_cli. Created 3 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
Index: pkg/analyzer/lib/src/summary/summary_sdk.dart
diff --git a/pkg/analyzer/lib/src/summary/summary_sdk.dart b/pkg/analyzer/lib/src/summary/summary_sdk.dart
index ac6d4b3e0e3370c7ca75204fdb27e94641479244..b178fdcf081225890781a03e9d1281d0cfd2d21b 100644
--- a/pkg/analyzer/lib/src/summary/summary_sdk.dart
+++ b/pkg/analyzer/lib/src/summary/summary_sdk.dart
@@ -7,7 +7,6 @@ library analyzer.src.summary.summary_sdk;
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/file_system/file_system.dart' show ResourceProvider;
-import 'package:analyzer/src/context/cache.dart' show CacheEntry;
import 'package:analyzer/src/context/context.dart';
import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/generated/constant.dart';
@@ -18,84 +17,6 @@ import 'package:analyzer/src/generated/source.dart'
show DartUriResolver, Source, SourceFactory;
import 'package:analyzer/src/summary/idl.dart';
import 'package:analyzer/src/summary/package_bundle_reader.dart';
-import 'package:analyzer/src/summary/resynthesize.dart';
-import 'package:analyzer/src/task/dart.dart';
-import 'package:analyzer/task/model.dart' show ResultDescriptor, TargetedResult;
-
-class SdkSummaryResultProvider extends ResynthesizerResultProvider {
- final SummaryTypeProvider typeProvider = new SummaryTypeProvider();
-
- SdkSummaryResultProvider(
- InternalAnalysisContext context, PackageBundle bundle, bool strongMode)
- : super(context, new SummaryDataStore(const <String>[])) {
- addBundle(null, bundle);
- createResynthesizer(null, typeProvider);
- _buildCoreLibrary();
- _buildAsyncLibrary();
- resynthesizer.finalizeCoreAsyncLibraries();
- context.typeProvider = typeProvider;
- }
-
- @override
- bool compute(CacheEntry entry, ResultDescriptor result) {
- if (result == TYPE_PROVIDER) {
- entry.setValue(result as ResultDescriptor<TypeProvider>, typeProvider,
- TargetedResult.EMPTY_LIST);
- return true;
- }
- return super.compute(entry, result);
- }
-
- @override
- bool hasResultsForSource(Source source) {
- return source != null && source.isInSystemLibrary;
- }
-
- void _buildAsyncLibrary() {
- LibraryElement library = resynthesizer.getLibraryElement('dart:async');
- typeProvider.initializeAsync(library);
- }
-
- void _buildCoreLibrary() {
- LibraryElement library = resynthesizer.getLibraryElement('dart:core');
- typeProvider.initializeCore(library);
- }
-}
-
-/**
- * The implementation of [SummaryResynthesizer] for Dart SDK.
- */
-class SdkSummaryResynthesizer extends SummaryResynthesizer {
- final PackageBundle bundle;
- final Map<String, UnlinkedUnit> unlinkedSummaries = <String, UnlinkedUnit>{};
- final Map<String, LinkedLibrary> linkedSummaries = <String, LinkedLibrary>{};
-
- SdkSummaryResynthesizer(AnalysisContext context, TypeProvider typeProvider,
- SourceFactory sourceFactory, this.bundle, bool strongMode)
- : super(null, context, typeProvider, sourceFactory, strongMode) {
- for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) {
- unlinkedSummaries[bundle.unlinkedUnitUris[i]] = bundle.unlinkedUnits[i];
- }
- for (int i = 0; i < bundle.linkedLibraryUris.length; i++) {
- linkedSummaries[bundle.linkedLibraryUris[i]] = bundle.linkedLibraries[i];
- }
- }
-
- @override
- LinkedLibrary getLinkedSummary(String uri) {
- return linkedSummaries[uri];
- }
-
- @override
- UnlinkedUnit getUnlinkedSummary(String uri) {
- return unlinkedSummaries[uri];
- }
-
- @override
- bool hasLibrarySummary(String uri) {
- return uri.startsWith('dart:');
- }
-}
/**
* An implementation of [DartSdk] which provides analysis results for `dart:`
@@ -143,8 +64,10 @@ class SummaryBasedDartSdk implements DartSdk {
SourceFactory factory = new SourceFactory(
[new DartUriResolver(this)], null, resourceProvider);
_analysisContext.sourceFactory = factory;
+ SummaryDataStore dataStore = new SummaryDataStore([]);
+ dataStore.addBundle(null, _bundle);
_analysisContext.resultProvider =
- new SdkSummaryResultProvider(_analysisContext, _bundle, strongMode);
+ new InputPackagesResultProvider(_analysisContext, dataStore);
}
return _analysisContext;
}

Powered by Google App Engine
This is Rietveld 408576698