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

Side by Side Diff: pkg/analysis_server/lib/src/domain_server.dart

Issue 308703005: Extract constants into separate libarary. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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 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/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
9 10
10 /** 11 /**
11 * Instances of the class [ServerDomainHandler] implement a [RequestHandler] 12 * Instances of the class [ServerDomainHandler] implement a [RequestHandler]
12 * that handles requests in the server domain. 13 * that handles requests in the server domain.
13 */ 14 */
14 class ServerDomainHandler implements RequestHandler { 15 class ServerDomainHandler implements RequestHandler {
15 /** 16 /**
16 * The name of the `server.getVersion` request.
17 */
18 static const String GET_VERSION_METHOD = 'server.getVersion';
19
20 /**
21 * The name of the `server.setSubscriptions` request.
22 */
23 static const String SET_SUBSCRIPTIONS_METHOD = 'server.setSubscriptions';
24
25 /**
26 * The name of the `server.shutdown` request.
27 */
28 static const String SHUTDOWN_METHOD = 'server.shutdown';
29
30 /**
31 * The name of the `subscriptions` parameter.
32 */
33 static const String SUBSCRIPTIONS_PARAMETER = 'subscriptions';
34
35 /**
36 * The name of the version result value.
37 */
38 static const String VERSION_RESULT = 'version';
39
40 /**
41 * The analysis server that is using this handler to process requests. 17 * The analysis server that is using this handler to process requests.
42 */ 18 */
43 final AnalysisServer server; 19 final AnalysisServer server;
44 20
45 /** 21 /**
46 * 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 ].
47 */ 23 */
48 ServerDomainHandler(this.server); 24 ServerDomainHandler(this.server);
49 25
50 @override 26 @override
51 Response handleRequest(Request request) { 27 Response handleRequest(Request request) {
52 try { 28 try {
53 String requestName = request.method; 29 String requestName = request.method;
54 if (requestName == GET_VERSION_METHOD) { 30 if (requestName == METHOD_GET_VERSION) {
55 return getVersion(request); 31 return getVersion(request);
56 } else if (requestName == SET_SUBSCRIPTIONS_METHOD) { 32 } else if (requestName == METHOD_SET_SUBSCRIPTIONS) {
57 return setSubscriptions(request); 33 return setSubscriptions(request);
58 } else if (requestName == SHUTDOWN_METHOD) { 34 } else if (requestName == METHOD_SHUTDOWN) {
59 return shutdown(request); 35 return shutdown(request);
60 } 36 }
61 } on RequestFailure catch (exception) { 37 } on RequestFailure catch (exception) {
62 return exception.response; 38 return exception.response;
63 } 39 }
64 return null; 40 return null;
65 } 41 }
66 42
67 /** 43 /**
68 * Subscribe for services. 44 * Subscribe for services.
69 * 45 *
70 * All previous subscriptions are replaced by the given set of subscriptions. 46 * All previous subscriptions are replaced by the given set of subscriptions.
71 */ 47 */
72 Response setSubscriptions(Request request) { 48 Response setSubscriptions(Request request) {
73 RequestDatum subDatum = request.getRequiredParameter(SUBSCRIPTIONS_PARAMETER ); 49 RequestDatum subDatum = request.getRequiredParameter(SUBSCRIPTIONS);
74 server.serverServices = subDatum.asEnumSet(ServerService.VALUES); 50 server.serverServices = subDatum.asEnumSet(ServerService.VALUES);
75 return new Response(request.id); 51 return new Response(request.id);
76 } 52 }
77 53
78 // TODO(scheglov) remove or move to the 'analysis' domain 54 // TODO(scheglov) remove or move to the 'analysis' domain
79 // /** 55 // /**
80 // * Create a new context in which analysis can be performed. The context that 56 // * Create a new context in which analysis can be performed. The context that
81 // * is created will persist until server.deleteContext is used to delete it. 57 // * is created will persist until server.deleteContext is used to delete it.
82 // * Clients, therefore, are responsible for managing the lifetime of contexts . 58 // * Clients, therefore, are responsible for managing the lifetime of contexts .
83 // */ 59 // */
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 server.running = false; 111 server.running = false;
136 Response response = new Response(request.id); 112 Response response = new Response(request.id);
137 return response; 113 return response;
138 } 114 }
139 115
140 /** 116 /**
141 * Return the version number of the analysis server. 117 * Return the version number of the analysis server.
142 */ 118 */
143 Response getVersion(Request request) { 119 Response getVersion(Request request) {
144 Response response = new Response(request.id); 120 Response response = new Response(request.id);
145 response.setResult(VERSION_RESULT, '0.0.1'); 121 response.setResult(VERSION, '0.0.1');
146 return response; 122 return response;
147 } 123 }
148 } 124 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/domain_context.dart ('k') | pkg/analysis_server/test/analysis_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698