Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: pkg/analyzer/lib/src/task/driver.dart

Issue 1783853002: Improve the error message when there is an infinite loop in tasks (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.task.driver; 5 library analyzer.src.task.driver;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/src/context/cache.dart'; 10 import 'package:analyzer/src/context/cache.dart';
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 * the set of [WorkItem]s contained in the cycle (if there are overlapping 494 * the set of [WorkItem]s contained in the cycle (if there are overlapping
495 * cycles, this is the set of all [WorkItem]s in the entire strongly 495 * cycles, this is the set of all [WorkItem]s in the entire strongly
496 * connected component). Otherwise, `null`. 496 * connected component). Otherwise, `null`.
497 */ 497 */
498 final List<WorkItem> dependencyCycle; 498 final List<WorkItem> dependencyCycle;
499 499
500 /** 500 /**
501 * Initialize a newly created exception to represent a failed attempt to 501 * Initialize a newly created exception to represent a failed attempt to
502 * perform the given [task] due to the given [dependencyCycle]. 502 * perform the given [task] due to the given [dependencyCycle].
503 */ 503 */
504 InfiniteTaskLoopException(AnalysisTask task, this.dependencyCycle, 504 InfiniteTaskLoopException(AnalysisTask task, List<WorkItem> dependencyCycle,
505 [this.cyclicPath]) 505 [List<TargetedResult> cyclicPath])
506 : super( 506 : this.dependencyCycle = dependencyCycle,
507 'Infinite loop while performing task ${task.descriptor.name} for ${t ask.target}'); 507 this.cyclicPath = cyclicPath,
508 super(_composeMessage(task, dependencyCycle, cyclicPath));
509
510 /**
511 * Compose an error message based on the data we have available.
512 */
513 static String _composeMessage(AnalysisTask task,
514 List<WorkItem> dependencyCycle, List<TargetedResult> cyclicPath) {
515 StringBuffer buffer = new StringBuffer();
516 buffer.write('Infinite loop while performing task ');
517 buffer.write(task.descriptor.name);
518 buffer.write(' for ');
519 buffer.writeln(task.target);
520 buffer.writeln(' Dependency Cycle:');
521 for (WorkItem item in dependencyCycle) {
522 buffer.write(' ');
523 buffer.writeln(item);
524 }
525 if (cyclicPath != null) {
526 buffer.writeln(' Cyclic Path:');
527 for (TargetedResult result in cyclicPath) {
528 buffer.write(' ');
529 buffer.writeln(result);
530 }
531 }
532 return buffer.toString();
533 }
508 } 534 }
509 535
510 /** 536 /**
511 * Object used by [CycleAwareDependencyWalker] to report a single strongly 537 * Object used by [CycleAwareDependencyWalker] to report a single strongly
512 * connected component of nodes. 538 * connected component of nodes.
513 */ 539 */
514 class StronglyConnectedComponent<Node> { 540 class StronglyConnectedComponent<Node> {
515 /** 541 /**
516 * The nodes contained in the strongly connected component. 542 * The nodes contained in the strongly connected component.
517 */ 543 */
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 final TaskManager taskManager; 857 final TaskManager taskManager;
832 858
833 _WorkOrderDependencyWalker(this.taskManager, WorkItem startingNode) 859 _WorkOrderDependencyWalker(this.taskManager, WorkItem startingNode)
834 : super(startingNode); 860 : super(startingNode);
835 861
836 @override 862 @override
837 WorkItem getNextInput(WorkItem node, List<WorkItem> skipInputs) { 863 WorkItem getNextInput(WorkItem node, List<WorkItem> skipInputs) {
838 return node.gatherInputs(taskManager, skipInputs); 864 return node.gatherInputs(taskManager, skipInputs);
839 } 865 }
840 } 866 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698