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

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

Issue 1974323003: Add '--dart-sdk-summary' option to analyzer-cli and use SummaryBasedDartSdk. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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/summary/package_bundle_reader.dart ('k') | pkg/analyzer_cli/lib/src/build_mode.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 56dbb27794619c341cd681e231bdeda6e145753c..740abf7195507dc54ea58d0248689d17b0eca3ea 100644
--- a/pkg/analyzer/lib/src/summary/summary_sdk.dart
+++ b/pkg/analyzer/lib/src/summary/summary_sdk.dart
@@ -13,9 +13,11 @@ import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/generated/constant.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/resolver.dart';
+import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source.dart'
- show Source, SourceFactory, SourceKind;
+ show DartUriResolver, Source, SourceFactory, SourceKind;
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/dart.dart';
@@ -190,6 +192,78 @@ class SdkSummaryResynthesizer extends SummaryResynthesizer {
}
/**
+ * An implementation of [DartSdk] which provides analysis results for `dart:`
+ * libraries from the given summary file. This implementation is limited and
+ * suitable only for command-line tools, but not for IDEs.
Brian Wilkerson 2016/05/13 18:07:59 It would be good to expand this comment by explain
+ */
+class SummaryBasedDartSdk implements DartSdk {
+ SummaryDataStore _dataStore;
+ InSummaryPackageUriResolver _uriResolver;
+ PackageBundle _bundle;
+
+ /**
+ * The [AnalysisContext] which is used for all of the sources in this sdk.
+ */
+ InternalAnalysisContext _analysisContext;
+
+ SummaryBasedDartSdk(String summaryPath) {
+ _dataStore = new SummaryDataStore(<String>[summaryPath]);
+ _uriResolver = new InSummaryPackageUriResolver(_dataStore);
+ _bundle = _dataStore.bundles.single;
+ }
+
+ /**
+ * Return the [PackageBundle] for this SDK, not `null`.
+ */
+ PackageBundle get bundle => _bundle;
+
+ @override
+ AnalysisContext get context {
+ if (_analysisContext == null) {
+ _analysisContext = new SdkAnalysisContext(null);
+ SourceFactory factory = new SourceFactory([new DartUriResolver(this)]);
+ _analysisContext.sourceFactory = factory;
+ _analysisContext.resultProvider =
+ new SdkSummaryResultProvider(_analysisContext, _bundle);
+ }
+ return _analysisContext;
+ }
+
+ @override
+ List<SdkLibrary> get sdkLibraries {
+ throw new UnimplementedError();
+ }
+
+ @override
+ String get sdkVersion {
+ throw new UnimplementedError();
+ }
+
+ @override
+ List<String> get uris {
+ throw new UnimplementedError();
+ }
+
+ @override
+ Source fromFileUri(Uri uri) {
+ return null;
+ }
+
+ @override
+ SdkLibrary getSdkLibrary(String uri) {
+ // This is not quite correct, but currently it's used only in
+ // to report errors on importing or exporting of internal libraries.
+ return null;
+ }
+
+ @override
+ Source mapDartUri(String uriStr) {
+ Uri uri = Uri.parse(uriStr);
+ return _uriResolver.resolveAbsolute(uri);
+ }
+}
+
+/**
* Provider for analysis results.
*/
abstract class SummaryResultProvider extends ResultProvider {
« no previous file with comments | « pkg/analyzer/lib/src/summary/package_bundle_reader.dart ('k') | pkg/analyzer_cli/lib/src/build_mode.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698