Chromium Code Reviews| 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..cf035d3badd92a522b9e015d96a0b53eed380592 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,20 @@ 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'); |
| + File file = new File(path); |
| + if (file.existsSync()) { |
|
Brian Wilkerson
2016/01/05 18:46:18
Should we catch IO exceptions here and return `nul
Paul Berry
2016/01/05 19:33:43
I hope we can propagate (or at least report) the e
scheglov
2016/01/05 20:27:57
I will catch all exceptions here and report them w
|
| + List<int> bytes = file.readAsBytesSync(); |
| + return new SdkBundle.fromBuffer(bytes); |
| + } |
| + return null; |
| + } |
| + |
| + /** |
| * Return the given [file] if it exists and is executable, or `null` if it |
| * does not exist or is not executable. |
| */ |