Chromium Code Reviews| 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> toList(MapTaskInput mapper) { | |
| 33 return new ListToListTaskInput(this, mapper); | |
| 34 } | |
| 35 | |
| 36 @override | |
| 37 TaskInput<Map<E, Object>> toMap(GenerateTaskInputs mapper) { | |
|
Brian Wilkerson
2015/03/24 15:07:10
The overridden method has a parameter type of MapT
scheglov
2015/03/24 17:16:39
Done.
| |
| 38 return new ListToMapTaskInput(this, mapper); | |
| 39 } | |
| 40 | |
| 41 @override | |
| 42 TaskInput<Map> toMapOf(ResultDescriptor valueResult) { | |
| 43 return toMap(valueResult.of); | |
| 44 } | |
| 45 } | |
| 46 | |
| 47 /** | |
| 19 * An input to an [AnalysisTask] that is computed by the following steps. First | 48 * 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 | 49 * 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 | 50 * 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, | 51 * 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. | 52 * and the list of the analysis results is used as the input to the task. |
| 24 */ | 53 */ |
| 25 class ListToListTaskInput<B, E> | 54 class ListToListTaskInput<B, E> |
| 26 extends _ListToCollectionTaskInput<B, E, List<E>> { | 55 extends _ListToCollectionTaskInput<B, E, List<E>> { |
| 27 /** | 56 /** |
| 28 * Initialize a result accessor to use the given [baseAccessor] to access a | 57 * 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; | 507 return false; |
| 479 } | 508 } |
| 480 _baseListElement = _baseList[_baseListIndex]; | 509 _baseListElement = _baseList[_baseListIndex]; |
| 481 currentBuilder = input.generateTaskInputs(_baseListElement).createBuilder(); | 510 currentBuilder = input.generateTaskInputs(_baseListElement).createBuilder(); |
| 482 return currentBuilder.moveNext(); | 511 return currentBuilder.moveNext(); |
| 483 } | 512 } |
| 484 | 513 |
| 485 void _addResultElement(B baseElement, E resultElement); | 514 void _addResultElement(B baseElement, E resultElement); |
| 486 void _initResultValue(); | 515 void _initResultValue(); |
| 487 } | 516 } |
| OLD | NEW |