| Index: pkg/analyzer/lib/src/context/context.dart
|
| diff --git a/pkg/analyzer/lib/src/context/context.dart b/pkg/analyzer/lib/src/context/context.dart
|
| index 4714557e35a910b1a9a07d958b866ce1cca77006..d9a417ab64cc1cf823c690a3cf992d3cf0533121 100644
|
| --- a/pkg/analyzer/lib/src/context/context.dart
|
| +++ b/pkg/analyzer/lib/src/context/context.dart
|
| @@ -25,6 +25,7 @@ import 'package:analyzer/src/generated/resolver.dart';
|
| import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
|
| import 'package:analyzer/src/generated/source.dart';
|
| import 'package:analyzer/src/generated/utilities_collection.dart';
|
| +import 'package:analyzer/src/summary/resynthesize.dart';
|
| import 'package:analyzer/src/task/dart.dart';
|
| import 'package:analyzer/src/task/dart_work_manager.dart';
|
| import 'package:analyzer/src/task/driver.dart';
|
| @@ -52,6 +53,33 @@ import 'package:html/dom.dart' show Document;
|
| typedef T PendingFutureComputer<T>(CacheEntry entry);
|
|
|
| /**
|
| + * Helper for [InternalAnalysisContext.aboutToComputeResult].
|
| + */
|
| +abstract class AboutToComputeResultHelper {
|
| + final InternalAnalysisContext context;
|
| +
|
| + /**
|
| + * The [SummaryResynthesizer] of this context, maybe `null`.
|
| + */
|
| + SummaryResynthesizer resynthesizer;
|
| +
|
| + AboutToComputeResultHelper(this.context);
|
| +
|
| + /**
|
| + * This method is invoked by an [InternalAnalysisContext] when the state of
|
| + * the [result] of the [entry] is [CacheState.INVALID], so it is about to be
|
| + * computed.
|
| + *
|
| + * If the processor knows how to provide the value, it sets the value into
|
| + * the [entry] with all required dependencies, and returns `true`.
|
| + *
|
| + * Otherwise, it returns `false` to indicate that the result should be
|
| + * computed as usually.
|
| + */
|
| + bool compute(CacheEntry entry, ResultDescriptor result);
|
| +}
|
| +
|
| +/**
|
| * An [AnalysisContext] in which analysis can be performed.
|
| */
|
| class AnalysisContextImpl implements InternalAnalysisContext {
|
| @@ -185,6 +213,9 @@ class AnalysisContextImpl implements InternalAnalysisContext {
|
| */
|
| List<AnalysisListener> _listeners = new List<AnalysisListener>();
|
|
|
| + @override
|
| + AboutToComputeResultHelper aboutToComputeResultHelper;
|
| +
|
| /**
|
| * The most recently incrementally resolved source, or `null` when it was
|
| * already validated, or the most recent change was not incrementally resolved.
|
| @@ -489,26 +520,21 @@ class AnalysisContextImpl implements InternalAnalysisContext {
|
| @override
|
| bool aboutToComputeResult(CacheEntry entry, ResultDescriptor result) {
|
| return PerformanceStatistics.summary.makeCurrentWhile(() {
|
| - AnalysisTarget target = entry.target;
|
| - // TYPE_PROVIDER
|
| - if (target is AnalysisContextTarget && result == TYPE_PROVIDER) {
|
| - DartSdk dartSdk = sourceFactory.dartSdk;
|
| - if (dartSdk != null) {
|
| - AnalysisContext sdkContext = dartSdk.context;
|
| - if (!identical(sdkContext, this) &&
|
| - sdkContext is InternalAnalysisContext) {
|
| - return sdkContext.aboutToComputeResult(entry, result);
|
| - }
|
| - }
|
| + // Use this helper if it is set.
|
| + if (aboutToComputeResultHelper != null &&
|
| + aboutToComputeResultHelper.compute(entry, result)) {
|
| + return true;
|
| }
|
| - // A result for a Source.
|
| - Source source = target.source;
|
| - if (source != null) {
|
| - InternalAnalysisContext context = _cache.getContextFor(source);
|
| - if (!identical(context, this)) {
|
| - return context.aboutToComputeResult(entry, result);
|
| + // Ask the SDK.
|
| + DartSdk dartSdk = sourceFactory.dartSdk;
|
| + if (dartSdk != null) {
|
| + AnalysisContext sdkContext = dartSdk.context;
|
| + if (!identical(sdkContext, this) &&
|
| + sdkContext is InternalAnalysisContext) {
|
| + return sdkContext.aboutToComputeResult(entry, result);
|
| }
|
| }
|
| + // Cannot provide the result.
|
| return false;
|
| });
|
| }
|
|
|