Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1194)

Unified Diff: pkg/analyzer/lib/src/task/manager.dart

Issue 1645643002: Replace isAppropriateFor with suitabilityFor and start using it (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/task/html.dart ('k') | pkg/analyzer/lib/src/task/model.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
}
« no previous file with comments | « pkg/analyzer/lib/src/task/html.dart ('k') | pkg/analyzer/lib/src/task/model.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698