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

Side by Side Diff: pkg/analyzer/lib/src/task/model.dart

Issue 812733004: Initial task support (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library analyzer.src.task.model;
6
7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask;
8 import 'package:analyzer/src/task/inputs.dart';
9 import 'package:analyzer/task/model.dart';
10
11 /**
12 * A concrete implementation of a [ContributionPoint].
13 */
14 class ContributionPointImpl<V> extends ResultDescriptorImpl<V> implements
15 ContributionPoint<V> {
16 /**
17 * The results that contribute to this result.
18 */
19 final List<ResultDescriptor> contributors = <ResultDescriptor>[];
20
21 /**
22 * Initialize a newly created contribution point to have the given [name].
23 */
24 ContributionPointImpl(String name) : super(name);
25
26 /**
27 * Record that the given analysis [result] contibutes to this result.
28 */
29 void recordContributor(ResultDescriptor<V> result) {
30 contributors.add(result);
31 }
32 }
33
34 /**
35 * A concrete implementation of a [ResultDescriptor].
36 */
37 class ResultDescriptorImpl<V> implements ResultDescriptor<V> {
38 /**
39 * The name of the result, used for debugging.
40 */
41 final String name;
42
43 /**
44 * Initialize a newly created analysis result to have the given [name]. If a
45 * contribution point is specified, then this result will contribute to it.
46 */
47 ResultDescriptorImpl(this.name, {ContributionPoint contributesTo}) {
48 if (contributesTo is ContributionPointImpl) {
49 contributesTo.recordContributor(this);
50 }
51 }
52
53 @override
54 TaskInput<V> inputFor(AnalysisTarget target) =>
55 new SimpleTaskInput<V>(target, this);
56
57 @override
58 String toString() => name;
59 }
60
61 /**
62 * A concrete implementation of a [TaskDescriptor].
63 */
64 class TaskDescriptorImpl implements TaskDescriptor {
65 /**
66 * The name of the described task, used for debugging.
67 */
68 final String name;
69
70 /**
71 * The function used to build the analysis task.
72 */
73 final BuildTask buildTask;
74
75 /**
76 * The function used to build the inputs to the task.
77 */
78 @override
79 final CreateTaskInputs createTaskInputs;
80
81 /**
82 * A list of the analysis results that will be computed by the described task.
83 */
84 @override
85 final List<ResultDescriptor> results;
86
87 /**
88 * Initialize a newly created task descriptor to have the given [name] and to
89 * describe a task that takes the inputs built using the given [createTaskInpu ts],
90 * and produces the given [results]. The [buildTask] will be used to create
91 * the instance of [AnalysisTask] thusly described.
92 */
93 TaskDescriptorImpl(this.name, this.buildTask, this.createTaskInputs,
94 this.results);
95
96 @override
97 AnalysisTask createTask(AnalysisContext context, AnalysisTarget target,
98 Map<String, dynamic> inputs) {
99 AnalysisTask task = buildTask(context, target);
100 task.inputs = inputs;
101 return task;
102 }
103
104 @override
105 String toString() => name;
106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698