| 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.model; | 5 library analyzer.src.task.model; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/engine.dart'; | 7 import 'package:analyzer/src/generated/engine.dart'; |
| 8 import 'package:analyzer/src/task/inputs.dart'; | 8 import 'package:analyzer/src/task/inputs.dart'; |
| 9 import 'package:analyzer/task/model.dart'; | 9 import 'package:analyzer/task/model.dart'; |
| 10 | 10 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 @override | 119 @override |
| 120 final CreateTaskInputs createTaskInputs; | 120 final CreateTaskInputs createTaskInputs; |
| 121 | 121 |
| 122 /** | 122 /** |
| 123 * A list of the analysis results that will be computed by the described task. | 123 * A list of the analysis results that will be computed by the described task. |
| 124 */ | 124 */ |
| 125 @override | 125 @override |
| 126 final List<ResultDescriptor> results; | 126 final List<ResultDescriptor> results; |
| 127 | 127 |
| 128 /** | 128 /** |
| 129 * The function used to determine whether the described task is appropriate | 129 * The function used to determine whether the described task is suitable for |
| 130 * for a given target. | 130 * a given target. |
| 131 */ | 131 */ |
| 132 final IsAppropriateFor _isAppropriateFor; | 132 final SuitabilityFor _suitabilityFor; |
| 133 | 133 |
| 134 /** | 134 /** |
| 135 * Initialize a newly created task descriptor to have the given [name] and to | 135 * Initialize a newly created task descriptor to have the given [name] and to |
| 136 * describe a task that takes the inputs built using the given [inputBuilder], | 136 * describe a task that takes the inputs built using the given [inputBuilder], |
| 137 * and produces the given [results]. The [buildTask] function will be used to | 137 * and produces the given [results]. The [buildTask] function will be used to |
| 138 * create the instance of [AnalysisTask] being described. If provided, the | 138 * create the instance of [AnalysisTask] being described. If provided, the |
| 139 * [isAppropriateFor] function will be used to determine whether the task can | 139 * [isAppropriateFor] function will be used to determine whether the task can |
| 140 * be used on a specific target. | 140 * be used on a specific target. |
| 141 */ | 141 */ |
| 142 TaskDescriptorImpl( | 142 TaskDescriptorImpl( |
| 143 this.name, this.buildTask, this.createTaskInputs, this.results, | 143 this.name, this.buildTask, this.createTaskInputs, this.results, |
| 144 {IsAppropriateFor isAppropriateFor}) | 144 {SuitabilityFor suitabilityFor}) |
| 145 : _isAppropriateFor = isAppropriateFor ?? _alwaysTrue; | 145 : _suitabilityFor = suitabilityFor ?? _defaultSuitability; |
| 146 | 146 |
| 147 @override | 147 @override |
| 148 AnalysisTask createTask(AnalysisContext context, AnalysisTarget target, | 148 AnalysisTask createTask(AnalysisContext context, AnalysisTarget target, |
| 149 Map<String, dynamic> inputs) { | 149 Map<String, dynamic> inputs) { |
| 150 AnalysisTask task = buildTask(context, target); | 150 AnalysisTask task = buildTask(context, target); |
| 151 task.inputs = inputs; | 151 task.inputs = inputs; |
| 152 return task; | 152 return task; |
| 153 } | 153 } |
| 154 | 154 |
| 155 @override | 155 @override |
| 156 bool isAppropriateFor(AnalysisTarget target) => _isAppropriateFor(target); | 156 TaskSuitability suitabilityFor(AnalysisTarget target) => |
| 157 _suitabilityFor(target); |
| 157 | 158 |
| 158 @override | 159 @override |
| 159 String toString() => name; | 160 String toString() => name; |
| 160 | 161 |
| 161 /** | 162 /** |
| 162 * The function that will be used to determine whether a task can be applied | 163 * The function that will be used to determine the suitability of a task if no |
| 163 * to a given target if no other function is provided. | 164 * other function is provided. |
| 164 */ | 165 */ |
| 165 static bool _alwaysTrue(AnalysisTarget target) => true; | 166 static TaskSuitability _defaultSuitability(AnalysisTarget target) => |
| 167 TaskSuitability.LOWEST; |
| 166 } | 168 } |
| OLD | NEW |