| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 protocol; | 5 library protocol; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:convert' show JsonDecoder; | 8 import 'dart:convert' show JsonDecoder; |
| 9 | 9 |
| 10 import 'package:analysis_services/json.dart'; | 10 import 'package:analysis_services/json.dart'; |
| (...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 */ | 893 */ |
| 894 void setParameter(String name, Object value) { | 894 void setParameter(String name, Object value) { |
| 895 params[name] = _toJson(value); | 895 params[name] = _toJson(value); |
| 896 } | 896 } |
| 897 | 897 |
| 898 /** | 898 /** |
| 899 * Return a table representing the structure of the Json object that will be | 899 * Return a table representing the structure of the Json object that will be |
| 900 * sent to the client to represent this response. | 900 * sent to the client to represent this response. |
| 901 */ | 901 */ |
| 902 Map<String, Object> toJson() { | 902 Map<String, Object> toJson() { |
| 903 Map<String, Object> jsonObject = new HashMap<String, Object>(); | 903 Map<String, Object> jsonObject = {}; |
| 904 jsonObject[EVENT] = event; | 904 jsonObject[EVENT] = event; |
| 905 if (!params.isEmpty) { | 905 if (!params.isEmpty) { |
| 906 jsonObject[PARAMS] = params; | 906 jsonObject[PARAMS] = params; |
| 907 } | 907 } |
| 908 return jsonObject; | 908 return jsonObject; |
| 909 } | 909 } |
| 910 } | 910 } |
| 911 | 911 |
| 912 /** | 912 /** |
| 913 * Instances of the class [RequestHandler] implement a handler that can handle | 913 * Instances of the class [RequestHandler] implement a handler that can handle |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 */ | 945 */ |
| 946 _toJson(Object value) { | 946 _toJson(Object value) { |
| 947 if (value is HasToJson) { | 947 if (value is HasToJson) { |
| 948 return value.toJson(); | 948 return value.toJson(); |
| 949 } | 949 } |
| 950 if (value is Iterable) { | 950 if (value is Iterable) { |
| 951 return value.map((item) => _toJson(item)).toList(); | 951 return value.map((item) => _toJson(item)).toList(); |
| 952 } | 952 } |
| 953 return value; | 953 return value; |
| 954 } | 954 } |
| OLD | NEW |