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

Side by Side Diff: packages/analyzer/lib/src/task/manager.dart

Issue 2990843002: Removed fixed dependencies (Closed)
Patch Set: Created 3 years, 4 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 unified diff | Download patch
« no previous file with comments | « packages/analyzer/lib/src/task/inputs.dart ('k') | packages/analyzer/lib/src/task/model.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.manager; 5 library analyzer.src.task.manager;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/generated/java_engine.dart'; 9 import 'package:analyzer/exception/exception.dart';
10 import 'package:analyzer/task/model.dart'; 10 import 'package:analyzer/task/model.dart';
11 11
12 /** 12 /**
13 * An object that manages the information about the tasks that have been 13 * An object that manages the information about the tasks that have been
14 * defined. 14 * defined.
15 */ 15 */
16 class TaskManager { 16 class TaskManager {
17 /** 17 /**
18 * A table mapping [ResultDescriptor]s to a list of [TaskDescriptor]s 18 * A table mapping [ResultDescriptor]s to a list of [TaskDescriptor]s
19 * for the tasks that can be used to compute the result. 19 * for the tasks that can be used to compute the result.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 /** 77 /**
78 * Find a task that will compute the given [result] for the given [target]. 78 * Find a task that will compute the given [result] for the given [target].
79 */ 79 */
80 TaskDescriptor findTask(AnalysisTarget target, ResultDescriptor result) { 80 TaskDescriptor findTask(AnalysisTarget target, ResultDescriptor result) {
81 List<TaskDescriptor> descriptors = taskMap[result]; 81 List<TaskDescriptor> descriptors = taskMap[result];
82 if (descriptors == null) { 82 if (descriptors == null) {
83 throw new AnalysisException( 83 throw new AnalysisException(
84 'No tasks registered to compute $result for $target'); 84 'No tasks registered to compute $result for $target');
85 } 85 }
86 return _findBestTask(descriptors); 86 return _findBestTask(descriptors, target);
87 } 87 }
88 88
89 /** 89 /**
90 * Remove the given [result] from the list of results that are to be computed 90 * Remove the given [result] from the list of results that are to be computed
91 * for all sources within an analysis root. 91 * for all sources within an analysis root.
92 */ 92 */
93 void removeGeneralResult(ResultDescriptor result) { 93 void removeGeneralResult(ResultDescriptor result) {
94 generalResults.remove(result); 94 generalResults.remove(result);
95 } 95 }
96 96
97 /** 97 /**
98 * Remove the given [result] from the list of results that are to be computed 98 * Remove the given [result] from the list of results that are to be computed
99 * for priority sources. 99 * for priority sources.
100 */ 100 */
101 void removePriorityResult(ResultDescriptor result) { 101 void removePriorityResult(ResultDescriptor result) {
102 priorityResults.remove(result); 102 priorityResults.remove(result);
103 } 103 }
104 104
105 /** 105 /**
106 * Given a list of task [descriptors] that can be used to compute some 106 * Given a list of task [descriptors] that can be used to compute some
107 * unspecified result, return the descriptor that will compute the result with 107 * unspecified result for the given [target], return the descriptor that
108 * the least amount of work. 108 * should be used to compute the result.
109 */ 109 */
110 TaskDescriptor _findBestTask(List<TaskDescriptor> descriptors) { 110 TaskDescriptor _findBestTask(
111 // TODO(brianwilkerson) Improve this implementation. 111 List<TaskDescriptor> descriptors, AnalysisTarget target) {
112 return descriptors[0]; 112 TaskDescriptor best = null;
113 for (TaskDescriptor descriptor in descriptors) {
114 TaskSuitability suitability = descriptor.suitabilityFor(target);
115 if (suitability == TaskSuitability.HIGHEST) {
116 return descriptor;
117 } else if (best == null && suitability == TaskSuitability.LOWEST) {
118 best = descriptor;
119 }
120 }
121 return best;
113 } 122 }
114 } 123 }
OLDNEW
« no previous file with comments | « packages/analyzer/lib/src/task/inputs.dart ('k') | packages/analyzer/lib/src/task/model.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698