| Index: pkg/analyzer/lib/src/dart/analysis/library_context.dart
|
| diff --git a/pkg/analyzer/lib/src/dart/analysis/library_context.dart b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
|
| index f14cde27a64211301cc16399f1e389b667f86208..ec706cee77838d92b89f809c92949ebb92fbbad2 100644
|
| --- a/pkg/analyzer/lib/src/dart/analysis/library_context.dart
|
| +++ b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
|
| @@ -4,7 +4,8 @@
|
|
|
| import 'package:analyzer/context/declared_variables.dart';
|
| import 'package:analyzer/dart/ast/ast.dart';
|
| -import 'package:analyzer/dart/element/element.dart' show CompilationUnitElement;
|
| +import 'package:analyzer/dart/element/element.dart'
|
| + show CompilationUnitElement, LibraryElement;
|
| import 'package:analyzer/error/error.dart';
|
| import 'package:analyzer/src/context/context.dart';
|
| import 'package:analyzer/src/dart/analysis/byte_store.dart';
|
| @@ -19,7 +20,8 @@ import 'package:analyzer/src/summary/idl.dart';
|
| import 'package:analyzer/src/summary/link.dart';
|
| import 'package:analyzer/src/summary/package_bundle_reader.dart';
|
| import 'package:analyzer/src/task/dart.dart' show COMPILATION_UNIT_ELEMENT;
|
| -import 'package:analyzer/task/dart.dart' show LibrarySpecificUnit;
|
| +import 'package:analyzer/task/dart.dart'
|
| + show LIBRARY_ELEMENT, LibrarySpecificUnit;
|
|
|
| /**
|
| * Context information necessary to analyze one or more libraries within an
|
| @@ -47,11 +49,16 @@ class LibraryContext {
|
| AnalysisOptions options,
|
| DeclaredVariables declaredVariables,
|
| SourceFactory sourceFactory,
|
| + SummaryDataStore externalSummaries,
|
| FileTracker fileTracker) {
|
| return logger.run('Create library context', () {
|
| Map<String, FileState> libraries = <String, FileState>{};
|
| SummaryDataStore store = new SummaryDataStore(const <String>[]);
|
|
|
| + if (externalSummaries != null) {
|
| + store.addStore(externalSummaries);
|
| + }
|
| +
|
| if (sdkBundle != null) {
|
| store.addBundle(null, sdkBundle);
|
| }
|
| @@ -59,6 +66,7 @@ class LibraryContext {
|
| void appendLibraryFiles(FileState library) {
|
| if (!libraries.containsKey(library.uriStr)) {
|
| // Serve 'dart:' URIs from the SDK bundle.
|
| + // TODO(scheglov) Repeal and replace with the external store.
|
| if (sdkBundle != null && library.uri.scheme == 'dart') {
|
| return;
|
| }
|
| @@ -161,6 +169,31 @@ class LibraryContext {
|
| return new ResolutionResult(resolvedUnit, errors);
|
| }
|
|
|
| + /**
|
| + * TODO(scheglov) document
|
| + */
|
| + static LibraryElement resynthesizeLibrary(
|
| + AnalysisOptions analysisOptions,
|
| + DeclaredVariables declaredVariables,
|
| + SourceFactory sourceFactory,
|
| + SummaryDataStore store,
|
| + String uri) {
|
| + AnalysisContextImpl analysisContext =
|
| + AnalysisEngine.instance.createAnalysisContext();
|
| + analysisContext.useSdkCachePartition = false;
|
| + analysisContext.analysisOptions = analysisOptions;
|
| + analysisContext.declaredVariables.addAll(declaredVariables);
|
| + analysisContext.sourceFactory = sourceFactory.clone();
|
| + var provider = new InputPackagesResultProvider(analysisContext, store);
|
| + var source = sourceFactory.resolveUri(null, uri);
|
| + var entry = analysisContext.getCacheEntry(source);
|
| + bool success = provider.compute(entry, LIBRARY_ELEMENT);
|
| + if (!success) {
|
| + throw new StateError('Expected successful resynthesis of $source');
|
| + }
|
| + return entry.getValue(LIBRARY_ELEMENT);
|
| + }
|
| +
|
| static AnalysisContext _createAnalysisContext(
|
| AnalysisOptions _analysisOptions,
|
| DeclaredVariables declaredVariables,
|
| @@ -214,6 +247,9 @@ class _ContentCacheWrapper implements ContentCache {
|
| if (source.isInSystemLibrary) {
|
| return true;
|
| }
|
| + if (fileTracker.externalSummaries.hasUnlinkedUnit(source.uri.toString())) {
|
| + return true;
|
| + }
|
| return _getFileForSource(source).exists;
|
| }
|
|
|
|
|