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

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

Issue 449213002: Rework "analysis.updateContent" analysis server request. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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.analysis; 5 library domain.analysis;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analysis_server/src/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/computer/computer_hover.dart'; 10 import 'package:analysis_server/src/computer/computer_hover.dart';
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 server.setAnalysisSubscriptions(subMap); 164 server.setAnalysisSubscriptions(subMap);
165 return new Response(request.id); 165 return new Response(request.id);
166 } 166 }
167 167
168 /** 168 /**
169 * Implement the 'analysis.updateContent' request. 169 * Implement the 'analysis.updateContent' request.
170 */ 170 */
171 Response updateContent(Request request) { 171 Response updateContent(Request request) {
172 var changes = new HashMap<String, ContentChange>(); 172 var changes = new HashMap<String, ContentChange>();
173 RequestDatum filesDatum = request.getRequiredParameter(FILES); 173 RequestDatum filesDatum = request.getRequiredParameter(FILES);
174 Response errorResponse;
174 filesDatum.forEachMap((file, changeDatum) { 175 filesDatum.forEachMap((file, changeDatum) {
175 var change = new ContentChange(); 176 ContentChange change = new ContentChange();
176 change.content = changeDatum[CONTENT].isNull ? 177 switch (changeDatum[TYPE].asString()) {
177 null : 178 case 'add':
178 changeDatum[CONTENT].asString(); 179 change.content = changeDatum[CONTENT].asString();
179 if (changeDatum.hasKey(OFFSET)) { 180 break;
180 change.offset = changeDatum[OFFSET].asInt(); 181 case 'change':
181 change.oldLength = changeDatum[OLD_LENGTH].asInt(); 182 change.offset = changeDatum[OFFSET].asInt();
182 change.newLength = changeDatum[NEW_LENGTH].asInt(); 183 change.oldLength = changeDatum[OLD_LENGTH].asInt();
184 change.content = changeDatum[REPLACEMENT].asString();
185 break;
186 case 'remove':
187 break;
188 default:
189 errorResponse = new Response.invalidParameter(request,
190 changeDatum[TYPE].path, 'be one of "add", "change", or "remove"');
191 return;
Brian Wilkerson 2014/08/07 22:15:22 I think we want to return the errorResponse at thi
Paul Berry 2014/08/07 23:58:09 Unfortunately, that doesn't work, because we are i
Brian Wilkerson 2014/08/08 00:14:58 What I want is non-local returns. What I need is
183 } 192 }
184 changes[file] = change; 193 changes[file] = change;
185 }); 194 });
195 if (errorResponse != null) {
Brian Wilkerson 2014/08/07 22:15:22 In which case errorResponse will never be non-null
196 return errorResponse;
197 }
186 server.updateContent(changes); 198 server.updateContent(changes);
187 return new Response(request.id); 199 return new Response(request.id);
188 } 200 }
189 201
190 /** 202 /**
191 * Implement the 'analysis.updateOptions' request. 203 * Implement the 'analysis.updateOptions' request.
192 */ 204 */
193 Response updateOptions(Request request) { 205 Response updateOptions(Request request) {
194 // options 206 // options
195 RequestDatum optionsDatum = request.getRequiredParameter(OPTIONS); 207 RequestDatum optionsDatum = request.getRequiredParameter(OPTIONS);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 server.updateOptions(updaters); 252 server.updateOptions(updaters);
241 return new Response(request.id); 253 return new Response(request.id);
242 } 254 }
243 } 255 }
244 256
245 257
246 /** 258 /**
247 * A description of the change to the content of a file. 259 * A description of the change to the content of a file.
248 */ 260 */
249 class ContentChange { 261 class ContentChange {
250 String content; 262 String content;
Brian Wilkerson 2014/08/07 22:15:22 Perhaps change 'content' to 'replacement'?
Paul Berry 2014/08/07 23:58:09 I'm not sure that would be an improvement, because
Brian Wilkerson 2014/08/08 00:14:58 A bit wordy, but I would have understood what the
251 int offset; 263 int offset;
252 int oldLength; 264 int oldLength;
Brian Wilkerson 2014/08/07 22:15:22 Perhaps rename 'oldLength' to 'length'?
Paul Berry 2014/08/07 23:58:09 Done.
253 int newLength;
254 } 265 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698