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

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

Issue 139983004: Server code clean-up (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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.context; 5 library domain.context;
6 6
7 import 'package:analysis_server/src/analysis_server.dart';
8 import 'package:analysis_server/src/protocol.dart';
7 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
8 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
9 11
10 import 'analysis_server.dart';
11 import 'protocol.dart';
12
13 /** 12 /**
14 * Instances of the class [ContextDomainHandler] implement a [RequestHandler] 13 * Instances of the class [ContextDomainHandler] implement a [RequestHandler]
15 * that handles requests in the context domain. 14 * that handles requests in the context domain.
16 */ 15 */
17 class ContextDomainHandler implements RequestHandler { 16 class ContextDomainHandler implements RequestHandler {
18 /** 17 /**
19 * The name of the context.applyChanges request. 18 * The name of the context.applyChanges request.
20 */ 19 */
21 static const String APPLY_CHANGES_NAME = 'context.applyChanges'; 20 static const String APPLY_CHANGES_NAME = 'context.applyChanges';
22 21
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 * Inform the specified context that the changes encoded in the change set 110 * Inform the specified context that the changes encoded in the change set
112 * have been made. Any invalidated analysis results will be flushed from the 111 * have been made. Any invalidated analysis results will be flushed from the
113 * context. 112 * context.
114 */ 113 */
115 Response applyChanges(Request request) { 114 Response applyChanges(Request request) {
116 AnalysisContext context = getAnalysisContext(request); 115 AnalysisContext context = getAnalysisContext(request);
117 Map<String, Object> changesData = request.getRequiredParameter(CHANGES_PARAM ); 116 Map<String, Object> changesData = request.getRequiredParameter(CHANGES_PARAM );
118 ChangeSet changeSet = createChangeSet(changesData); 117 ChangeSet changeSet = createChangeSet(changesData);
119 118
120 context.applyChanges(changeSet); 119 context.applyChanges(changeSet);
120 Response response = new Response(request.id);
121 return response;
121 } 122 }
122 123
123 /** 124 /**
124 * Convert the given JSON object into a [ChangeSet]. 125 * Convert the given JSON object into a [ChangeSet].
125 */ 126 */
126 ChangeSet createChangeSet(Map<String, Object> jsonData) { 127 ChangeSet createChangeSet(Map<String, Object> jsonData) {
127 // TODO(brianwilkerson) Implement this. 128 // TODO(brianwilkerson) Implement this.
128 return null; 129 return null;
129 } 130 }
130 131
131 /** 132 /**
132 * Set the options controlling analysis within a context to the given set of 133 * Set the options controlling analysis within a context to the given set of
133 * options. 134 * options.
134 */ 135 */
135 Response setOptions(Request request) { 136 Response setOptions(Request request) {
136 AnalysisContext context = getAnalysisContext(request); 137 AnalysisContext context = getAnalysisContext(request);
137 138
138 context.analysisOptions = createAnalysisOptions(request); 139 context.analysisOptions = createAnalysisOptions(request);
140 Response response = new Response(request.id);
141 return response;
139 } 142 }
140 143
141 /** 144 /**
142 * Return the set of analysis options associated with the given [request], or 145 * Return the set of analysis options associated with the given [request], or
143 * throw a [RequestFailure] exception if the analysis options are not valid. 146 * throw a [RequestFailure] exception if the analysis options are not valid.
144 */ 147 */
145 AnalysisOptions createAnalysisOptions(Request request) { 148 AnalysisOptions createAnalysisOptions(Request request) {
146 Map<String, Object> optionsData = request.getRequiredParameter(OPTIONS_PARAM ); 149 Map<String, Object> optionsData = request.getRequiredParameter(OPTIONS_PARAM );
147 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); 150 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
148 optionsData.forEach((String key, Object value) { 151 optionsData.forEach((String key, Object value) {
(...skipping 19 matching lines...) Expand all
168 /** 171 /**
169 * Set the priority sources in the specified context to the sources in the 172 * Set the priority sources in the specified context to the sources in the
170 * given array. 173 * given array.
171 */ 174 */
172 Response setPrioritySources(Request request) { 175 Response setPrioritySources(Request request) {
173 AnalysisContext context = getAnalysisContext(request); 176 AnalysisContext context = getAnalysisContext(request);
174 List<String> sourcesData = request.getRequiredParameter(SOURCES_PARAM); 177 List<String> sourcesData = request.getRequiredParameter(SOURCES_PARAM);
175 List<Source> sources = convertToSources(context.sourceFactory, sourcesData); 178 List<Source> sources = convertToSources(context.sourceFactory, sourcesData);
176 179
177 context.analysisPriorityOrder = sources; 180 context.analysisPriorityOrder = sources;
181 Response response = new Response(request.id);
182 return response;
178 } 183 }
179 184
180 /** 185 /**
181 * Convert the given list of strings into a list of sources owned by the given 186 * Convert the given list of strings into a list of sources owned by the given
182 * [sourceFactory]. 187 * [sourceFactory].
183 */ 188 */
184 List<Source> convertToSources(SourceFactory sourceFactory, List<String> source sData) { 189 List<Source> convertToSources(SourceFactory sourceFactory, List<String> source sData) {
185 List<Source> sources = new List<Source>(); 190 List<Source> sources = new List<Source>();
186 sourcesData.forEach((String string) { 191 sourcesData.forEach((String string) {
187 sources.add(sourceFactory.fromEncoding(string)); 192 sources.add(sourceFactory.fromEncoding(string));
188 }); 193 });
189 return sources; 194 return sources;
190 } 195 }
191 196
192 /** 197 /**
193 * Return the analysis context specified by the given request, or throw a 198 * Return the analysis context specified by the given request, or throw a
194 * [RequestFailure] exception if either there is no specified context or if 199 * [RequestFailure] exception if either there is no specified context or if
195 * the specified context does not exist. 200 * the specified context does not exist.
196 */ 201 */
197 AnalysisContext getAnalysisContext(Request request) { 202 AnalysisContext getAnalysisContext(Request request) {
198 String contextId = request.getRequiredParameter(CONTEXT_ID_PARAM); 203 String contextId = request.getRequiredParameter(CONTEXT_ID_PARAM);
199 AnalysisContext context = server.contextMap[contextId]; 204 AnalysisContext context = server.contextMap[contextId];
200 if (context == null) { 205 if (context == null) {
201 throw new RequestFailure(new Response.contextDoesNotExist(request)); 206 throw new RequestFailure(new Response.contextDoesNotExist(request));
202 } 207 }
203 return context; 208 return context;
204 } 209 }
205 } 210 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/channel.dart ('k') | pkg/analysis_server/lib/src/domain_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698