| 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 88df107a3bc479c8aa6046653c6d118e0eff9f6a..f077b3a3f8d07a1279745d4712fb7b1e402938fa 100644
|
| --- a/pkg/analyzer/lib/src/task/driver.dart
|
| +++ b/pkg/analyzer/lib/src/task/driver.dart
|
| @@ -413,8 +413,46 @@ class WorkOrder implements Iterator<WorkItem> {
|
| while (childItem != null) {
|
| pendingItems.add(currentItem);
|
| currentItem = childItem;
|
| + if (_hasInfiniteTaskLoop()) {
|
| + currentItem = pendingItems.removeLast();
|
| + try {
|
| + throw new InfiniteTaskLoopException(childItem);
|
| + } on InfiniteTaskLoopException catch (exception, stackTrace) {
|
| + currentItem.exception = new CaughtException(exception, stackTrace);
|
| + }
|
| + return true;
|
| + }
|
| childItem = currentItem.gatherInputs(taskManager);
|
| }
|
| return true;
|
| }
|
| +
|
| + /**
|
| + * Check to see whether the current work item is attempting to perform the
|
| + * same task on the same target as any of the pending work items. If it is,
|
| + * then throw an [InfiniteTaskLoopException].
|
| + */
|
| + bool _hasInfiniteTaskLoop() {
|
| + TaskDescriptor descriptor = currentItem.descriptor;
|
| + AnalysisTarget target = currentItem.target;
|
| + for (WorkItem item in pendingItems) {
|
| + if (item.descriptor == descriptor && item.target == target) {
|
| + return true;
|
| + }
|
| + }
|
| + return false;
|
| + }
|
| +}
|
| +
|
| +/**
|
| + * An exception indicating that an attempt was made to perform a task on a
|
| + * target while gathering the inputs to perform the same task for the same
|
| + * target.
|
| + */
|
| +class InfiniteTaskLoopException extends AnalysisException {
|
| + /**
|
| + * Initialize a newly created exception to represent an attempt to perform
|
| + * the task for the target represented by the given [item].
|
| + */
|
| + InfiniteTaskLoopException(WorkItem item) : super('Infinite loop while performing task ${item.descriptor.name} for ${item.target}');
|
| }
|
|
|