Chromium Code Reviews| 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..2a1c2b5866d6b2afc59b9f13ebdf2b97a4ca62bd 100644 |
| --- a/pkg/analysis_server/lib/src/protocol/protocol_internal.dart |
| +++ b/pkg/analysis_server/lib/src/protocol/protocol_internal.dart |
| @@ -303,16 +303,19 @@ 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 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])); |
| + result.add(decoder('$jsonPath[$i]', json[i]) as Object/*=E*/); |
|
Paul Berry
2016/03/31 19:44:02
Could we also get rid of this cast by parameterizi
Brian Wilkerson
2016/03/31 19:51:34
Yes. Done.
|
| } |
| return result; |
| } else { |
| @@ -324,23 +327,23 @@ 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, |
| + Map/*<K, V>*/ decodeMap/*<K, V>*/(String jsonPath, Object json, |
| {JsonDecoderCallback keyDecoder, JsonDecoderCallback 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); |
| + decodedKey = keyDecoder('$jsonPath.key', key) as Object/*=K*/; |
|
Paul Berry
2016/03/31 19:44:02
Similar question here.
Brian Wilkerson
2016/03/31 19:51:34
Done.
|
| } 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 { |