| 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 10 matching lines...) Expand all Loading... |
| 21 */ | 21 */ |
| 22 class AnalysisDriver { | 22 class AnalysisDriver { |
| 23 /** | 23 /** |
| 24 * The task manager used to figure out how to compute analysis results. | 24 * The task manager used to figure out how to compute analysis results. |
| 25 */ | 25 */ |
| 26 final TaskManager taskManager; | 26 final TaskManager taskManager; |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * The context in which analysis is to be performed. | 29 * The context in which analysis is to be performed. |
| 30 */ | 30 */ |
| 31 final ExtendedAnalysisContext context; | 31 final InternalAnalysisContext context; |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * The work order that was previously computed but that has not yet been | 34 * The work order that was previously computed but that has not yet been |
| 35 * completed. | 35 * completed. |
| 36 */ | 36 */ |
| 37 WorkOrder currentWorkOrder; | 37 WorkOrder currentWorkOrder; |
| 38 | 38 |
| 39 /** | 39 /** |
| 40 * The controller that is notified when a task is started. | 40 * The controller that is notified when a task is started. |
| 41 */ | 41 */ |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 */ | 116 */ |
| 117 WorkOrder createWorkOrderForResult( | 117 WorkOrder createWorkOrderForResult( |
| 118 AnalysisTarget target, ResultDescriptor result) { | 118 AnalysisTarget target, ResultDescriptor result) { |
| 119 CacheEntry entry = context.getCacheEntry(target); | 119 CacheEntry entry = context.getCacheEntry(target); |
| 120 CacheState state = entry.getState(result); | 120 CacheState state = entry.getState(result); |
| 121 if (state == CacheState.VALID || | 121 if (state == CacheState.VALID || |
| 122 state == CacheState.ERROR || | 122 state == CacheState.ERROR || |
| 123 state == CacheState.IN_PROCESS) { | 123 state == CacheState.IN_PROCESS) { |
| 124 return null; | 124 return null; |
| 125 } | 125 } |
| 126 return new WorkOrder(taskManager, | 126 try { |
| 127 new WorkItem(context, target, taskManager.findTask(target, result))); | 127 return new WorkOrder(taskManager, |
| 128 new WorkItem(context, target, taskManager.findTask(target, result))); |
| 129 } catch (exception, stackTrace) { |
| 130 throw new AnalysisException( |
| 131 'Could not create work order (target = $target; result = $result)', |
| 132 new CaughtException(exception, stackTrace)); |
| 133 } |
| 128 } | 134 } |
| 129 | 135 |
| 130 /** | 136 /** |
| 131 * Create a work order that will produce the required analysis results for | 137 * Create a work order that will produce the required analysis results for |
| 132 * the given [target]. If [isPriority] is true, then the target is a priority | 138 * the given [target]. If [isPriority] is true, then the target is a priority |
| 133 * target. Return the work order that was created, or `null` if there is no | 139 * target. Return the work order that was created, or `null` if there is no |
| 134 * further work that needs to be done for the given target. | 140 * further work that needs to be done for the given target. |
| 135 */ | 141 */ |
| 136 WorkOrder createWorkOrderForTarget(AnalysisTarget target, bool isPriority) { | 142 WorkOrder createWorkOrderForTarget(AnalysisTarget target, bool isPriority) { |
| 137 for (ResultDescriptor result in taskManager.generalResults) { | 143 for (ResultDescriptor result in taskManager.generalResults) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 } | 259 } |
| 254 | 260 |
| 255 /** | 261 /** |
| 256 * A description of a single anaysis task that can be performed to advance | 262 * A description of a single anaysis task that can be performed to advance |
| 257 * analysis. | 263 * analysis. |
| 258 */ | 264 */ |
| 259 class WorkItem { | 265 class WorkItem { |
| 260 /** | 266 /** |
| 261 * The context in which the task will be performed. | 267 * The context in which the task will be performed. |
| 262 */ | 268 */ |
| 263 final ExtendedAnalysisContext context; | 269 final InternalAnalysisContext context; |
| 264 | 270 |
| 265 /** | 271 /** |
| 266 * The target for which a task is to be performed. | 272 * The target for which a task is to be performed. |
| 267 */ | 273 */ |
| 268 final AnalysisTarget target; | 274 final AnalysisTarget target; |
| 269 | 275 |
| 270 /** | 276 /** |
| 271 * A description of the task to be performed. | 277 * A description of the task to be performed. |
| 272 */ | 278 */ |
| 273 final TaskDescriptor descriptor; | 279 final TaskDescriptor descriptor; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 TaskDescriptor descriptor = currentItem.descriptor; | 459 TaskDescriptor descriptor = currentItem.descriptor; |
| 454 AnalysisTarget target = currentItem.target; | 460 AnalysisTarget target = currentItem.target; |
| 455 for (WorkItem item in pendingItems) { | 461 for (WorkItem item in pendingItems) { |
| 456 if (item.descriptor == descriptor && item.target == target) { | 462 if (item.descriptor == descriptor && item.target == target) { |
| 457 return true; | 463 return true; |
| 458 } | 464 } |
| 459 } | 465 } |
| 460 return false; | 466 return false; |
| 461 } | 467 } |
| 462 } | 468 } |
| OLD | NEW |