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

Side by Side Diff: pkg/analyzer/lib/task/model.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, 10 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 | « pkg/analyzer/lib/src/task/yaml.dart ('k') | pkg/analyzer/lib/task/yaml.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.task.model; 5 library analyzer.task.model;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:developer'; 8 import 'dart:developer';
9 9
10 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; 10 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask;
(...skipping 19 matching lines...) Expand all
30 /** 30 /**
31 * A function that takes the target for which a task will produce results and 31 * A function that takes the target for which a task will produce results and
32 * returns a map from input names to descriptions of the analysis results needed 32 * returns a map from input names to descriptions of the analysis results needed
33 * by the task in order for the task to be performed. Such functions are passed 33 * by the task in order for the task to be performed. Such functions are passed
34 * to a [TaskDescriptor] to be used to determine the inputs needed by the task. 34 * to a [TaskDescriptor] to be used to determine the inputs needed by the task.
35 */ 35 */
36 typedef Map<String, TaskInput> CreateTaskInputs(AnalysisTarget target); 36 typedef Map<String, TaskInput> CreateTaskInputs(AnalysisTarget target);
37 37
38 /** 38 /**
39 * A function that takes the target for which a task will produce results and 39 * A function that takes the target for which a task will produce results and
40 * returns `true` if the task is appropriate for the target. Such functions are 40 * returns an indication of how suitable the task is for the target. Such
41 * passed to a [TaskDescriptor] to be used to determine the inputs needed by the 41 * functions are passed to a [TaskDescriptor] to be used to determine their
42 * task. 42 * suitability for computing results.
43 */ 43 */
44 typedef bool IsAppropriateFor(AnalysisTarget target); 44 typedef TaskSuitability SuitabilityFor(AnalysisTarget target);
45 45
46 /** 46 /**
47 * A function that converts an object of the type [B] into a [TaskInput]. 47 * A function that converts an object of the type [B] into a [TaskInput].
48 * This is used, for example, by a [ListTaskInput] to create task inputs 48 * This is used, for example, by a [ListTaskInput] to create task inputs
49 * for each value in a list of values. 49 * for each value in a list of values.
50 */ 50 */
51 typedef TaskInput<E> UnaryFunction<B, E>(B object); 51 typedef TaskInput<E> UnaryFunction<B, E>(B object);
52 52
53 /** 53 /**
54 * An [AnalysisTarget] wrapper for an [AnalysisContext]. 54 * An [AnalysisTarget] wrapper for an [AnalysisContext].
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 /** 530 /**
531 * Initialize a newly created task descriptor to have the given [name] and to 531 * Initialize a newly created task descriptor to have the given [name] and to
532 * describe a task that takes the inputs built using the given [inputBuilder], 532 * describe a task that takes the inputs built using the given [inputBuilder],
533 * and produces the given [results]. The [buildTask] function will be used to 533 * and produces the given [results]. The [buildTask] function will be used to
534 * create the instance of [AnalysisTask] being described. If provided, the 534 * create the instance of [AnalysisTask] being described. If provided, the
535 * [isAppropriateFor] function will be used to determine whether the task can 535 * [isAppropriateFor] function will be used to determine whether the task can
536 * be used on a specific target. 536 * be used on a specific target.
537 */ 537 */
538 factory TaskDescriptor(String name, BuildTask buildTask, 538 factory TaskDescriptor(String name, BuildTask buildTask,
539 CreateTaskInputs inputBuilder, List<ResultDescriptor> results, 539 CreateTaskInputs inputBuilder, List<ResultDescriptor> results,
540 {IsAppropriateFor isAppropriateFor}) = TaskDescriptorImpl; 540 {SuitabilityFor suitabilityFor}) = TaskDescriptorImpl;
541 541
542 /** 542 /**
543 * Return the builder used to build the inputs to the task. 543 * Return the builder used to build the inputs to the task.
544 */ 544 */
545 CreateTaskInputs get createTaskInputs; 545 CreateTaskInputs get createTaskInputs;
546 546
547 /** 547 /**
548 * Return the name of the task being described. 548 * Return the name of the task being described.
549 */ 549 */
550 String get name; 550 String get name;
551 551
552 /** 552 /**
553 * Return a list of the analysis results that will be computed by this task. 553 * Return a list of the analysis results that will be computed by this task.
554 */ 554 */
555 List<ResultDescriptor> get results; 555 List<ResultDescriptor> get results;
556 556
557 /** 557 /**
558 * Create and return a task that is described by this descriptor that can be 558 * Create and return a task that is described by this descriptor that can be
559 * used to compute results based on the given [inputs]. 559 * used to compute results based on the given [inputs].
560 */ 560 */
561 AnalysisTask createTask(AnalysisContext context, AnalysisTarget target, 561 AnalysisTask createTask(AnalysisContext context, AnalysisTarget target,
562 Map<String, dynamic> inputs); 562 Map<String, dynamic> inputs);
563 563
564 /** 564 /**
565 * Return `true` if this task is appropriate for the given [target]. 565 * Return an indication of how suitable this task is for the given [target].
566 */ 566 */
567 bool isAppropriateFor(AnalysisTarget target); 567 TaskSuitability suitabilityFor(AnalysisTarget target);
568 } 568 }
569 569
570 /** 570 /**
571 * A description of an input to an [AnalysisTask] that can be used to compute 571 * A description of an input to an [AnalysisTask] that can be used to compute
572 * that input. 572 * that input.
573 * 573 *
574 * Clients may not extend, implement or mix-in this class. 574 * Clients may not extend, implement or mix-in this class.
575 */ 575 */
576 abstract class TaskInput<V> { 576 abstract class TaskInput<V> {
577 /** 577 /**
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 * It is safe to invoke [moveNext] after it has returned `false`. In this case 656 * It is safe to invoke [moveNext] after it has returned `false`. In this case
657 * [moveNext] has no effect and will again return `false`. 657 * [moveNext] has no effect and will again return `false`.
658 * 658 *
659 * Throws a [StateError] if the value of the current result has not been 659 * Throws a [StateError] if the value of the current result has not been
660 * provided using [currentValue]. 660 * provided using [currentValue].
661 */ 661 */
662 bool moveNext(); 662 bool moveNext();
663 } 663 }
664 664
665 /** 665 /**
666 * An indication of how suitable a task is for a given target.
667 */
668 enum TaskSuitability { NONE, LOWEST, HIGHEST }
669
670 /**
666 * [WorkManager]s are used to drive analysis. 671 * [WorkManager]s are used to drive analysis.
667 * 672 *
668 * They know specific of the targets and results they care about, 673 * They know specific of the targets and results they care about,
669 * so they can request analysis results in optimal order. 674 * so they can request analysis results in optimal order.
670 * 675 *
671 * Clients may implement this class when implementing plugins. 676 * Clients may implement this class when implementing plugins.
672 */ 677 */
673 abstract class WorkManager { 678 abstract class WorkManager {
674 /** 679 /**
675 * Notifies the manager about changes in the explicit source list. 680 * Notifies the manager about changes in the explicit source list.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 /** 753 /**
749 * A work should be done, but without any special urgency. 754 * A work should be done, but without any special urgency.
750 */ 755 */
751 NORMAL, 756 NORMAL,
752 757
753 /** 758 /**
754 * Nothing to do. 759 * Nothing to do.
755 */ 760 */
756 NONE 761 NONE
757 } 762 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/yaml.dart ('k') | pkg/analyzer/lib/task/yaml.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698