| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 * [InternalAnalysisContext]. | 232 * [InternalAnalysisContext]. |
| 233 */ | 233 */ |
| 234 abstract class ExtendedAnalysisContext implements InternalAnalysisContext { | 234 abstract class ExtendedAnalysisContext implements InternalAnalysisContext { |
| 235 List<AnalysisTarget> get explicitTargets; | 235 List<AnalysisTarget> get explicitTargets; |
| 236 List<AnalysisTarget> get priorityTargets; | 236 List<AnalysisTarget> get priorityTargets; |
| 237 void set typeProvider(TypeProvider typeProvider); | 237 void set typeProvider(TypeProvider typeProvider); |
| 238 CacheEntry getCacheEntry(AnalysisTarget target); | 238 CacheEntry getCacheEntry(AnalysisTarget target); |
| 239 } | 239 } |
| 240 | 240 |
| 241 /** | 241 /** |
| 242 * An exception indicating that an attempt was made to perform a task on a |
| 243 * target while gathering the inputs to perform the same task for the same |
| 244 * target. |
| 245 */ |
| 246 class InfiniteTaskLoopException extends AnalysisException { |
| 247 /** |
| 248 * Initialize a newly created exception to represent an attempt to perform |
| 249 * the task for the target represented by the given [item]. |
| 250 */ |
| 251 InfiniteTaskLoopException(WorkItem item) : super( |
| 252 'Infinite loop while performing task ${item.descriptor.name} for ${ite
m.target}'); |
| 253 } |
| 254 |
| 255 /** |
| 242 * A description of a single anaysis task that can be performed to advance | 256 * A description of a single anaysis task that can be performed to advance |
| 243 * analysis. | 257 * analysis. |
| 244 */ | 258 */ |
| 245 class WorkItem { | 259 class WorkItem { |
| 246 /** | 260 /** |
| 247 * The context in which the task will be performed. | 261 * The context in which the task will be performed. |
| 248 */ | 262 */ |
| 249 final ExtendedAnalysisContext context; | 263 final ExtendedAnalysisContext context; |
| 250 | 264 |
| 251 /** | 265 /** |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 } | 374 } |
| 361 } | 375 } |
| 362 builder.currentValue = inputEntry.getValue(inputResult); | 376 builder.currentValue = inputEntry.getValue(inputResult); |
| 363 if (!builder.moveNext()) { | 377 if (!builder.moveNext()) { |
| 364 inputs = builder.inputValue; | 378 inputs = builder.inputValue; |
| 365 builder = null; | 379 builder = null; |
| 366 } | 380 } |
| 367 } | 381 } |
| 368 return null; | 382 return null; |
| 369 } | 383 } |
| 384 |
| 385 @override |
| 386 String toString() => 'Run $descriptor on $target'; |
| 370 } | 387 } |
| 371 | 388 |
| 372 /** | 389 /** |
| 373 * A description of the work to be done to compute a desired analysis result. | 390 * A description of the work to be done to compute a desired analysis result. |
| 374 * The class implements a lazy depth-first traversal of the work item's input. | 391 * The class implements a lazy depth-first traversal of the work item's input. |
| 375 */ | 392 */ |
| 376 class WorkOrder implements Iterator<WorkItem> { | 393 class WorkOrder implements Iterator<WorkItem> { |
| 377 /** | 394 /** |
| 378 * The task manager used to build work items. | 395 * The task manager used to build work items. |
| 379 */ | 396 */ |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 TaskDescriptor descriptor = currentItem.descriptor; | 453 TaskDescriptor descriptor = currentItem.descriptor; |
| 437 AnalysisTarget target = currentItem.target; | 454 AnalysisTarget target = currentItem.target; |
| 438 for (WorkItem item in pendingItems) { | 455 for (WorkItem item in pendingItems) { |
| 439 if (item.descriptor == descriptor && item.target == target) { | 456 if (item.descriptor == descriptor && item.target == target) { |
| 440 return true; | 457 return true; |
| 441 } | 458 } |
| 442 } | 459 } |
| 443 return false; | 460 return false; |
| 444 } | 461 } |
| 445 } | 462 } |
| 446 | |
| 447 /** | |
| 448 * An exception indicating that an attempt was made to perform a task on a | |
| 449 * target while gathering the inputs to perform the same task for the same | |
| 450 * target. | |
| 451 */ | |
| 452 class InfiniteTaskLoopException extends AnalysisException { | |
| 453 /** | |
| 454 * Initialize a newly created exception to represent an attempt to perform | |
| 455 * the task for the target represented by the given [item]. | |
| 456 */ | |
| 457 InfiniteTaskLoopException(WorkItem item) : super('Infinite loop while performi
ng task ${item.descriptor.name} for ${item.target}'); | |
| 458 } | |
| OLD | NEW |