Index: pkg/analysis_server/lib/src/protocol/protocol_internal.dart |
diff --git a/pkg/analysis_server/lib/src/protocol/protocol_internal.dart b/pkg/analysis_server/lib/src/protocol/protocol_internal.dart |
index 256523abf7c32a2bb9b529cc54f8c3b7ffd50071..ce774edd9971ab19916738b481201917dc50057b 100644 |
--- a/pkg/analysis_server/lib/src/protocol/protocol_internal.dart |
+++ b/pkg/analysis_server/lib/src/protocol/protocol_internal.dart |
@@ -222,7 +222,7 @@ RefactoringOptions refactoringOptionsFromJson(JsonDecoder jsonDecoder, |
* string describing the part of the JSON object being decoded, and [value] is |
* the part to decode. |
*/ |
-typedef Object JsonDecoderCallback(String jsonPath, Object value); |
+typedef E JsonDecoderCallback<E>(String jsonPath, Object value); |
/** |
* Instances of the class [HasToJson] implement [toJson] method that returns |
@@ -303,14 +303,17 @@ abstract class JsonDecoder { |
} |
/** |
- * Decode a JSON object that is expected to be a List. [decoder] is used to |
- * decode the items in the list. |
+ * Decode a JSON object that is expected to be a List. The [decoder] is used |
+ * to decode the items in the list. |
+ * |
+ * The type parameter [E] is the expected type of the elements in the list. |
*/ |
- List decodeList(String jsonPath, Object json, [JsonDecoderCallback decoder]) { |
+ List/*<E>*/ decodeList/*<E>*/(String jsonPath, Object json, |
+ [JsonDecoderCallback/*<E>*/ decoder]) { |
if (json == null) { |
- return []; |
+ return/*<E>*/ []; |
} else if (json is List) { |
- List result = []; |
+ List/*<E>*/ result = /*<E>*/ []; |
for (int i = 0; i < json.length; i++) { |
result.add(decoder('$jsonPath[$i]', json[i])); |
} |
@@ -324,23 +327,24 @@ abstract class JsonDecoder { |
* Decode a JSON object that is expected to be a Map. [keyDecoder] is used |
* to decode the keys, and [valueDecoder] is used to decode the values. |
*/ |
- Map decodeMap(String jsonPath, Object json, |
- {JsonDecoderCallback keyDecoder, JsonDecoderCallback valueDecoder}) { |
+ Map/*<K, V>*/ decodeMap/*<K, V>*/(String jsonPath, Object json, |
+ {JsonDecoderCallback/*<K>*/ keyDecoder, |
+ JsonDecoderCallback/*<V>*/ valueDecoder}) { |
if (json == null) { |
return {}; |
} else if (json is Map) { |
- Map result = {}; |
+ Map/*<K, V>*/ result = /*<K, V>*/ {}; |
json.forEach((String key, value) { |
- Object decodedKey; |
+ Object/*=K*/ decodedKey; |
if (keyDecoder != null) { |
decodedKey = keyDecoder('$jsonPath.key', key); |
} else { |
- decodedKey = key; |
+ decodedKey = key as Object/*=K*/; |
} |
if (valueDecoder != null) { |
value = valueDecoder('$jsonPath[${JSON.encode(key)}]', value); |
} |
- result[decodedKey] = value; |
+ result[decodedKey] = value as Object/*=V*/; |
}); |
return result; |
} else { |