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 'dart:async'; |
| 6 |
5 import 'package:analysis_server/protocol/protocol.dart'; | 7 import 'package:analysis_server/protocol/protocol.dart'; |
6 import 'package:analysis_server/protocol/protocol_constants.dart'; | 8 import 'package:analysis_server/protocol/protocol_constants.dart'; |
7 import 'package:analysis_server/protocol/protocol_generated.dart'; | 9 import 'package:analysis_server/protocol/protocol_generated.dart'; |
8 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
9 | 11 |
10 /** | 12 /** |
11 * Instances of the class [ServerDomainHandler] implement a [RequestHandler] | 13 * Instances of the class [ServerDomainHandler] implement a [RequestHandler] |
12 * that handles requests in the server domain. | 14 * that handles requests in the server domain. |
13 */ | 15 */ |
14 class ServerDomainHandler implements RequestHandler { | 16 class ServerDomainHandler implements RequestHandler { |
(...skipping 17 matching lines...) Expand all Loading... |
32 | 34 |
33 @override | 35 @override |
34 Response handleRequest(Request request) { | 36 Response handleRequest(Request request) { |
35 try { | 37 try { |
36 String requestName = request.method; | 38 String requestName = request.method; |
37 if (requestName == SERVER_REQUEST_GET_VERSION) { | 39 if (requestName == SERVER_REQUEST_GET_VERSION) { |
38 return getVersion(request); | 40 return getVersion(request); |
39 } else if (requestName == SERVER_REQUEST_SET_SUBSCRIPTIONS) { | 41 } else if (requestName == SERVER_REQUEST_SET_SUBSCRIPTIONS) { |
40 return setSubscriptions(request); | 42 return setSubscriptions(request); |
41 } else if (requestName == SERVER_REQUEST_SHUTDOWN) { | 43 } else if (requestName == SERVER_REQUEST_SHUTDOWN) { |
42 return shutdown(request); | 44 shutdown(request); |
| 45 return Response.DELAYED_RESPONSE; |
43 } | 46 } |
44 } on RequestFailure catch (exception) { | 47 } on RequestFailure catch (exception) { |
45 return exception.response; | 48 return exception.response; |
46 } | 49 } |
47 return null; | 50 return null; |
48 } | 51 } |
49 | 52 |
50 /** | 53 /** |
51 * Subscribe for services. | 54 * Subscribe for services. |
52 * | 55 * |
53 * All previous subscriptions are replaced by the given set of subscriptions. | 56 * All previous subscriptions are replaced by the given set of subscriptions. |
54 */ | 57 */ |
55 Response setSubscriptions(Request request) { | 58 Response setSubscriptions(Request request) { |
56 server.serverServices = | 59 server.serverServices = |
57 new ServerSetSubscriptionsParams.fromRequest(request) | 60 new ServerSetSubscriptionsParams.fromRequest(request) |
58 .subscriptions | 61 .subscriptions |
59 .toSet(); | 62 .toSet(); |
60 return new ServerSetSubscriptionsResult().toResponse(request.id); | 63 return new ServerSetSubscriptionsResult().toResponse(request.id); |
61 } | 64 } |
62 | 65 |
63 /** | 66 /** |
64 * Cleanly shutdown the analysis server. | 67 * Cleanly shutdown the analysis server. |
65 */ | 68 */ |
66 Response shutdown(Request request) { | 69 Future<Null> shutdown(Request request) async { |
67 server.shutdown(); | 70 await server.shutdown(); |
68 Response response = new ServerShutdownResult().toResponse(request.id); | 71 Response response = new ServerShutdownResult().toResponse(request.id); |
69 return response; | 72 server.sendResponse(response); |
70 } | 73 } |
71 } | 74 } |
OLD | NEW |