| Index: packages/analyzer/lib/src/task/model.dart
|
| diff --git a/packages/analyzer/lib/src/task/model.dart b/packages/analyzer/lib/src/task/model.dart
|
| index 50c05eed6ce1528fbda9f8552c282942cb51c426..47de4b3143399d07dd27a609fcfcd161d4d3b6a6 100644
|
| --- a/packages/analyzer/lib/src/task/model.dart
|
| +++ b/packages/analyzer/lib/src/task/model.dart
|
| @@ -4,14 +4,14 @@
|
|
|
| library analyzer.src.task.model;
|
|
|
| -import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask;
|
| +import 'package:analyzer/src/generated/engine.dart';
|
| import 'package:analyzer/src/task/inputs.dart';
|
| import 'package:analyzer/task/model.dart';
|
|
|
| /**
|
| * The default [ResultCachingPolicy], results are never flushed.
|
| */
|
| -const ResultCachingPolicy DEFAULT_CACHING_POLICY =
|
| +const ResultCachingPolicy<Object> DEFAULT_CACHING_POLICY =
|
| const SimpleResultCachingPolicy(-1, -1);
|
|
|
| /**
|
| @@ -125,14 +125,24 @@ class TaskDescriptorImpl implements TaskDescriptor {
|
| @override
|
| final List<ResultDescriptor> results;
|
|
|
| + /**
|
| + * The function used to determine whether the described task is suitable for
|
| + * a given target.
|
| + */
|
| + final SuitabilityFor _suitabilityFor;
|
| +
|
| /**
|
| * Initialize a newly created task descriptor to have the given [name] and to
|
| - * describe a task that takes the inputs built using the given [createTaskInputs],
|
| - * and produces the given [results]. The [buildTask] will be used to create
|
| - * the instance of [AnalysisTask] thusly described.
|
| + * describe a task that takes the inputs built using the given [inputBuilder],
|
| + * and produces the given [results]. The [buildTask] function will be used to
|
| + * create the instance of [AnalysisTask] being described. If provided, the
|
| + * [isAppropriateFor] function will be used to determine whether the task can
|
| + * be used on a specific target.
|
| */
|
| TaskDescriptorImpl(
|
| - this.name, this.buildTask, this.createTaskInputs, this.results);
|
| + this.name, this.buildTask, this.createTaskInputs, this.results,
|
| + {SuitabilityFor suitabilityFor})
|
| + : _suitabilityFor = suitabilityFor ?? _defaultSuitability;
|
|
|
| @override
|
| AnalysisTask createTask(AnalysisContext context, AnalysisTarget target,
|
| @@ -142,6 +152,17 @@ class TaskDescriptorImpl implements TaskDescriptor {
|
| return task;
|
| }
|
|
|
| + @override
|
| + TaskSuitability suitabilityFor(AnalysisTarget target) =>
|
| + _suitabilityFor(target);
|
| +
|
| @override
|
| String toString() => name;
|
| +
|
| + /**
|
| + * The function that will be used to determine the suitability of a task if no
|
| + * other function is provided.
|
| + */
|
| + static TaskSuitability _defaultSuitability(AnalysisTarget target) =>
|
| + TaskSuitability.LOWEST;
|
| }
|
|
|