| 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 library domain.server; | 5 library domain.server; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/analysis_server.dart'; | 7 import 'package:analysis_server/src/analysis_server.dart'; |
| 8 import 'package:analysis_server/src/constants.dart'; | 8 import 'package:analysis_server/src/constants.dart'; |
| 9 import 'package:analysis_server/src/protocol.dart'; | 9 import 'package:analysis_server/src/protocol.dart'; |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * Instances of the class [ServerDomainHandler] implement a [RequestHandler] | 12 * Instances of the class [ServerDomainHandler] implement a [RequestHandler] |
| 13 * that handles requests in the server domain. | 13 * that handles requests in the server domain. |
| 14 */ | 14 */ |
| 15 class ServerDomainHandler implements RequestHandler { | 15 class ServerDomainHandler implements RequestHandler { |
| 16 /** | 16 /** |
| 17 * The analysis server that is using this handler to process requests. | 17 * The analysis server that is using this handler to process requests. |
| 18 */ | 18 */ |
| 19 final AnalysisServer server; | 19 final AnalysisServer server; |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * Initialize a newly created handler to handle requests for the given [server
]. | 22 * Initialize a newly created handler to handle requests for the given [server
]. |
| 23 */ | 23 */ |
| 24 ServerDomainHandler(this.server); | 24 ServerDomainHandler(this.server); |
| 25 | 25 |
| 26 @override | 26 @override |
| 27 Response handleRequest(Request request) { | 27 Response handleRequest(Request request) { |
| 28 try { | 28 try { |
| 29 String requestName = request.method; | 29 String requestName = request.method; |
| 30 if (requestName == METHOD_GET_VERSION) { | 30 if (requestName == SERVER_GET_VERSION) { |
| 31 return getVersion(request); | 31 return getVersion(request); |
| 32 } else if (requestName == METHOD_SET_SERVER_SUBSCRIPTIONS) { | 32 } else if (requestName == SERVER_SET_SUBSCRIPTIONS) { |
| 33 return setSubscriptions(request); | 33 return setSubscriptions(request); |
| 34 } else if (requestName == METHOD_SHUTDOWN) { | 34 } else if (requestName == SERVER_SHUTDOWN) { |
| 35 return shutdown(request); | 35 return shutdown(request); |
| 36 } | 36 } |
| 37 } on RequestFailure catch (exception) { | 37 } on RequestFailure catch (exception) { |
| 38 return exception.response; | 38 return exception.response; |
| 39 } | 39 } |
| 40 return null; | 40 return null; |
| 41 } | 41 } |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * Subscribe for services. | 44 * Subscribe for services. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 115 |
| 116 /** | 116 /** |
| 117 * Return the version number of the analysis server. | 117 * Return the version number of the analysis server. |
| 118 */ | 118 */ |
| 119 Response getVersion(Request request) { | 119 Response getVersion(Request request) { |
| 120 Response response = new Response(request.id); | 120 Response response = new Response(request.id); |
| 121 response.setResult(VERSION, '0.0.1'); | 121 response.setResult(VERSION, '0.0.1'); |
| 122 return response; | 122 return response; |
| 123 } | 123 } |
| 124 } | 124 } |
| OLD | NEW |