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

Unified Diff: pkg/analyzer/lib/src/generated/sdk_io.dart

Issue 1555093005: Use SummarySdkAnalysisContext if the SDK has the analysis_summary file. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fixes for review comments. 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/context/context.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/generated/sdk_io.dart
diff --git a/pkg/analyzer/lib/src/generated/sdk_io.dart b/pkg/analyzer/lib/src/generated/sdk_io.dart
index 1f98ba3eddfd7c26d85909f26e47e13cf530b73e..1fc4b3364545df0108ee8fb3b384e06daee32a95 100644
--- a/pkg/analyzer/lib/src/generated/sdk_io.dart
+++ b/pkg/analyzer/lib/src/generated/sdk_io.dart
@@ -18,6 +18,9 @@ import 'package:analyzer/src/generated/parser.dart';
import 'package:analyzer/src/generated/scanner.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source_io.dart';
+import 'package:analyzer/src/summary/format.dart' show SdkBundle;
+import 'package:analyzer/src/summary/summary_sdk.dart';
+import 'package:path/path.dart' as pathos;
/**
* A Dart SDK installed in a specified directory. Typical Dart SDK layout is
@@ -241,7 +244,12 @@ class DirectoryBasedDartSdk implements DartSdk {
@override
AnalysisContext get context {
if (_analysisContext == null) {
- _analysisContext = new SdkAnalysisContext();
+ SdkBundle sdkBundle = _getSummarySdkBundle();
+ if (sdkBundle != null) {
+ _analysisContext = new SummarySdkAnalysisContext(sdkBundle);
+ } else {
+ _analysisContext = new SdkAnalysisContext();
+ }
SourceFactory factory = new SourceFactory([new DartUriResolver(this)]);
_analysisContext.sourceFactory = factory;
List<String> uris = this.uris;
@@ -533,6 +541,26 @@ class DirectoryBasedDartSdk implements DartSdk {
}
/**
+ * Return the [SdkBundle] for this SDK, if it exists, or `null` otherwise.
+ */
+ SdkBundle _getSummarySdkBundle() {
+ String rootPath = directory.getAbsolutePath();
+ String path = pathos.join(rootPath, 'lib', '_internal', 'analysis_summary');
+ try {
+ File file = new File(path);
+ if (file.existsSync()) {
+ List<int> bytes = file.readAsBytesSync();
+ return new SdkBundle.fromBuffer(bytes);
+ }
+ } catch (exception, stackTrace) {
+ AnalysisEngine.instance.logger.logError(
+ 'Failed to load SDK analysis summary from $path',
+ new CaughtException(exception, stackTrace));
+ }
+ return null;
+ }
+
+ /**
* Return the given [file] if it exists and is executable, or `null` if it
* does not exist or is not executable.
*/
« no previous file with comments | « pkg/analyzer/lib/src/context/context.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