Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Unified Diff: pkg/analyzer/lib/src/task/inputs.dart

Issue 1005693007: Add toMap / toMapOf / toList (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/lib/src/task/model.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/inputs.dart
diff --git a/pkg/analyzer/lib/src/task/inputs.dart b/pkg/analyzer/lib/src/task/inputs.dart
index 425869ff462b91d704d8f62b21566db864be0ff8..bba4f71674ae968bd77a68fbdfc8f538b7ff51db 100644
--- a/pkg/analyzer/lib/src/task/inputs.dart
+++ b/pkg/analyzer/lib/src/task/inputs.dart
@@ -16,6 +16,42 @@ import 'package:analyzer/task/model.dart';
typedef TaskInput<E> GenerateTaskInputs<B, E>(B object);
/**
+ * An input to an [AnalysisTask] that is computed by accessing a single result
+ * defined on a single target.
+ */
+class ListTaskInputImpl<E> extends SimpleTaskInput<List<E>>
+ implements ListTaskInput<E> {
+ /**
+ * Initialize a newly created task input that computes the input by accessing
+ * the given [result] associated with the given [target].
+ */
+ ListTaskInputImpl(AnalysisTarget target, ResultDescriptor<List<E>> result)
+ : super(target, result);
+
+ @override
+ TaskInput<List /*<V>*/ > toList(UnaryFunction<E, Object /*<V>*/ > mapper) {
+ return new ListToListTaskInput<E, Object /*V*/ >(this, mapper);
+ }
+
+ @override
+ TaskInput<List /*<V>*/ > toListOf(ResultDescriptor /*<V>*/ valueResult) {
+ return (this as ListTaskInputImpl<AnalysisTarget>).toList(valueResult.of);
+ }
+
+ @override
+ TaskInput<Map<E, Object /*V*/ >> toMap(
+ UnaryFunction<E, Object /*<V>*/ > mapper) {
+ return new ListToMapTaskInput<E, Object /*V*/ >(this, mapper);
+ }
+
+ @override
+ TaskInput<Map<AnalysisTarget, Object /*V*/ >> toMapOf(
+ ResultDescriptor /*<V>*/ valueResult) {
+ return (this as ListTaskInputImpl<AnalysisTarget>).toMap(valueResult.of);
+ }
+}
+
+/**
* An input to an [AnalysisTask] that is computed by the following steps. First
* another (base) task input is used to compute a [List]-valued result. An input
* generator function is then used to map each element of that list to a task
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/lib/src/task/model.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698