| 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 /** | 5 /** |
| 6 * Support for client code that needs to interact with the requests, responses | 6 * Support for client code that needs to interact with the requests, responses |
| 7 * and notifications that are part of the analysis server's wire protocol. | 7 * and notifications that are part of the analysis server's wire protocol. |
| 8 */ | 8 */ |
| 9 library analysis_server.plugin.protocol.protocol; | 9 library analysis_server.plugin.protocol.protocol; |
| 10 | 10 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 /** | 79 /** |
| 80 * Initialize a newly created [Notification] to have the given [event] name. | 80 * Initialize a newly created [Notification] to have the given [event] name. |
| 81 * If [_params] is provided, it will be used as the params; otherwise no | 81 * If [_params] is provided, it will be used as the params; otherwise no |
| 82 * params will be used. | 82 * params will be used. |
| 83 */ | 83 */ |
| 84 Notification(this.event, [this._params]); | 84 Notification(this.event, [this._params]); |
| 85 | 85 |
| 86 /** | 86 /** |
| 87 * Initialize a newly created instance based on the given JSON data. | 87 * Initialize a newly created instance based on the given JSON data. |
| 88 */ | 88 */ |
| 89 factory Notification.fromJson(Map<String, Object> json) { | 89 factory Notification.fromJson(Map json) { |
| 90 return new Notification(json[Notification.EVENT], | 90 return new Notification(json[Notification.EVENT], |
| 91 json[Notification.PARAMS] as Map<String, Object>); | 91 json[Notification.PARAMS] as Map<String, Object>); |
| 92 } | 92 } |
| 93 | 93 |
| 94 /** | 94 /** |
| 95 * Return a table representing the structure of the Json object that will be | 95 * Return a table representing the structure of the Json object that will be |
| 96 * sent to the client to represent this response. | 96 * sent to the client to represent this response. |
| 97 */ | 97 */ |
| 98 Map<String, Object> toJson() { | 98 Map<String, Object> toJson() { |
| 99 Map<String, Object> jsonObject = {}; | 99 Map<String, Object> jsonObject = {}; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 * error condition. | 361 * error condition. |
| 362 */ | 362 */ |
| 363 Response.formatWithErrors(Request request) | 363 Response.formatWithErrors(Request request) |
| 364 : this(request.id, | 364 : this(request.id, |
| 365 error: new RequestError(RequestErrorCode.FORMAT_WITH_ERRORS, | 365 error: new RequestError(RequestErrorCode.FORMAT_WITH_ERRORS, |
| 366 'Error during `edit.format`: source contains syntax errors.')); | 366 'Error during `edit.format`: source contains syntax errors.')); |
| 367 | 367 |
| 368 /** | 368 /** |
| 369 * Initialize a newly created instance based on the given JSON data. | 369 * Initialize a newly created instance based on the given JSON data. |
| 370 */ | 370 */ |
| 371 factory Response.fromJson(Map<String, Object> json) { | 371 factory Response.fromJson(Map json) { |
| 372 try { | 372 try { |
| 373 Object id = json[Response.ID]; | 373 Object id = json[Response.ID]; |
| 374 if (id is! String) { | 374 if (id is! String) { |
| 375 return null; | 375 return null; |
| 376 } | 376 } |
| 377 Object error = json[Response.ERROR]; | 377 Object error = json[Response.ERROR]; |
| 378 RequestError decodedError; | 378 RequestError decodedError; |
| 379 if (error is Map) { | 379 if (error is Map) { |
| 380 decodedError = new RequestError.fromJson( | 380 decodedError = new RequestError.fromJson( |
| 381 new ResponseDecoder(null), '.error', error); | 381 new ResponseDecoder(null), '.error', error); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 jsonObject[ID] = id; | 575 jsonObject[ID] = id; |
| 576 if (error != null) { | 576 if (error != null) { |
| 577 jsonObject[ERROR] = error.toJson(); | 577 jsonObject[ERROR] = error.toJson(); |
| 578 } | 578 } |
| 579 if (_result != null) { | 579 if (_result != null) { |
| 580 jsonObject[RESULT] = _result; | 580 jsonObject[RESULT] = _result; |
| 581 } | 581 } |
| 582 return jsonObject; | 582 return jsonObject; |
| 583 } | 583 } |
| 584 } | 584 } |
| OLD | NEW |