| 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.inputs; | 5 library analyzer.src.task.inputs; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/task/model.dart'; | 9 import 'package:analyzer/task/model.dart'; |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * A function that converts an object of the type [B] into a [TaskInput]. | 12 * A function that converts an object of the type [B] into a [TaskInput]. |
| 13 * This is used, for example, by a [ListToListTaskInput] to create task inputs | 13 * This is used, for example, by a [ListToListTaskInput] to create task inputs |
| 14 * for each value in a list of values. | 14 * for each value in a list of values. |
| 15 */ | 15 */ |
| 16 typedef TaskInput<E> GenerateTaskInputs<B, E>(B object); | 16 typedef TaskInput<E> GenerateTaskInputs<B, E>(B object); |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * An input to an [AnalysisTask] that is computed by accessing a single result |
| 20 * defined on a single target. |
| 21 */ |
| 22 class ListTaskInputImpl<E> extends SimpleTaskInput<List<E>> |
| 23 implements ListTaskInput<E> { |
| 24 /** |
| 25 * Initialize a newly created task input that computes the input by accessing |
| 26 * the given [result] associated with the given [target]. |
| 27 */ |
| 28 ListTaskInputImpl(AnalysisTarget target, ResultDescriptor<List<E>> result) |
| 29 : super(target, result); |
| 30 |
| 31 @override |
| 32 TaskInput<List /*<V>*/ > toList(UnaryFunction<E, Object /*<V>*/ > mapper) { |
| 33 return new ListToListTaskInput<E, Object /*V*/ >(this, mapper); |
| 34 } |
| 35 |
| 36 @override |
| 37 TaskInput<List /*<V>*/ > toListOf(ResultDescriptor /*<V>*/ valueResult) { |
| 38 return (this as ListTaskInputImpl<AnalysisTarget>).toList(valueResult.of); |
| 39 } |
| 40 |
| 41 @override |
| 42 TaskInput<Map<E, Object /*V*/ >> toMap( |
| 43 UnaryFunction<E, Object /*<V>*/ > mapper) { |
| 44 return new ListToMapTaskInput<E, Object /*V*/ >(this, mapper); |
| 45 } |
| 46 |
| 47 @override |
| 48 TaskInput<Map<AnalysisTarget, Object /*V*/ >> toMapOf( |
| 49 ResultDescriptor /*<V>*/ valueResult) { |
| 50 return (this as ListTaskInputImpl<AnalysisTarget>).toMap(valueResult.of); |
| 51 } |
| 52 } |
| 53 |
| 54 /** |
| 19 * An input to an [AnalysisTask] that is computed by the following steps. First | 55 * An input to an [AnalysisTask] that is computed by the following steps. First |
| 20 * another (base) task input is used to compute a [List]-valued result. An input | 56 * another (base) task input is used to compute a [List]-valued result. An input |
| 21 * generator function is then used to map each element of that list to a task | 57 * generator function is then used to map each element of that list to a task |
| 22 * input. Finally, each of the task inputs are used to access analysis results, | 58 * input. Finally, each of the task inputs are used to access analysis results, |
| 23 * and the list of the analysis results is used as the input to the task. | 59 * and the list of the analysis results is used as the input to the task. |
| 24 */ | 60 */ |
| 25 class ListToListTaskInput<B, E> | 61 class ListToListTaskInput<B, E> |
| 26 extends _ListToCollectionTaskInput<B, E, List<E>> { | 62 extends _ListToCollectionTaskInput<B, E, List<E>> { |
| 27 /** | 63 /** |
| 28 * Initialize a result accessor to use the given [baseAccessor] to access a | 64 * Initialize a result accessor to use the given [baseAccessor] to access a |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 return false; | 514 return false; |
| 479 } | 515 } |
| 480 _baseListElement = _baseList[_baseListIndex]; | 516 _baseListElement = _baseList[_baseListIndex]; |
| 481 currentBuilder = input.generateTaskInputs(_baseListElement).createBuilder(); | 517 currentBuilder = input.generateTaskInputs(_baseListElement).createBuilder(); |
| 482 return currentBuilder.moveNext(); | 518 return currentBuilder.moveNext(); |
| 483 } | 519 } |
| 484 | 520 |
| 485 void _addResultElement(B baseElement, E resultElement); | 521 void _addResultElement(B baseElement, E resultElement); |
| 486 void _initResultValue(); | 522 void _initResultValue(); |
| 487 } | 523 } |
| OLD | NEW |