| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if (workOrder != null) { | 147 if (workOrder != null) { |
| 148 return workOrder; | 148 return workOrder; |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 /** | 154 /** |
| 155 * Create a work order that will produce the given [result] for the given | 155 * Create a work order that will produce the given [result] for the given |
| 156 * [target]. Return the work order that was created, or `null` if the result | 156 * [target]. Return the work order that was created, or `null` if the result |
| 157 * has already been computed. | 157 * has either already been computed or cannot be computed. |
| 158 */ | 158 */ |
| 159 WorkOrder createWorkOrderForResult( | 159 WorkOrder createWorkOrderForResult( |
| 160 AnalysisTarget target, ResultDescriptor result) { | 160 AnalysisTarget target, ResultDescriptor result) { |
| 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 if (taskDescriptor == null) { |
| 170 return null; |
| 171 } |
| 169 try { | 172 try { |
| 170 WorkItem workItem = | 173 WorkItem workItem = |
| 171 new WorkItem(context, target, taskDescriptor, result, 0, null); | 174 new WorkItem(context, target, taskDescriptor, result, 0, null); |
| 172 return new WorkOrder(taskManager, workItem); | 175 return new WorkOrder(taskManager, workItem); |
| 173 } catch (exception, stackTrace) { | 176 } catch (exception, stackTrace) { |
| 174 throw new AnalysisException( | 177 throw new AnalysisException( |
| 175 'Could not create work order (target = $target; taskDescriptor = $task
Descriptor; result = $result)', | 178 'Could not create work order (target = $target; taskDescriptor = $task
Descriptor; result = $result)', |
| 176 new CaughtException(exception, stackTrace)); | 179 new CaughtException(exception, stackTrace)); |
| 177 } | 180 } |
| 178 } | 181 } |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 // | 705 // |
| 703 throw new UnimplementedError(); | 706 throw new UnimplementedError(); |
| 704 } else if (inputState != CacheState.VALID) { | 707 } else if (inputState != CacheState.VALID) { |
| 705 if (context.aboutToComputeResult(inputEntry, inputResult)) { | 708 if (context.aboutToComputeResult(inputEntry, inputResult)) { |
| 706 inputState = CacheState.VALID; | 709 inputState = CacheState.VALID; |
| 707 builder.currentValue = inputEntry.getValue(inputResult); | 710 builder.currentValue = inputEntry.getValue(inputResult); |
| 708 } else { | 711 } else { |
| 709 try { | 712 try { |
| 710 TaskDescriptor descriptor = | 713 TaskDescriptor descriptor = |
| 711 taskManager.findTask(inputTarget, inputResult); | 714 taskManager.findTask(inputTarget, inputResult); |
| 715 if (descriptor == null) { |
| 716 throw new AnalysisException( |
| 717 'Cannot find task to build $inputResult for $inputTarget'); |
| 718 } |
| 712 return new WorkItem(context, inputTarget, descriptor, inputResult, | 719 return new WorkItem(context, inputTarget, descriptor, inputResult, |
| 713 level + 1, workOrder); | 720 level + 1, workOrder); |
| 714 } on AnalysisException catch (exception, stackTrace) { | 721 } on AnalysisException catch (exception, stackTrace) { |
| 715 this.exception = new CaughtException(exception, stackTrace); | 722 this.exception = new CaughtException(exception, stackTrace); |
| 716 return null; | 723 return null; |
| 724 } catch (exception, stackTrace) { |
| 725 this.exception = new CaughtException( |
| 726 throw new AnalysisException( |
| 727 'Cannot create work order to build $inputResult for $inputTa
rget', |
| 728 exception), |
| 729 stackTrace); |
| 730 return null; |
| 717 } | 731 } |
| 718 } | 732 } |
| 719 } else { | 733 } else { |
| 720 builder.currentValue = inputEntry.getValue(inputResult); | 734 builder.currentValue = inputEntry.getValue(inputResult); |
| 721 if (builder.flushOnAccess) { | 735 if (builder.flushOnAccess) { |
| 722 inputEntry.setState(inputResult, CacheState.FLUSHED); | 736 inputEntry.setState(inputResult, CacheState.FLUSHED); |
| 723 } | 737 } |
| 724 } | 738 } |
| 725 if (!builder.moveNext()) { | 739 if (!builder.moveNext()) { |
| 726 inputs = builder.inputValue; | 740 inputs = builder.inputValue; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 final TaskManager taskManager; | 828 final TaskManager taskManager; |
| 815 | 829 |
| 816 _WorkOrderDependencyWalker(this.taskManager, WorkItem startingNode) | 830 _WorkOrderDependencyWalker(this.taskManager, WorkItem startingNode) |
| 817 : super(startingNode); | 831 : super(startingNode); |
| 818 | 832 |
| 819 @override | 833 @override |
| 820 WorkItem getNextInput(WorkItem node, List<WorkItem> skipInputs) { | 834 WorkItem getNextInput(WorkItem node, List<WorkItem> skipInputs) { |
| 821 return node.gatherInputs(taskManager, skipInputs); | 835 return node.gatherInputs(taskManager, skipInputs); |
| 822 } | 836 } |
| 823 } | 837 } |
| OLD | NEW |