Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Side by Side Diff: pkg/analysis_server/lib/src/protocol.dart

Issue 185313002: restructure client api to use streams (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/lib/src/channel.dart ('k') | pkg/analysis_server/test/channel_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:convert' show JsonDecoder; 7 import 'dart:convert' show JsonDecoder;
8 8
9 /** 9 /**
10 * Instances of the class [Request] represent a request that was received. 10 * Instances of the class [Request] represent a request that was received.
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 * by a [request] that cannot be handled by any known handlers. 258 * by a [request] that cannot be handled by any known handlers.
259 */ 259 */
260 Response.unknownRequest(Request request) 260 Response.unknownRequest(Request request)
261 : this(request.id, new RequestError(-7, 'Unknown request')); 261 : this(request.id, new RequestError(-7, 'Unknown request'));
262 262
263 /** 263 /**
264 * Initialize a newly created instance based upon the given JSON data 264 * Initialize a newly created instance based upon the given JSON data
265 */ 265 */
266 factory Response.fromJson(Map<String, Object> json) { 266 factory Response.fromJson(Map<String, Object> json) {
267 try { 267 try {
268 // TODO process result 268 var id = json[Response.ID];
269 String id = json[Response.ID]; 269 if (id is! String) {
270 return null;
271 }
270 var error = json[Response.ERROR]; 272 var error = json[Response.ERROR];
271 var result = json[Response.RESULT]; 273 var result = json[Response.RESULT];
272 Response response; 274 Response response;
273 if (error is Map) { 275 if (error is Map) {
274 response = new Response(id, new RequestError.fromJson(error)); 276 response = new Response(id, new RequestError.fromJson(error));
275 } else { 277 } else {
276 response = new Response(id); 278 response = new Response(id);
277 } 279 }
278 if (result is Map) { 280 if (result is Map) {
279 result.forEach((String key, Object value) { 281 result.forEach((String key, Object value) {
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 /** 574 /**
573 * The response to be returned as a result of the failure. 575 * The response to be returned as a result of the failure.
574 */ 576 */
575 final Response response; 577 final Response response;
576 578
577 /** 579 /**
578 * Initialize a newly created exception to return the given reponse. 580 * Initialize a newly created exception to return the given reponse.
579 */ 581 */
580 RequestFailure(this.response); 582 RequestFailure(this.response);
581 } 583 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/channel.dart ('k') | pkg/analysis_server/test/channel_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698