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