| Index: pkg/analyzer/lib/src/task/manager.dart
|
| diff --git a/pkg/analyzer/lib/src/task/manager.dart b/pkg/analyzer/lib/src/task/manager.dart
|
| index eebc08491fdea0fa1ef13f0b43babc5de5cf7d7a..c8252fa44ebbcb5aaba056e5e2ff9c1e55ed00fa 100644
|
| --- a/pkg/analyzer/lib/src/task/manager.dart
|
| +++ b/pkg/analyzer/lib/src/task/manager.dart
|
| @@ -83,7 +83,7 @@ class TaskManager {
|
| throw new AnalysisException(
|
| 'No tasks registered to compute $result for $target');
|
| }
|
| - return _findBestTask(descriptors);
|
| + return _findBestTask(descriptors, target);
|
| }
|
|
|
| /**
|
| @@ -104,11 +104,20 @@ class TaskManager {
|
|
|
| /**
|
| * Given a list of task [descriptors] that can be used to compute some
|
| - * unspecified result, return the descriptor that will compute the result with
|
| - * the least amount of work.
|
| + * unspecified result for the given [target], return the descriptor that
|
| + * should be used to compute the result.
|
| */
|
| - TaskDescriptor _findBestTask(List<TaskDescriptor> descriptors) {
|
| - // TODO(brianwilkerson) Improve this implementation.
|
| - return descriptors[0];
|
| + TaskDescriptor _findBestTask(
|
| + List<TaskDescriptor> descriptors, AnalysisTarget target) {
|
| + TaskDescriptor best = null;
|
| + for (TaskDescriptor descriptor in descriptors) {
|
| + TaskSuitability suitability = descriptor.suitabilityFor(target);
|
| + if (suitability == TaskSuitability.HIGHEST) {
|
| + return descriptor;
|
| + } else if (best == null && suitability == TaskSuitability.LOWEST) {
|
| + best = descriptor;
|
| + }
|
| + }
|
| + return best;
|
| }
|
| }
|
|
|