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.task.model; | 5 library analyzer.task.model; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; | 9 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; |
10 import 'package:analyzer/src/generated/error.dart' show AnalysisError; | |
10 import 'package:analyzer/src/generated/java_engine.dart'; | 11 import 'package:analyzer/src/generated/java_engine.dart'; |
11 import 'package:analyzer/src/generated/source.dart'; | 12 import 'package:analyzer/src/generated/source.dart'; |
13 import 'package:analyzer/src/generated/utilities_general.dart'; | |
12 import 'package:analyzer/src/task/driver.dart'; | 14 import 'package:analyzer/src/task/driver.dart'; |
13 import 'package:analyzer/src/task/model.dart'; | 15 import 'package:analyzer/src/task/model.dart'; |
14 | 16 |
15 /** | 17 /** |
16 * A function that converts the given [key] and [value] into a [TaskInput]. | 18 * A function that converts the given [key] and [value] into a [TaskInput]. |
17 */ | 19 */ |
18 typedef TaskInput<E> BinaryFunction<K, V, E>(K key, V value); | 20 typedef TaskInput<E> BinaryFunction<K, V, E>(K key, V value); |
19 | 21 |
20 /** | 22 /** |
21 * A function that takes an analysis [context] and an analysis [target] and | 23 * A function that takes an analysis [context] and an analysis [target] and |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
383 String get name; | 385 String get name; |
384 | 386 |
385 /** | 387 /** |
386 * Return a task input that can be used to compute this result for the given | 388 * Return a task input that can be used to compute this result for the given |
387 * [target]. | 389 * [target]. |
388 */ | 390 */ |
389 TaskInput<V> of(AnalysisTarget target); | 391 TaskInput<V> of(AnalysisTarget target); |
390 } | 392 } |
391 | 393 |
392 /** | 394 /** |
395 * A specification of the given [result] for the given [target]. | |
Brian Wilkerson
2015/08/26 16:19:32
We should probably include the boilerplate for "cl
| |
396 */ | |
397 class TargetedResult { | |
398 /** | |
399 * An empty list of results. | |
400 */ | |
401 static final List<TargetedResult> EMPTY_LIST = const <TargetedResult>[]; | |
402 | |
403 /** | |
404 * The target with which the result is associated. | |
405 */ | |
406 final AnalysisTarget target; | |
407 | |
408 /** | |
409 * The result associated with the target. | |
410 */ | |
411 final ResultDescriptor result; | |
412 | |
413 /** | |
414 * Initialize a new targeted result. | |
415 */ | |
416 TargetedResult(this.target, this.result); | |
417 | |
418 @override | |
419 int get hashCode { | |
420 return JenkinsSmiHash.combine(target.hashCode, result.hashCode); | |
421 } | |
422 | |
423 @override | |
424 bool operator ==(other) { | |
425 return other is TargetedResult && | |
426 other.target == target && | |
427 other.result == result; | |
428 } | |
429 | |
430 @override | |
431 String toString() => '$result for $target'; | |
432 } | |
433 | |
434 /** | |
393 * A description of an [AnalysisTask]. | 435 * A description of an [AnalysisTask]. |
394 */ | 436 */ |
395 abstract class TaskDescriptor { | 437 abstract class TaskDescriptor { |
396 /** | 438 /** |
397 * Initialize a newly created task descriptor to have the given [name] and to | 439 * Initialize a newly created task descriptor to have the given [name] and to |
398 * describe a task that takes the inputs built using the given [inputBuilder], | 440 * describe a task that takes the inputs built using the given [inputBuilder], |
399 * and produces the given [results]. The [buildTask] will be used to create | 441 * and produces the given [results]. The [buildTask] will be used to create |
400 * the instance of [AnalysisTask] thusly described. | 442 * the instance of [AnalysisTask] thusly described. |
401 */ | 443 */ |
402 factory TaskDescriptor(String name, BuildTask buildTask, | 444 factory TaskDescriptor(String name, BuildTask buildTask, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 * be computed, or `false` if the inputs have been computed. | 549 * be computed, or `false` if the inputs have been computed. |
508 * | 550 * |
509 * It is safe to invoke [moveNext] after it has returned `false`. In this case | 551 * It is safe to invoke [moveNext] after it has returned `false`. In this case |
510 * [moveNext] has no effect and will again return `false`. | 552 * [moveNext] has no effect and will again return `false`. |
511 * | 553 * |
512 * Throws a [StateError] if the value of the current result has not been | 554 * Throws a [StateError] if the value of the current result has not been |
513 * provided using [currentValue]. | 555 * provided using [currentValue]. |
514 */ | 556 */ |
515 bool moveNext(); | 557 bool moveNext(); |
516 } | 558 } |
559 | |
560 /** | |
561 * [WorkManager]s are used to drive analysis. | |
562 * | |
563 * They know specific of the targets and results they care about, | |
564 * so they can request analysis results in optimal order. | |
Brian Wilkerson
2015/08/26 16:19:32
We should also have boilerplate here saying "only
| |
565 */ | |
566 abstract class WorkManager { | |
567 /** | |
568 * Notifies the manager about changes in the explicit source list. | |
569 */ | |
570 void applyChange(List<Source> addedSources, List<Source> changedSources, | |
571 List<Source> removedSources); | |
572 | |
573 /** | |
574 * Notifies the managers that the given set of priority [targets] was set. | |
575 */ | |
576 void applyPriorityTargets(List<AnalysisTarget> targets); | |
577 | |
578 /** | |
579 * Return a list of all of the errors associated with the given [source]. | |
580 * The list of errors will be empty if the source is not known to the context | |
581 * or if there are no errors in the source. The errors contained in the list | |
582 * can be incomplete. | |
583 */ | |
584 List<AnalysisError> getErrors(Source source); | |
585 | |
586 /** | |
587 * Return the next [TargetedResult] that this work manager wants to be | |
588 * computed, or `null` if this manager doesn't need any new results. | |
589 */ | |
590 TargetedResult getNextResult(); | |
591 | |
592 /** | |
593 * Return the priority if the next work order this work manager want to be | |
594 * computed. The [AnalysisDriver] will perform the work order with | |
595 * the highest priority. | |
596 * | |
597 * Even if the returned value is [WorkOrderPriority.NONE], it still does not | |
598 * guarantee that [getNextResult] will return not `null`. | |
599 */ | |
600 WorkOrderPriority getNextResultPriority(); | |
601 | |
602 /** | |
603 * Notifies the manager about analysis options changes. | |
604 */ | |
605 void onAnalysisOptionsChanged(); | |
606 | |
607 /** | |
608 * Notifies the manager about [SourceFactory] changes. | |
609 */ | |
610 void onSourceFactoryChanged(); | |
611 | |
612 /** | |
613 * Notifies the manager that the given [outputs] were produced for | |
614 * the given [target]. | |
615 */ | |
616 void resultsComputed( | |
617 AnalysisTarget target, Map<ResultDescriptor, dynamic> outputs); | |
618 } | |
619 | |
620 /** | |
621 * The priorities of work orders returned by [WorkManager]s. | |
Brian Wilkerson
2015/08/26 16:19:32
Should we have a disclaimer about clients needing
| |
622 */ | |
623 enum WorkOrderPriority { | |
624 /** | |
625 * Responding to an user's action. | |
626 */ | |
627 INTERACTIVE, | |
628 | |
629 /** | |
630 * Computing information for priority sources. | |
631 */ | |
632 PRIORITY, | |
633 | |
634 /** | |
635 * A work should be done, but without any special urgency. | |
636 */ | |
637 NORMAL, | |
638 | |
639 /** | |
640 * Nothing to do. | |
641 */ | |
642 NONE | |
643 } | |
OLD | NEW |