| 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 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 */ | 82 */ |
| 83 ListTaskInputImpl(AnalysisTarget target, ResultDescriptor<List<E>> result) | 83 ListTaskInputImpl(AnalysisTarget target, ResultDescriptor<List<E>> result) |
| 84 : super._unflushable(target, result); | 84 : super._unflushable(target, result); |
| 85 } | 85 } |
| 86 | 86 |
| 87 /** | 87 /** |
| 88 * A mixin-ready implementation of [ListTaskInput]. | 88 * A mixin-ready implementation of [ListTaskInput]. |
| 89 */ | 89 */ |
| 90 abstract class ListTaskInputMixin<E> implements ListTaskInput<E> { | 90 abstract class ListTaskInputMixin<E> implements ListTaskInput<E> { |
| 91 @override | 91 @override |
| 92 ListTaskInput /*<V>*/ toFlattenListOf /*<V>*/ ( | 92 ListTaskInput/*<V>*/ toFlattenListOf/*<V>*/( |
| 93 ListResultDescriptor /*<V>*/ subListResult) { | 93 ListResultDescriptor/*<V>*/ subListResult) { |
| 94 return new ListToFlattenListTaskInput<E, dynamic /*=V*/ >( | 94 return new ListToFlattenListTaskInput<E, dynamic/*=V*/ >( |
| 95 this, subListResult.of as dynamic); | 95 this, subListResult.of as dynamic); |
| 96 } | 96 } |
| 97 | 97 |
| 98 ListTaskInput /*<V>*/ toList /*<V>*/ ( | 98 ListTaskInput/*<V>*/ toList/*<V>*/(UnaryFunction<E, dynamic/*=V*/ > mapper) { |
| 99 UnaryFunction<E, dynamic /*<=V>*/ > mapper) { | 99 return new ListToListTaskInput<E, dynamic/*=V*/ >(this, mapper); |
| 100 return new ListToListTaskInput<E, dynamic /*=V*/ >(this, mapper); | |
| 101 } | 100 } |
| 102 | 101 |
| 103 ListTaskInput /*<V>*/ toListOf /*<V>*/ ( | 102 ListTaskInput/*<V>*/ toListOf/*<V>*/(ResultDescriptor/*<V>*/ valueResult) { |
| 104 ResultDescriptor /*<V>*/ valueResult) { | |
| 105 return (this as ListTaskInput<AnalysisTarget>).toList(valueResult.of); | 103 return (this as ListTaskInput<AnalysisTarget>).toList(valueResult.of); |
| 106 } | 104 } |
| 107 | 105 |
| 108 MapTaskInput<E, dynamic /*=V*/ > toMap /*<V>*/ ( | 106 MapTaskInput<E, dynamic/*=V*/ > toMap/*<V>*/( |
| 109 UnaryFunction<E, dynamic /*<=V>*/ > mapper) { | 107 UnaryFunction<E, dynamic/*=V*/ > mapper) { |
| 110 return new ListToMapTaskInput<E, dynamic /*=V*/ >(this, mapper); | 108 return new ListToMapTaskInput<E, dynamic/*=V*/ >(this, mapper); |
| 111 } | 109 } |
| 112 | 110 |
| 113 MapTaskInput<AnalysisTarget, dynamic /*=V*/ > toMapOf /*<V>*/ ( | 111 MapTaskInput<AnalysisTarget, dynamic/*=V*/ > toMapOf/*<V>*/( |
| 114 ResultDescriptor /*<V>*/ valueResult) { | 112 ResultDescriptor/*<V>*/ valueResult) { |
| 115 return (this as ListTaskInputImpl<AnalysisTarget>).toMap(valueResult.of); | 113 return (this as ListTaskInputImpl<AnalysisTarget>).toMap(valueResult.of); |
| 116 } | 114 } |
| 117 } | 115 } |
| 118 | 116 |
| 119 /** | 117 /** |
| 120 * An input to an [AnalysisTask] that is computed by the following steps. First | 118 * An input to an [AnalysisTask] that is computed by the following steps. First |
| 121 * another (base) task input is used to compute a [List]-valued result. An input | 119 * another (base) task input is used to compute a [List]-valued result. An input |
| 122 * generator function is then used to map each element of that list to a task | 120 * generator function is then used to map each element of that list to a task |
| 123 * input. Finally, each of the task inputs are used to access analysis results, | 121 * input. Finally, each of the task inputs are used to access analysis results, |
| 124 * and the list of the analysis results is used as the input to the task. | 122 * and the list of the analysis results is used as the input to the task. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 @override | 270 @override |
| 273 void _initResultValue() { | 271 void _initResultValue() { |
| 274 _resultValue = new HashMap<B, E>(); | 272 _resultValue = new HashMap<B, E>(); |
| 275 } | 273 } |
| 276 } | 274 } |
| 277 | 275 |
| 278 /** | 276 /** |
| 279 * A mixin-ready implementation of [MapTaskInput]. | 277 * A mixin-ready implementation of [MapTaskInput]. |
| 280 */ | 278 */ |
| 281 abstract class MapTaskInputMixin<K, V> implements MapTaskInput<K, V> { | 279 abstract class MapTaskInputMixin<K, V> implements MapTaskInput<K, V> { |
| 282 TaskInput<List /*<E>*/ > toFlattenList /*<E>*/ ( | 280 TaskInput<List/*<E>*/ > toFlattenList/*<E>*/( |
| 283 BinaryFunction<K, dynamic /*element of V*/, dynamic /*<=E>*/ > mapper) { | 281 BinaryFunction<K, dynamic /*element of V*/, dynamic/*=E*/ > mapper) { |
| 284 return new MapToFlattenListTaskInput<K, dynamic /*element of V*/, | 282 return new MapToFlattenListTaskInput<K, dynamic /*element of V*/, |
| 285 dynamic /*=E*/ >(this as MapTaskInput<K, List /*<element of V>*/ >, mapp
er); | 283 dynamic/*=E*/ >(this as MapTaskInput<K, List /*element of V*/ >, mapper)
; |
| 286 } | 284 } |
| 287 } | 285 } |
| 288 | 286 |
| 289 /** | 287 /** |
| 290 * A [TaskInput] that is computed by the following steps. | 288 * A [TaskInput] that is computed by the following steps. |
| 291 * | 289 * |
| 292 * First the [base] task input is used to compute a [Map]-valued result. | 290 * First the [base] task input is used to compute a [Map]-valued result. |
| 293 * The values of the [Map] must be [List]s. | 291 * The values of the [Map] must be [List]s. |
| 294 * | 292 * |
| 295 * The given [mapper] is used to transform each key / value pair of the [Map] | 293 * The given [mapper] is used to transform each key / value pair of the [Map] |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 * Initialize a newly created task input that computes the input by accessing | 432 * Initialize a newly created task input that computes the input by accessing |
| 435 * the given [result] associated with the given [target]. | 433 * the given [result] associated with the given [target]. |
| 436 */ | 434 */ |
| 437 ObjectToListTaskInput(this.baseInput, this.mapper); | 435 ObjectToListTaskInput(this.baseInput, this.mapper); |
| 438 | 436 |
| 439 @override | 437 @override |
| 440 TaskInputBuilder<List<E>> createBuilder() => | 438 TaskInputBuilder<List<E>> createBuilder() => |
| 441 new ObjectToListTaskInputBuilder<E>(this); | 439 new ObjectToListTaskInputBuilder<E>(this); |
| 442 | 440 |
| 443 @override | 441 @override |
| 444 ListTaskInput /*<V>*/ toFlattenListOf /*<V>*/ ( | 442 ListTaskInput/*<V>*/ toFlattenListOf/*<V>*/( |
| 445 ListResultDescriptor /*<V>*/ subListResult) { | 443 ListResultDescriptor/*<V>*/ subListResult) { |
| 446 return new ListToFlattenListTaskInput<E, dynamic /*=V*/ >( | 444 return new ListToFlattenListTaskInput<E, dynamic/*=V*/ >( |
| 447 this, subListResult.of as dynamic); | 445 this, subListResult.of as dynamic); |
| 448 } | 446 } |
| 449 | 447 |
| 450 @override | 448 @override |
| 451 ListTaskInput /*<V>*/ toListOf /*<V>*/ ( | 449 ListTaskInput/*<V>*/ toListOf/*<V>*/(ResultDescriptor/*<V>*/ valueResult) { |
| 452 ResultDescriptor /*<V>*/ valueResult) { | 450 return new ListToListTaskInput<E, dynamic/*=V*/ >( |
| 453 return new ListToListTaskInput<E, dynamic /*=V*/ >( | |
| 454 this, valueResult.of as dynamic); | 451 this, valueResult.of as dynamic); |
| 455 } | 452 } |
| 456 | 453 |
| 457 @override | 454 @override |
| 458 MapTaskInput<AnalysisTarget, dynamic /*=V*/ > toMapOf /*<V>*/ ( | 455 MapTaskInput<AnalysisTarget, dynamic/*=V*/ > toMapOf/*<V>*/( |
| 459 ResultDescriptor /*<V>*/ valueResult) { | 456 ResultDescriptor/*<V>*/ valueResult) { |
| 460 return new ListToMapTaskInput<AnalysisTarget, dynamic /*=V*/ >( | 457 return new ListToMapTaskInput<AnalysisTarget, dynamic/*=V*/ >( |
| 461 this as dynamic, valueResult.of); | 458 this as dynamic, valueResult.of); |
| 462 } | 459 } |
| 463 } | 460 } |
| 464 | 461 |
| 465 /** | 462 /** |
| 466 * A [TaskInputBuilder] used to build an input based on a [SimpleTaskInput]. | 463 * A [TaskInputBuilder] used to build an input based on a [SimpleTaskInput]. |
| 467 */ | 464 */ |
| 468 class ObjectToListTaskInputBuilder<E> implements TaskInputBuilder<List<E>> { | 465 class ObjectToListTaskInputBuilder<E> implements TaskInputBuilder<List<E>> { |
| 469 /** | 466 /** |
| 470 * The input being built. | 467 * The input being built. |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 'The value of the current result must be set before moving to the ne
xt result.'); | 686 'The value of the current result must be set before moving to the ne
xt result.'); |
| 690 } | 687 } |
| 691 _state = _AFTER; | 688 _state = _AFTER; |
| 692 return false; | 689 return false; |
| 693 } | 690 } |
| 694 } | 691 } |
| 695 } | 692 } |
| 696 | 693 |
| 697 abstract class TaskInputImpl<V> implements TaskInput<V> { | 694 abstract class TaskInputImpl<V> implements TaskInput<V> { |
| 698 @override | 695 @override |
| 699 ListTaskInput /*<E>*/ mappedToList /*<E>*/ (List /*<E>*/ mapper(V value)) { | 696 ListTaskInput/*<E>*/ mappedToList/*<E>*/(List/*<E>*/ mapper(V value)) { |
| 700 return new ObjectToListTaskInput(this, mapper); | 697 return new ObjectToListTaskInput(this, mapper); |
| 701 } | 698 } |
| 702 } | 699 } |
| 703 | 700 |
| 704 /** | 701 /** |
| 705 * A [TaskInputBuilder] used to build an input based on one or more other task | 702 * A [TaskInputBuilder] used to build an input based on one or more other task |
| 706 * inputs. The task inputs to be built are specified by a table mapping the name | 703 * inputs. The task inputs to be built are specified by a table mapping the name |
| 707 * of the input to the task used to access the input's value. | 704 * of the input to the task used to access the input's value. |
| 708 */ | 705 */ |
| 709 class TopLevelTaskInputBuilder | 706 class TopLevelTaskInputBuilder |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 return false; | 985 return false; |
| 989 } | 986 } |
| 990 _baseListElement = _baseList[_baseListIndex]; | 987 _baseListElement = _baseList[_baseListIndex]; |
| 991 currentBuilder = input.generateTaskInputs(_baseListElement).createBuilder(); | 988 currentBuilder = input.generateTaskInputs(_baseListElement).createBuilder(); |
| 992 return currentBuilder.moveNext(); | 989 return currentBuilder.moveNext(); |
| 993 } | 990 } |
| 994 | 991 |
| 995 void _addResultElement(B baseElement, E resultElement); | 992 void _addResultElement(B baseElement, E resultElement); |
| 996 void _initResultValue(); | 993 void _initResultValue(); |
| 997 } | 994 } |
| OLD | NEW |