Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 28 matching lines...) Expand all Loading... | |
| 39 final List<WorkManager> workManagers; | 39 final List<WorkManager> workManagers; |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * The context in which analysis is to be performed. | 42 * The context in which analysis is to be performed. |
| 43 */ | 43 */ |
| 44 final InternalAnalysisContext context; | 44 final InternalAnalysisContext context; |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * The map of [ComputedResult] controllers. | 47 * The map of [ComputedResult] controllers. |
| 48 */ | 48 */ |
| 49 final Map<ResultDescriptor, | 49 final Map<ResultDescriptor, StreamController<ComputedResult>> |
| 50 StreamController<ComputedResult>> resultComputedControllers = | 50 resultComputedControllers = |
| 51 <ResultDescriptor, StreamController<ComputedResult>>{}; | 51 <ResultDescriptor, StreamController<ComputedResult>>{}; |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * The work order that was previously computed but that has not yet been | 54 * The work order that was previously computed but that has not yet been |
| 55 * completed. | 55 * completed. |
| 56 */ | 56 */ |
| 57 WorkOrder currentWorkOrder; | 57 WorkOrder currentWorkOrder; |
| 58 | 58 |
| 59 /** | 59 /** |
| 60 * Indicates whether any tasks are currently being performed (or building | 60 * Indicates whether any tasks are currently being performed (or building |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 CacheEntry entry = context.getCacheEntry(target); | 161 CacheEntry entry = context.getCacheEntry(target); |
| 162 CacheState state = entry.getState(result); | 162 CacheState state = entry.getState(result); |
| 163 if (state == CacheState.VALID || | 163 if (state == CacheState.VALID || |
| 164 state == CacheState.ERROR || | 164 state == CacheState.ERROR || |
| 165 state == CacheState.IN_PROCESS) { | 165 state == CacheState.IN_PROCESS) { |
| 166 return null; | 166 return null; |
| 167 } | 167 } |
| 168 TaskDescriptor taskDescriptor = taskManager.findTask(target, result); | 168 TaskDescriptor taskDescriptor = taskManager.findTask(target, result); |
| 169 try { | 169 try { |
| 170 WorkItem workItem = | 170 WorkItem workItem = |
| 171 new WorkItem(context, target, taskDescriptor, result, null); | 171 new WorkItem(context, target, taskDescriptor, result, 0, null); |
| 172 return new WorkOrder(taskManager, workItem); | 172 return new WorkOrder(taskManager, workItem); |
| 173 } catch (exception, stackTrace) { | 173 } catch (exception, stackTrace) { |
| 174 throw new AnalysisException( | 174 throw new AnalysisException( |
| 175 'Could not create work order (target = $target; taskDescriptor = $task Descriptor; result = $result)', | 175 'Could not create work order (target = $target; taskDescriptor = $task Descriptor; result = $result)', |
| 176 new CaughtException(exception, stackTrace)); | 176 new CaughtException(exception, stackTrace)); |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 | 179 |
| 180 /** | 180 /** |
| 181 * Create a work order that will produce the required analysis results for | 181 * Create a work order that will produce the required analysis results for |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 /** | 542 /** |
| 543 * A description of the task to be performed. | 543 * A description of the task to be performed. |
| 544 */ | 544 */ |
| 545 final TaskDescriptor descriptor; | 545 final TaskDescriptor descriptor; |
| 546 | 546 |
| 547 /** | 547 /** |
| 548 * The [ResultDescriptor] which was led to this work item being spawned. | 548 * The [ResultDescriptor] which was led to this work item being spawned. |
| 549 */ | 549 */ |
| 550 final ResultDescriptor spawningResult; | 550 final ResultDescriptor spawningResult; |
| 551 | 551 |
| 552 final int level; | |
|
Paul Berry
2015/12/17 15:05:47
Doc comment missing - did you leave this code in b
| |
| 553 | |
| 552 /** | 554 /** |
| 553 * The work order that this item is part of, may be `null`. | 555 * The work order that this item is part of, may be `null`. |
| 554 */ | 556 */ |
| 555 WorkOrder workOrder; | 557 WorkOrder workOrder; |
| 556 | 558 |
| 557 /** | 559 /** |
| 558 * An iterator used to iterate over the descriptors of the inputs to the task, | 560 * An iterator used to iterate over the descriptors of the inputs to the task, |
| 559 * or `null` if all of the inputs have been collected and the task can be | 561 * or `null` if all of the inputs have been collected and the task can be |
| 560 * created. | 562 * created. |
| 561 */ | 563 */ |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 586 * cycles, this is the set of all [WorkItem]s in the entire strongly | 588 * cycles, this is the set of all [WorkItem]s in the entire strongly |
| 587 * connected component). Otherwise, `null`. | 589 * connected component). Otherwise, `null`. |
| 588 */ | 590 */ |
| 589 List<WorkItem> dependencyCycle; | 591 List<WorkItem> dependencyCycle; |
| 590 | 592 |
| 591 /** | 593 /** |
| 592 * Initialize a newly created work item to compute the inputs for the task | 594 * Initialize a newly created work item to compute the inputs for the task |
| 593 * described by the given descriptor. | 595 * described by the given descriptor. |
| 594 */ | 596 */ |
| 595 WorkItem(this.context, this.target, this.descriptor, this.spawningResult, | 597 WorkItem(this.context, this.target, this.descriptor, this.spawningResult, |
| 596 this.workOrder) { | 598 this.level, this.workOrder) { |
| 597 AnalysisTarget actualTarget = | 599 AnalysisTarget actualTarget = |
| 598 identical(target, AnalysisContextTarget.request) | 600 identical(target, AnalysisContextTarget.request) |
| 599 ? new AnalysisContextTarget(context) | 601 ? new AnalysisContextTarget(context) |
| 600 : target; | 602 : target; |
| 603 // print('${'\t' * level}$spawningResult of $actualTarget'); | |
|
Paul Berry
2015/12/17 15:05:47
Looks like this was left in by accident too
| |
| 601 Map<String, TaskInput> inputDescriptors = | 604 Map<String, TaskInput> inputDescriptors = |
| 602 descriptor.createTaskInputs(actualTarget); | 605 descriptor.createTaskInputs(actualTarget); |
| 603 builder = new TopLevelTaskInputBuilder(inputDescriptors); | 606 builder = new TopLevelTaskInputBuilder(inputDescriptors); |
| 604 if (!builder.moveNext()) { | 607 if (!builder.moveNext()) { |
| 605 builder = null; | 608 builder = null; |
| 606 } | 609 } |
| 607 inputs = new HashMap<String, dynamic>(); | 610 inputs = new HashMap<String, dynamic>(); |
| 608 } | 611 } |
| 609 | 612 |
| 610 @override | 613 @override |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 692 // input onto a waiting list and proceed to the next input so that work | 695 // input onto a waiting list and proceed to the next input so that work |
| 693 // could proceed, but given that the only result that can currently be | 696 // could proceed, but given that the only result that can currently be |
| 694 // IN_PROCESS is CONTENT, I don't know that it's worth the extra effort | 697 // IN_PROCESS is CONTENT, I don't know that it's worth the extra effort |
| 695 // to implement the general solution at this point. | 698 // to implement the general solution at this point. |
| 696 // | 699 // |
| 697 throw new UnimplementedError(); | 700 throw new UnimplementedError(); |
| 698 } else if (inputState != CacheState.VALID) { | 701 } else if (inputState != CacheState.VALID) { |
| 699 try { | 702 try { |
| 700 TaskDescriptor descriptor = | 703 TaskDescriptor descriptor = |
| 701 taskManager.findTask(inputTarget, inputResult); | 704 taskManager.findTask(inputTarget, inputResult); |
| 702 return new WorkItem( | 705 return new WorkItem(context, inputTarget, descriptor, inputResult, |
| 703 context, inputTarget, descriptor, inputResult, workOrder); | 706 level + 1, workOrder); |
| 704 } on AnalysisException catch (exception, stackTrace) { | 707 } on AnalysisException catch (exception, stackTrace) { |
| 705 this.exception = new CaughtException(exception, stackTrace); | 708 this.exception = new CaughtException(exception, stackTrace); |
| 706 return null; | 709 return null; |
| 707 } | 710 } |
| 708 } else { | 711 } else { |
| 709 builder.currentValue = inputEntry.getValue(inputResult); | 712 builder.currentValue = inputEntry.getValue(inputResult); |
| 710 if (builder.flushOnAccess) { | 713 if (builder.flushOnAccess) { |
| 711 inputEntry.setState(inputResult, CacheState.FLUSHED); | 714 inputEntry.setState(inputResult, CacheState.FLUSHED); |
| 712 } | 715 } |
| 713 } | 716 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 803 final TaskManager taskManager; | 806 final TaskManager taskManager; |
| 804 | 807 |
| 805 _WorkOrderDependencyWalker(this.taskManager, WorkItem startingNode) | 808 _WorkOrderDependencyWalker(this.taskManager, WorkItem startingNode) |
| 806 : super(startingNode); | 809 : super(startingNode); |
| 807 | 810 |
| 808 @override | 811 @override |
| 809 WorkItem getNextInput(WorkItem node, List<WorkItem> skipInputs) { | 812 WorkItem getNextInput(WorkItem node, List<WorkItem> skipInputs) { |
| 810 return node.gatherInputs(taskManager, skipInputs); | 813 return node.gatherInputs(taskManager, skipInputs); |
| 811 } | 814 } |
| 812 } | 815 } |
| OLD | NEW |