| 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.
|
| */
|
|
|