| 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 /** | 26 /** |
| 27 * Return the version number of the analysis server. | 27 * Return the version number of the analysis server. |
| 28 */ | 28 */ |
| 29 Response getVersion(Request request) { | 29 Response getVersion(Request request) { |
| 30 return new ServerGetVersionResult('0.0.1').toResponse(request.id); | 30 return new ServerGetVersionResult( |
| 31 AnalysisServer.VERSION).toResponse(request.id); |
| 31 } | 32 } |
| 32 | 33 |
| 33 @override | 34 @override |
| 34 Response handleRequest(Request request) { | 35 Response handleRequest(Request request) { |
| 35 try { | 36 try { |
| 36 String requestName = request.method; | 37 String requestName = request.method; |
| 37 if (requestName == SERVER_GET_VERSION) { | 38 if (requestName == SERVER_GET_VERSION) { |
| 38 return getVersion(request); | 39 return getVersion(request); |
| 39 } else if (requestName == SERVER_SET_SUBSCRIPTIONS) { | 40 } else if (requestName == SERVER_SET_SUBSCRIPTIONS) { |
| 40 return setSubscriptions(request); | 41 return setSubscriptions(request); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 60 | 61 |
| 61 /** | 62 /** |
| 62 * Cleanly shutdown the analysis server. | 63 * Cleanly shutdown the analysis server. |
| 63 */ | 64 */ |
| 64 Response shutdown(Request request) { | 65 Response shutdown(Request request) { |
| 65 server.shutdown(); | 66 server.shutdown(); |
| 66 Response response = new ServerShutdownResult().toResponse(request.id); | 67 Response response = new ServerShutdownResult().toResponse(request.id); |
| 67 return response; | 68 return response; |
| 68 } | 69 } |
| 69 } | 70 } |
| OLD | NEW |