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.task.model; | 5 library analyzer.task.model; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; | 9 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; |
10 import 'package:analyzer/src/generated/java_engine.dart'; | 10 import 'package:analyzer/src/generated/java_engine.dart'; |
(...skipping 16 matching lines...) Expand all Loading... | |
27 typedef Map<String, TaskInput> CreateTaskInputs(AnalysisTarget target); | 27 typedef Map<String, TaskInput> CreateTaskInputs(AnalysisTarget target); |
28 | 28 |
29 /** | 29 /** |
30 * A function that converts an object of the type [B] into a [TaskInput]. | 30 * A function that converts an object of the type [B] into a [TaskInput]. |
31 * This is used, for example, by a [ListTaskInput] to create task inputs | 31 * This is used, for example, by a [ListTaskInput] to create task inputs |
32 * for each value in a list of values. | 32 * for each value in a list of values. |
33 */ | 33 */ |
34 typedef TaskInput<E> UnaryFunction<B, E>(B object); | 34 typedef TaskInput<E> UnaryFunction<B, E>(B object); |
35 | 35 |
36 /** | 36 /** |
37 * TODO | |
Brian Wilkerson
2015/04/01 22:13:08
Did you intend to leave this TODO?
| |
38 */ | |
39 typedef TaskInput<E> BinaryFunction<K, V, E>(K key, V value); | |
40 | |
41 /** | |
37 * An [AnalysisTarget] wrapper for an [AnalysisContext]. | 42 * An [AnalysisTarget] wrapper for an [AnalysisContext]. |
38 */ | 43 */ |
39 class AnalysisContextTarget implements AnalysisTarget { | 44 class AnalysisContextTarget implements AnalysisTarget { |
40 static final AnalysisContextTarget request = new AnalysisContextTarget(null); | 45 static final AnalysisContextTarget request = new AnalysisContextTarget(null); |
41 | 46 |
42 final AnalysisContext context; | 47 final AnalysisContext context; |
43 | 48 |
44 AnalysisContextTarget(this.context); | 49 AnalysisContextTarget(this.context); |
45 | 50 |
46 @override | 51 @override |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 * Return a task input that can be used to compute a list whose elements are | 290 * Return a task input that can be used to compute a list whose elements are |
286 * [valueResult]'s associated with those elements. | 291 * [valueResult]'s associated with those elements. |
287 */ | 292 */ |
288 ListTaskInput /*<V>*/ toListOf(ResultDescriptor /*<V>*/ valueResult); | 293 ListTaskInput /*<V>*/ toListOf(ResultDescriptor /*<V>*/ valueResult); |
289 | 294 |
290 /** | 295 /** |
291 * Return a task input that can be used to compute a map whose keys are the | 296 * Return a task input that can be used to compute a map whose keys are the |
292 * elements of this input and whose values are the result of passing the | 297 * elements of this input and whose values are the result of passing the |
293 * corresponding key to the [mapper] function. | 298 * corresponding key to the [mapper] function. |
294 */ | 299 */ |
295 TaskInput<Map<E, dynamic /*V*/ >> toMap( | 300 MapTaskInput<E, dynamic /*V*/ > toMap( |
296 UnaryFunction<E, dynamic /*<V>*/ > mapper); | 301 UnaryFunction<E, dynamic /*<V>*/ > mapper); |
297 | 302 |
298 /** | 303 /** |
299 * Return a task input that can be used to compute a map whose keys are the | 304 * Return a task input that can be used to compute a map whose keys are the |
300 * elements of this input and whose values are the [valueResult]'s associated | 305 * elements of this input and whose values are the [valueResult]'s associated |
301 * with those elements. | 306 * with those elements. |
302 */ | 307 */ |
303 TaskInput<Map<AnalysisTarget, dynamic /*V*/ >> toMapOf( | 308 MapTaskInput<AnalysisTarget, dynamic /*V*/ > toMapOf( |
304 ResultDescriptor /*<V>*/ valueResult); | 309 ResultDescriptor /*<V>*/ valueResult); |
305 } | 310 } |
306 | 311 |
307 /** | 312 /** |
313 * A description of an input with a [Map] based values. TODO | |
314 * | |
315 * Clients are not expected to subtype this class. | |
316 */ | |
317 abstract class MapTaskInput<K, V> extends TaskInput<Map<K, V>> { | |
318 /** | |
319 * [V] must be a [List]. | |
320 * Return a task input that can be used to compute a list whose elements are | |
321 * the result of passing keys [K] and the corresponding elements of [V] to | |
322 * the [mapper] function. | |
323 */ | |
324 TaskInput<List /*<E>*/ > toFlattenList( | |
325 BinaryFunction<K, dynamic /*element of V*/, dynamic /*<E>*/ > mapper); | |
326 } | |
327 | |
328 /** | |
308 * A description of an analysis result that can be computed by an [AnalysisTask] . | 329 * A description of an analysis result that can be computed by an [AnalysisTask] . |
309 * | 330 * |
310 * Clients are not expected to subtype this class. | 331 * Clients are not expected to subtype this class. |
311 */ | 332 */ |
312 abstract class ResultDescriptor<V> { | 333 abstract class ResultDescriptor<V> { |
313 /** | 334 /** |
314 * Initialize a newly created analysis result to have the given [name]. If a | 335 * Initialize a newly created analysis result to have the given [name]. If a |
315 * composite result is specified, then this result will contribute to it. | 336 * composite result is specified, then this result will contribute to it. |
316 */ | 337 */ |
317 factory ResultDescriptor(String name, V defaultValue, | 338 factory ResultDescriptor(String name, V defaultValue, |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
435 * be computed, or `false` if the inputs have been computed. | 456 * be computed, or `false` if the inputs have been computed. |
436 * | 457 * |
437 * It is safe to invoke [moveNext] after it has returned `false`. In this case | 458 * It is safe to invoke [moveNext] after it has returned `false`. In this case |
438 * [moveNext] has no effect and will again return `false`. | 459 * [moveNext] has no effect and will again return `false`. |
439 * | 460 * |
440 * Throws a [StateError] if the value of the current result has not been | 461 * Throws a [StateError] if the value of the current result has not been |
441 * provided using [currentValue]. | 462 * provided using [currentValue]. |
442 */ | 463 */ |
443 bool moveNext(); | 464 bool moveNext(); |
444 } | 465 } |
OLD | NEW |