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 import 'package:analysis_server/protocol/protocol.dart'; | 5 import 'package:analysis_server/protocol/protocol.dart'; |
| 6 import 'package:analysis_server/protocol/protocol_constants.dart'; |
6 import 'package:analysis_server/protocol/protocol_generated.dart'; | 7 import 'package:analysis_server/protocol/protocol_generated.dart'; |
7 import 'package:analysis_server/src/analysis_server.dart'; | 8 import 'package:analysis_server/src/analysis_server.dart'; |
8 import 'package:analysis_server/src/constants.dart'; | |
9 | 9 |
10 /** | 10 /** |
11 * Instances of the class [ServerDomainHandler] implement a [RequestHandler] | 11 * Instances of the class [ServerDomainHandler] implement a [RequestHandler] |
12 * that handles requests in the server domain. | 12 * that handles requests in the server domain. |
13 */ | 13 */ |
14 class ServerDomainHandler implements RequestHandler { | 14 class ServerDomainHandler implements RequestHandler { |
15 /** | 15 /** |
16 * The analysis server that is using this handler to process requests. | 16 * The analysis server that is using this handler to process requests. |
17 */ | 17 */ |
18 final AnalysisServer server; | 18 final AnalysisServer server; |
19 | 19 |
20 /** | 20 /** |
21 * Initialize a newly created handler to handle requests for the given [server
]. | 21 * Initialize a newly created handler to handle requests for the given [server
]. |
22 */ | 22 */ |
23 ServerDomainHandler(this.server); | 23 ServerDomainHandler(this.server); |
24 | 24 |
25 /** | 25 /** |
26 * Return the version number of the analysis server. | 26 * Return the version number of the analysis server. |
27 */ | 27 */ |
28 Response getVersion(Request request) { | 28 Response getVersion(Request request) { |
29 return new ServerGetVersionResult(AnalysisServer.VERSION) | 29 return new ServerGetVersionResult(AnalysisServer.VERSION) |
30 .toResponse(request.id); | 30 .toResponse(request.id); |
31 } | 31 } |
32 | 32 |
33 @override | 33 @override |
34 Response handleRequest(Request request) { | 34 Response handleRequest(Request request) { |
35 try { | 35 try { |
36 String requestName = request.method; | 36 String requestName = request.method; |
37 if (requestName == SERVER_GET_VERSION) { | 37 if (requestName == SERVER_REQUEST_GET_VERSION) { |
38 return getVersion(request); | 38 return getVersion(request); |
39 } else if (requestName == SERVER_SET_SUBSCRIPTIONS) { | 39 } else if (requestName == SERVER_REQUEST_SET_SUBSCRIPTIONS) { |
40 return setSubscriptions(request); | 40 return setSubscriptions(request); |
41 } else if (requestName == SERVER_SHUTDOWN) { | 41 } else if (requestName == SERVER_REQUEST_SHUTDOWN) { |
42 return shutdown(request); | 42 return shutdown(request); |
43 } | 43 } |
44 } on RequestFailure catch (exception) { | 44 } on RequestFailure catch (exception) { |
45 return exception.response; | 45 return exception.response; |
46 } | 46 } |
47 return null; | 47 return null; |
48 } | 48 } |
49 | 49 |
50 /** | 50 /** |
51 * Subscribe for services. | 51 * Subscribe for services. |
(...skipping 10 matching lines...) Expand all Loading... |
62 | 62 |
63 /** | 63 /** |
64 * Cleanly shutdown the analysis server. | 64 * Cleanly shutdown the analysis server. |
65 */ | 65 */ |
66 Response shutdown(Request request) { | 66 Response shutdown(Request request) { |
67 server.shutdown(); | 67 server.shutdown(); |
68 Response response = new ServerShutdownResult().toResponse(request.id); | 68 Response response = new ServerShutdownResult().toResponse(request.id); |
69 return response; | 69 return response; |
70 } | 70 } |
71 } | 71 } |
OLD | NEW |