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

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

Issue 284103005: move context id constant to AnalysisServer (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 7 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/protocol.dart'; 8 import 'package:analysis_server/src/protocol.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/java_io.dart'; 10 import 'package:analyzer/src/generated/java_io.dart';
(...skipping 20 matching lines...) Expand all
31 * The name of the server.shutdown request. 31 * The name of the server.shutdown request.
32 */ 32 */
33 static const String SHUTDOWN_METHOD = 'server.shutdown'; 33 static const String SHUTDOWN_METHOD = 'server.shutdown';
34 34
35 /** 35 /**
36 * The name of the server.version request. 36 * The name of the server.version request.
37 */ 37 */
38 static const String VERSION_METHOD = 'server.version'; 38 static const String VERSION_METHOD = 'server.version';
39 39
40 /** 40 /**
41 * The name of the contextId parameter.
42 */
43 static const String CONTEXT_ID_PARAM = 'contextId';
44
45 /**
46 * The name of the packageMap parameter. 41 * The name of the packageMap parameter.
47 */ 42 */
48 static const String PACKAGE_MAP_PARAM = 'packageMap'; 43 static const String PACKAGE_MAP_PARAM = 'packageMap';
49 44
50 /** 45 /**
51 * The name of the sdkDirectory parameter. 46 * The name of the sdkDirectory parameter.
52 */ 47 */
53 static const String SDK_DIRECTORY_PARAM = 'sdkDirectory'; 48 static const String SDK_DIRECTORY_PARAM = 'sdkDirectory';
54 49
55 /** 50 /**
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 83
89 /** 84 /**
90 * Create a new context in which analysis can be performed. The context that 85 * Create a new context in which analysis can be performed. The context that
91 * is created will persist until server.deleteContext is used to delete it. 86 * is created will persist until server.deleteContext is used to delete it.
92 * Clients, therefore, are responsible for managing the lifetime of contexts. 87 * Clients, therefore, are responsible for managing the lifetime of contexts.
93 */ 88 */
94 Response createContext(Request request) { 89 Response createContext(Request request) {
95 String sdkDirectory = request.getRequiredParameter(SDK_DIRECTORY_PARAM).asSt ring(); 90 String sdkDirectory = request.getRequiredParameter(SDK_DIRECTORY_PARAM).asSt ring();
96 Map<String, String> packageMap = request.getParameter(PACKAGE_MAP_PARAM, {}) .asStringMap(); 91 Map<String, String> packageMap = request.getParameter(PACKAGE_MAP_PARAM, {}) .asStringMap();
97 92
98 String contextId = request.getRequiredParameter(CONTEXT_ID_PARAM).asString() ; 93 String contextId = request.getRequiredParameter(AnalysisServer.CONTEXT_ID_PA RAM).asString();
99 if (server.contextMap.containsKey(contextId)) { 94 if (server.contextMap.containsKey(contextId)) {
100 return new Response.contextAlreadyExists(request); 95 return new Response.contextAlreadyExists(request);
101 } 96 }
102 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); 97 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext();
103 // TODO(brianwilkerson) Use the information from the request to set the 98 // TODO(brianwilkerson) Use the information from the request to set the
104 // source factory in the context. 99 // source factory in the context.
105 DirectoryBasedDartSdk sdk; 100 DirectoryBasedDartSdk sdk;
106 try { 101 try {
107 sdk = new DirectoryBasedDartSdk(new JavaFile(sdkDirectory)); 102 sdk = new DirectoryBasedDartSdk(new JavaFile(sdkDirectory));
108 } on Exception catch (e) { 103 } on Exception catch (e) {
(...skipping 10 matching lines...) Expand all
119 114
120 Response response = new Response(request.id); 115 Response response = new Response(request.id);
121 return response; 116 return response;
122 } 117 }
123 118
124 /** 119 /**
125 * Delete the context with the given id. Future attempts to use the context id 120 * Delete the context with the given id. Future attempts to use the context id
126 * will result in an error being returned. 121 * will result in an error being returned.
127 */ 122 */
128 Response deleteContext(Request request) { 123 Response deleteContext(Request request) {
129 String contextId = request.getRequiredParameter(CONTEXT_ID_PARAM).asString() ; 124 String contextId = request.getRequiredParameter(AnalysisServer.CONTEXT_ID_PA RAM).asString();
130 125
131 AnalysisContext removedContext = server.contextMap.remove(contextId); 126 AnalysisContext removedContext = server.contextMap.remove(contextId);
132 if (removedContext == null) { 127 if (removedContext == null) {
133 return new Response.contextDoesNotExist(request); 128 return new Response.contextDoesNotExist(request);
134 } 129 }
135 Response response = new Response(request.id); 130 Response response = new Response(request.id);
136 return response; 131 return response;
137 } 132 }
138 133
139 /** 134 /**
140 * Cleanly shutdown the analysis server. 135 * Cleanly shutdown the analysis server.
141 */ 136 */
142 Response shutdown(Request request) { 137 Response shutdown(Request request) {
143 server.running = false; 138 server.running = false;
144 Response response = new Response(request.id); 139 Response response = new Response(request.id);
145 return response; 140 return response;
146 } 141 }
147 142
148 /** 143 /**
149 * Return the version number of the analysis server. 144 * Return the version number of the analysis server.
150 */ 145 */
151 Response version(Request request) { 146 Response version(Request request) {
152 Response response = new Response(request.id); 147 Response response = new Response(request.id);
153 response.setResult(VERSION_RESULT, '0.0.1'); 148 response.setResult(VERSION_RESULT, '0.0.1');
154 return response; 149 return response;
155 } 150 }
156 } 151 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.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