| 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 d728b6fe72843d2dd85c605775a17615de9b0e88..f9fa98081535d4ce05253147319454f27367df13 100644
|
| --- a/pkg/analyzer/lib/src/dart/analysis/library_context.dart
|
| +++ b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
|
| @@ -10,6 +10,8 @@ import 'package:analyzer/error/error.dart';
|
| import 'package:analyzer/src/context/context.dart';
|
| import 'package:analyzer/src/dart/analysis/driver.dart';
|
| import 'package:analyzer/src/dart/analysis/file_state.dart';
|
| +import 'package:analyzer/src/dart/element/element.dart';
|
| +import 'package:analyzer/src/dart/element/handle.dart';
|
| import 'package:analyzer/src/generated/engine.dart'
|
| show AnalysisContext, AnalysisEngine, AnalysisOptions;
|
| import 'package:analyzer/src/generated/source.dart';
|
| @@ -17,8 +19,6 @@ import 'package:analyzer/src/summary/format.dart';
|
| 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:front_end/src/base/performace_logger.dart';
|
| import 'package:front_end/src/byte_store/byte_store.dart';
|
|
|
| @@ -37,6 +37,11 @@ class LibraryContext {
|
| */
|
| final AnalysisContext _analysisContext;
|
|
|
| + /**
|
| + * The resynthesizer that resynthesizes elements in [_analysisContext].
|
| + */
|
| + final ElementResynthesizer _resynthesizer;
|
| +
|
| /**
|
| * Create a [LibraryContext] which is prepared to analyze [targetLibrary].
|
| */
|
| @@ -132,24 +137,27 @@ class LibraryContext {
|
| byteStore.put(key, bytes);
|
| });
|
|
|
| - AnalysisContextImpl analysisContext = _createAnalysisContext(
|
| + var resynthesizingContext = _createResynthesizingContext(
|
| options, declaredVariables, sourceFactory, store);
|
| - analysisContext.contentCache = new _ContentCacheWrapper(fsState);
|
| + resynthesizingContext.context.contentCache =
|
| + new _ContentCacheWrapper(fsState);
|
|
|
| - return new LibraryContext._(store, analysisContext);
|
| + return new LibraryContext._(store, resynthesizingContext.context,
|
| + resynthesizingContext.resynthesizer);
|
| });
|
| }
|
|
|
| - LibraryContext._(this.store, this._analysisContext);
|
| + LibraryContext._(this.store, this._analysisContext, this._resynthesizer);
|
|
|
| /**
|
| * Computes a [CompilationUnitElement] for the given library/unit pair.
|
| */
|
| CompilationUnitElement computeUnitElement(
|
| Source librarySource, Source unitSource) {
|
| - return _analysisContext.computeResult(
|
| - new LibrarySpecificUnit(librarySource, unitSource),
|
| - COMPILATION_UNIT_ELEMENT);
|
| + String libraryUri = librarySource.uri.toString();
|
| + String unitUri = unitSource.uri.toString();
|
| + return _resynthesizer.getElement(
|
| + new ElementLocationImpl.con3(<String>[libraryUri, unitUri]));
|
| }
|
|
|
| /**
|
| @@ -161,17 +169,6 @@ class LibraryContext {
|
| _analysisContext.dispose();
|
| }
|
|
|
| - /**
|
| - * Computes a resolved [CompilationUnit] and a list of [AnalysisError]s for
|
| - * the given library/unit pair.
|
| - */
|
| - ResolutionResult resolveUnit(Source librarySource, Source unitSource) {
|
| - CompilationUnit resolvedUnit =
|
| - _analysisContext.resolveCompilationUnit2(unitSource, librarySource);
|
| - List<AnalysisError> errors = _analysisContext.computeErrors(unitSource);
|
| - return new ResolutionResult(resolvedUnit, errors);
|
| - }
|
| -
|
| /**
|
| * Resynthesize the [LibraryElement] from the given [store].
|
| */
|
| @@ -181,18 +178,17 @@ class LibraryContext {
|
| SourceFactory sourceFactory,
|
| SummaryDataStore store,
|
| String uri) {
|
| - AnalysisContextImpl analysisContext = _createAnalysisContext(
|
| + var resynthesizingContext = _createResynthesizingContext(
|
| analysisOptions, declaredVariables, sourceFactory, store);
|
| try {
|
| - return new StoreBasedSummaryResynthesizer(
|
| - analysisContext, sourceFactory, analysisOptions.strongMode, store)
|
| - .getLibraryElement(uri);
|
| + return resynthesizingContext.resynthesizer
|
| + .getElement(new ElementLocationImpl.con3([uri]));
|
| } finally {
|
| - analysisContext.dispose();
|
| + resynthesizingContext.context.dispose();
|
| }
|
| }
|
|
|
| - static AnalysisContextImpl _createAnalysisContext(
|
| + static _ResynthesizingAnalysisContext _createResynthesizingContext(
|
| AnalysisOptions analysisOptions,
|
| DeclaredVariables declaredVariables,
|
| SourceFactory sourceFactory,
|
| @@ -203,9 +199,10 @@ class LibraryContext {
|
| analysisContext.analysisOptions = analysisOptions;
|
| analysisContext.declaredVariables.addAll(declaredVariables);
|
| analysisContext.sourceFactory = sourceFactory.clone();
|
| - analysisContext.resultProvider =
|
| - new InputPackagesResultProvider(analysisContext, store);
|
| - return analysisContext;
|
| + var provider = new InputPackagesResultProvider(analysisContext, store);
|
| + analysisContext.resultProvider = provider;
|
| + return new _ResynthesizingAnalysisContext(
|
| + analysisContext, provider.resynthesizer);
|
| }
|
| }
|
|
|
| @@ -268,3 +265,13 @@ class _ContentCacheWrapper implements ContentCache {
|
| return fsState.getFileForPath(path);
|
| }
|
| }
|
| +
|
| +/**
|
| + * Container with analysis context and the corresponding resynthesizer.
|
| + */
|
| +class _ResynthesizingAnalysisContext {
|
| + final AnalysisContextImpl context;
|
| + final ElementResynthesizer resynthesizer;
|
| +
|
| + _ResynthesizingAnalysisContext(this.context, this.resynthesizer);
|
| +}
|
|
|