Chromium Code Reviews| 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..769a07bd15d723733c5ab50bfde1e080d2eb3990 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,20 @@ 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) { |
| + return aboutToComputeResultHelper.compute(entry, result); |
|
Brian Wilkerson
2016/01/14 22:45:28
Shouldn't this fall through to check for results f
scheglov
2016/01/14 22:51:35
Ack.
Thank you.
|
| } |
| - // 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; |
| }); |
| } |