Chromium Code Reviews| Index: pkg/analyzer/lib/src/task/driver.dart |
| diff --git a/pkg/analyzer/lib/src/task/driver.dart b/pkg/analyzer/lib/src/task/driver.dart |
| index 7cdbe1cf4fef0a6cddb6bf575b86658cdf425687..609b03fb55b8b205e061df6be6dd5049bec5010e 100644 |
| --- a/pkg/analyzer/lib/src/task/driver.dart |
| +++ b/pkg/analyzer/lib/src/task/driver.dart |
| @@ -44,6 +44,11 @@ class AnalysisDriver { |
| final InternalAnalysisContext context; |
| /** |
| + * The alternative source of analysis results. |
| + */ |
| + ResultProvider resultProvider; |
| + |
| + /** |
| * The map of [ComputedResult] controllers. |
| */ |
| final Map<ResultDescriptor, StreamController<ComputedResult>> |
| @@ -167,8 +172,8 @@ class AnalysisDriver { |
| } |
| TaskDescriptor taskDescriptor = taskManager.findTask(target, result); |
| try { |
| - WorkItem workItem = |
| - new WorkItem(context, target, taskDescriptor, result, 0, null); |
| + WorkItem workItem = new WorkItem( |
| + context, resultProvider, target, taskDescriptor, result, 0, null); |
| return new WorkOrder(taskManager, workItem); |
| } catch (exception, stackTrace) { |
| throw new AnalysisException( |
| @@ -504,7 +509,24 @@ class InfiniteTaskLoopException extends AnalysisException { |
| } |
| /** |
| - * Object used by CycleAwareDependencyWalker to report a single strongly |
| + * The object used by [WorkItem] to get values without using tasks. |
| + */ |
| +abstract class ResultProvider { |
| + /** |
| + * [WorkItem] call this method when the [result] of the [entry] is |
|
Paul Berry
2015/12/20 15:30:48
s/call/calls/
|
| + * [CacheState.INVALID], so it is about to schedule its computation. |
| + * |
| + * If the provider knows how to provide the value, it sets the value into |
| + * the [entry] with all required dependencies, and returns `true`. |
| + * |
| + * Otherwise, return `false` and the value will be computed. |
|
Paul Berry
2015/12/20 15:30:48
Grammar seems a little funny here. How about:
"
|
| + */ |
| + bool provideResult(InternalAnalysisContext context, CacheEntry entry, |
| + ResultDescriptor result); |
| +} |
| + |
| +/** |
| + * Object used by [CycleAwareDependencyWalker] to report a single strongly |
| * connected component of nodes. |
| */ |
| class StronglyConnectedComponent<Node> { |
| @@ -535,6 +557,11 @@ class WorkItem { |
| final InternalAnalysisContext context; |
| /** |
| + * The alternative source of analysis results. |
| + */ |
| + final ResultProvider resultProvider; |
| + |
| + /** |
| * The target for which a task is to be performed. |
| */ |
| final AnalysisTarget target; |
| @@ -597,8 +624,8 @@ class WorkItem { |
| * Initialize a newly created work item to compute the inputs for the task |
| * described by the given descriptor. |
| */ |
| - WorkItem(this.context, this.target, this.descriptor, this.spawningResult, |
| - this.level, this.workOrder) { |
| + WorkItem(this.context, this.resultProvider, this.target, this.descriptor, |
| + this.spawningResult, this.level, this.workOrder) { |
| AnalysisTarget actualTarget = |
| identical(target, AnalysisContextTarget.request) |
| ? new AnalysisContextTarget(context) |
| @@ -702,14 +729,20 @@ class WorkItem { |
| // |
| throw new UnimplementedError(); |
| } else if (inputState != CacheState.VALID) { |
| - try { |
| - TaskDescriptor descriptor = |
| - taskManager.findTask(inputTarget, inputResult); |
| - return new WorkItem(context, inputTarget, descriptor, inputResult, |
| - level + 1, workOrder); |
| - } on AnalysisException catch (exception, stackTrace) { |
| - this.exception = new CaughtException(exception, stackTrace); |
| - return null; |
| + if (resultProvider != null && |
|
Brian Wilkerson
2015/12/21 17:01:44
I'm guessing that the null check will eventually b
|
| + resultProvider.provideResult(context, inputEntry, inputResult)) { |
| + inputState = CacheState.VALID; |
| + builder.currentValue = inputEntry.getValue(inputResult); |
| + } else { |
| + try { |
| + TaskDescriptor descriptor = |
| + taskManager.findTask(inputTarget, inputResult); |
| + return new WorkItem(context, resultProvider, inputTarget, |
| + descriptor, inputResult, level + 1, workOrder); |
| + } on AnalysisException catch (exception, stackTrace) { |
| + this.exception = new CaughtException(exception, stackTrace); |
| + return null; |
| + } |
| } |
| } else { |
| builder.currentValue = inputEntry.getValue(inputResult); |