| 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'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import 'package:analysis_server/src/services/json.dart'; | |
| 11 | |
| 12 part 'generated_protocol.dart'; | 10 part 'generated_protocol.dart'; |
| 13 | 11 |
| 14 | 12 |
| 15 final Map<String, RefactoringKind> REQUEST_ID_REFACTORING_KINDS = | 13 final Map<String, RefactoringKind> REQUEST_ID_REFACTORING_KINDS = |
| 16 new HashMap<String, RefactoringKind>(); | 14 new HashMap<String, RefactoringKind>(); |
| 17 | 15 |
| 18 /** | 16 /** |
| 19 * Translate the input [map], applying [keyCallback] to all its keys, and | 17 * Translate the input [map], applying [keyCallback] to all its keys, and |
| 20 * [valueCallback] to all its values. | 18 * [valueCallback] to all its values. |
| 21 */ | 19 */ |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 } | 225 } |
| 228 | 226 |
| 229 | 227 |
| 230 /** | 228 /** |
| 231 * Type of callbacks used to decode parts of JSON objects. [jsonPath] is a | 229 * Type of callbacks used to decode parts of JSON objects. [jsonPath] is a |
| 232 * string describing the part of the JSON object being decoded, and [value] is | 230 * string describing the part of the JSON object being decoded, and [value] is |
| 233 * the part to decode. | 231 * the part to decode. |
| 234 */ | 232 */ |
| 235 typedef Object JsonDecoderCallback(String jsonPath, Object value); | 233 typedef Object JsonDecoderCallback(String jsonPath, Object value); |
| 236 | 234 |
| 235 |
| 236 /** |
| 237 * Instances of the class [HasToJson] implement [toJson] method that returns |
| 238 * a JSON presentation. |
| 239 */ |
| 240 abstract class HasToJson { |
| 241 /** |
| 242 * Returns a JSON presentation of the object. |
| 243 */ |
| 244 Map<String, Object> toJson(); |
| 245 } |
| 246 |
| 247 |
| 237 /** | 248 /** |
| 238 * Base class for decoding JSON objects. The derived class must implement | 249 * Base class for decoding JSON objects. The derived class must implement |
| 239 * error reporting logic. | 250 * error reporting logic. |
| 240 */ | 251 */ |
| 241 abstract class JsonDecoder { | 252 abstract class JsonDecoder { |
| 242 /** | 253 /** |
| 243 * Create an exception to throw if the JSON object at [jsonPath] fails to | 254 * Create an exception to throw if the JSON object at [jsonPath] fails to |
| 244 * match the API definition of [expected]. | 255 * match the API definition of [expected]. |
| 245 */ | 256 */ |
| 246 dynamic mismatch(String jsonPath, String expected); | 257 dynamic mismatch(String jsonPath, String expected); |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); | 834 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); |
| 824 hash = hash ^ (hash >> 11); | 835 hash = hash ^ (hash >> 11); |
| 825 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); | 836 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); |
| 826 } | 837 } |
| 827 | 838 |
| 828 static int hash2(a, b) => finish(combine(combine(0, a), b)); | 839 static int hash2(a, b) => finish(combine(combine(0, a), b)); |
| 829 | 840 |
| 830 static int hash4(a, b, c, d) => | 841 static int hash4(a, b, c, d) => |
| 831 finish(combine(combine(combine(combine(0, a), b), c), d)); | 842 finish(combine(combine(combine(combine(0, a), b), c), d)); |
| 832 } | 843 } |
| OLD | NEW |