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

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

Issue 2844273003: Unify the server and plugin versions of the generators (Closed)
Patch Set: add missed files Created 3 years, 7 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
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 /** 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
11 import 'dart:collection'; 11 import 'dart:collection';
12 import 'dart:convert' hide JsonDecoder; 12 import 'dart:convert' hide JsonDecoder;
13 13
14 import 'package:analysis_server/protocol/protocol_generated.dart';
14 import 'package:analysis_server/src/protocol/protocol_internal.dart'; 15 import 'package:analysis_server/src/protocol/protocol_internal.dart';
15 16
16 part 'generated_protocol.dart';
17
18 /** 17 /**
19 * A [RequestHandler] that supports [startup] and [shutdown] methods. 18 * A [RequestHandler] that supports [startup] and [shutdown] methods.
20 * 19 *
21 * Clients may not extend, implement or mix-in this class. 20 * Clients may not extend, implement or mix-in this class.
22 */ 21 */
23 abstract class DomainHandler implements RequestHandler { 22 abstract class DomainHandler implements RequestHandler {
24 /** 23 /**
25 * Perform any operations associated with the shutdown of the domain. It is 24 * Perform any operations associated with the shutdown of the domain. It is
26 * not guaranteed that this method will be called. If it is, it will be 25 * not guaranteed that this method will be called. If it is, it will be
27 * called after the last [Request] has been made. 26 * called after the last [Request] has been made.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 66
68 /** 67 /**
69 * The name of the event that triggered the notification. 68 * The name of the event that triggered the notification.
70 */ 69 */
71 final String event; 70 final String event;
72 71
73 /** 72 /**
74 * A table mapping the names of notification parameters to their values, or 73 * A table mapping the names of notification parameters to their values, or
75 * `null` if there are no notification parameters. 74 * `null` if there are no notification parameters.
76 */ 75 */
77 Map<String, Object> _params; 76 final Map<String, Object> params;
78 77
79 /** 78 /**
80 * Initialize a newly created [Notification] to have the given [event] name. 79 * 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 80 * If [_params] is provided, it will be used as the params; otherwise no
82 * params will be used. 81 * params will be used.
83 */ 82 */
84 Notification(this.event, [this._params]); 83 Notification(this.event, [this.params]);
85 84
86 /** 85 /**
87 * Initialize a newly created instance based on the given JSON data. 86 * Initialize a newly created instance based on the given JSON data.
88 */ 87 */
89 factory Notification.fromJson(Map json) { 88 factory Notification.fromJson(Map json) {
90 return new Notification(json[Notification.EVENT], 89 return new Notification(json[Notification.EVENT],
91 json[Notification.PARAMS] as Map<String, Object>); 90 json[Notification.PARAMS] as Map<String, Object>);
92 } 91 }
93 92
94 /** 93 /**
95 * Return a table representing the structure of the Json object that will be 94 * Return a table representing the structure of the Json object that will be
96 * sent to the client to represent this response. 95 * sent to the client to represent this response.
97 */ 96 */
98 Map<String, Object> toJson() { 97 Map<String, Object> toJson() {
99 Map<String, Object> jsonObject = {}; 98 Map<String, Object> jsonObject = {};
100 jsonObject[EVENT] = event; 99 jsonObject[EVENT] = event;
101 if (_params != null) { 100 if (params != null) {
102 jsonObject[PARAMS] = _params; 101 jsonObject[PARAMS] = params;
103 } 102 }
104 return jsonObject; 103 return jsonObject;
105 } 104 }
106 } 105 }
107 106
108 /** 107 /**
109 * A request that was received from the client. 108 * A request that was received from the client.
110 * 109 *
111 * Clients may not extend, implement or mix-in this class. 110 * Clients may not extend, implement or mix-in this class.
112 */ 111 */
(...skipping 25 matching lines...) Expand all
138 final String id; 137 final String id;
139 138
140 /** 139 /**
141 * The method being requested. 140 * The method being requested.
142 */ 141 */
143 final String method; 142 final String method;
144 143
145 /** 144 /**
146 * A table mapping the names of request parameters to their values. 145 * A table mapping the names of request parameters to their values.
147 */ 146 */
148 final Map<String, Object> _params; 147 final Map<String, Object> params;
149 148
150 /** 149 /**
151 * The time (milliseconds since epoch) at which the client made the request 150 * The time (milliseconds since epoch) at which the client made the request
152 * or `null` if this information is not provided by the client. 151 * or `null` if this information is not provided by the client.
153 */ 152 */
154 final int clientRequestTime; 153 final int clientRequestTime;
155 154
156 /** 155 /**
157 * Initialize a newly created [Request] to have the given [id] and [method] 156 * Initialize a newly created [Request] to have the given [id] and [method]
158 * name. If [params] is supplied, it is used as the "params" map for the 157 * name. If [params] is supplied, it is used as the "params" map for the
159 * request. Otherwise an empty "params" map is allocated. 158 * request. Otherwise an empty "params" map is allocated.
160 */ 159 */
161 Request(this.id, this.method, 160 Request(this.id, this.method,
162 [Map<String, Object> params, this.clientRequestTime]) 161 [Map<String, Object> params, this.clientRequestTime])
163 : _params = params ?? new HashMap<String, Object>(); 162 : params = params ?? new HashMap<String, Object>();
164 163
165 /** 164 /**
166 * Return a request parsed from the given json, or `null` if the [data] is 165 * Return a request parsed from the given json, or `null` if the [data] is
167 * not a valid json representation of a request. The [data] is expected to 166 * not a valid json representation of a request. The [data] is expected to
168 * have the following format: 167 * have the following format:
169 * 168 *
170 * { 169 * {
171 * 'clientRequestTime': millisecondsSinceEpoch 170 * 'clientRequestTime': millisecondsSinceEpoch
172 * 'id': String, 171 * 'id': String,
173 * 'method': methodName, 172 * 'method': methodName,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } 232 }
234 233
235 /** 234 /**
236 * Return a table representing the structure of the Json object that will be 235 * Return a table representing the structure of the Json object that will be
237 * sent to the client to represent this response. 236 * sent to the client to represent this response.
238 */ 237 */
239 Map<String, Object> toJson() { 238 Map<String, Object> toJson() {
240 Map<String, Object> jsonObject = new HashMap<String, Object>(); 239 Map<String, Object> jsonObject = new HashMap<String, Object>();
241 jsonObject[ID] = id; 240 jsonObject[ID] = id;
242 jsonObject[METHOD] = method; 241 jsonObject[METHOD] = method;
243 if (_params.isNotEmpty) { 242 if (params.isNotEmpty) {
244 jsonObject[PARAMS] = _params; 243 jsonObject[PARAMS] = params;
245 } 244 }
246 if (clientRequestTime != null) { 245 if (clientRequestTime != null) {
247 jsonObject[CLIENT_REQUEST_TIME] = clientRequestTime; 246 jsonObject[CLIENT_REQUEST_TIME] = clientRequestTime;
248 } 247 }
249 return jsonObject; 248 return jsonObject;
250 } 249 }
251 } 250 }
252 251
253 /** 252 /**
254 * An exception that occurred during the handling of a request that requires 253 * An exception that occurred during the handling of a request that requires
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 jsonObject[ID] = id; 588 jsonObject[ID] = id;
590 if (error != null) { 589 if (error != null) {
591 jsonObject[ERROR] = error.toJson(); 590 jsonObject[ERROR] = error.toJson();
592 } 591 }
593 if (_result != null) { 592 if (_result != null) {
594 jsonObject[RESULT] = _result; 593 jsonObject[RESULT] = _result;
595 } 594 }
596 return jsonObject; 595 return jsonObject;
597 } 596 }
598 } 597 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/plugin/protocol/protocol_dart.dart ('k') | pkg/analysis_server/lib/protocol/protocol_generated.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698