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

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

Issue 477323005: Use generated classes to create requests in analysis server unit tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 | « no previous file | pkg/analysis_server/test/analysis/get_errors_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:collection'; 7 import 'dart:collection';
8 import 'dart:convert' show JsonDecoder; 8 import 'dart:convert' show JsonDecoder;
9 9
10 import 'package:analysis_server/src/services/json.dart'; 10 import 'package:analysis_server/src/services/json.dart';
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 * such parameter associated with this request. 100 * such parameter associated with this request.
101 */ 101 */
102 RequestDatum getRequiredParameter(String name) { 102 RequestDatum getRequiredParameter(String name) {
103 if (!params.containsKey(name)) { 103 if (!params.containsKey(name)) {
104 throw new RequestFailure(new Response.missingRequiredParameter(this, name) ); 104 throw new RequestFailure(new Response.missingRequiredParameter(this, name) );
105 } 105 }
106 return new RequestDatum(this, name, params[name]); 106 return new RequestDatum(this, name, params[name]);
107 } 107 }
108 108
109 /** 109 /**
110 * Set the value of the parameter with the given [name] to the given [value].
111 */
112 void setParameter(String name, Object value) {
113 params[name] = value;
114 }
115
116 /**
117 * Return a table representing the structure of the Json object that will be 110 * Return a table representing the structure of the Json object that will be
118 * sent to the client to represent this response. 111 * sent to the client to represent this response.
119 */ 112 */
120 Map<String, Object> toJson() { 113 Map<String, Object> toJson() {
121 Map<String, Object> jsonObject = new HashMap<String, Object>(); 114 Map<String, Object> jsonObject = new HashMap<String, Object>();
122 jsonObject[ID] = id; 115 jsonObject[ID] = id;
123 jsonObject[METHOD] = method; 116 jsonObject[METHOD] = method;
124 if (params.isNotEmpty) { 117 if (params.isNotEmpty) {
125 jsonObject[PARAMS] = params; 118 jsonObject[PARAMS] = params;
126 } 119 }
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 */ 880 */
888 _toJson(Object value) { 881 _toJson(Object value) {
889 if (value is HasToJson) { 882 if (value is HasToJson) {
890 return value.toJson(); 883 return value.toJson();
891 } 884 }
892 if (value is Iterable) { 885 if (value is Iterable) {
893 return value.map((item) => _toJson(item)).toList(); 886 return value.map((item) => _toJson(item)).toList();
894 } 887 }
895 return value; 888 return value;
896 } 889 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis/get_errors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698