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

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

Issue 472613002: Update analysis server and integration tests to match new ChangeContentOverlay. (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';
11 import 'package:analysis_server/src/computer/error.dart'; 11 import 'package:analysis_server/src/computer/error.dart';
12 import 'package:analysis_server/src/constants.dart'; 12 import 'package:analysis_server/src/constants.dart';
13 import 'package:analysis_server/src/protocol.dart'; 13 import 'package:analysis_server/src/protocol.dart';
14 import 'package:analysis_services/constants.dart'; 14 import 'package:analysis_services/constants.dart';
15 import 'package:analysis_services/correction/change.dart';
15 import 'package:analyzer/src/generated/ast.dart'; 16 import 'package:analyzer/src/generated/ast.dart';
16 import 'package:analyzer/src/generated/engine.dart'; 17 import 'package:analyzer/src/generated/engine.dart';
17 18
18 19
19 /** 20 /**
20 * Instances of the class [AnalysisDomainHandler] implement a [RequestHandler] 21 * Instances of the class [AnalysisDomainHandler] implement a [RequestHandler]
21 * that handles requests in the `analysis` domain. 22 * that handles requests in the `analysis` domain.
22 */ 23 */
23 class AnalysisDomainHandler implements RequestHandler { 24 class AnalysisDomainHandler implements RequestHandler {
24 /** 25 /**
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 160
160 /** 161 /**
161 * Implement the 'analysis.updateContent' request. 162 * Implement the 'analysis.updateContent' request.
162 */ 163 */
163 Response updateContent(Request request) { 164 Response updateContent(Request request) {
164 var changes = new HashMap<String, ContentChange>(); 165 var changes = new HashMap<String, ContentChange>();
165 RequestDatum filesDatum = request.getRequiredParameter(FILES); 166 RequestDatum filesDatum = request.getRequiredParameter(FILES);
166 for (String file in filesDatum.keys) { 167 for (String file in filesDatum.keys) {
167 RequestDatum changeDatum = filesDatum[file]; 168 RequestDatum changeDatum = filesDatum[file];
168 ContentChange change = new ContentChange(); 169 ContentChange change = new ContentChange();
169 switch (changeDatum[TYPE].asString()) { 170 change.type = changeDatum[TYPE].asString();
171 switch (change.type) {
170 case ADD: 172 case ADD:
171 change.contentOrReplacement = changeDatum[CONTENT].asString(); 173 change.content = changeDatum[CONTENT].asString();
172 break; 174 break;
173 case CHANGE: 175 case CHANGE:
174 change.offset = changeDatum[OFFSET].asInt(); 176 change.changes = changeDatum[EDITS].asList((RequestDatum item) {
175 change.length = changeDatum[LENGTH].asInt(); 177 int offset = item[OFFSET].asInt();
176 change.contentOrReplacement = changeDatum[REPLACEMENT].asString(); 178 int length = item[LENGTH].asInt();
179 String replacement = item[REPLACEMENT].asString();
180 return new Edit(offset, length, replacement);
181 });
177 break; 182 break;
178 case REMOVE: 183 case REMOVE:
179 break; 184 break;
180 default: 185 default:
181 return new Response.invalidParameter( 186 return new Response.invalidParameter(
182 request, 187 request,
183 changeDatum[TYPE].path, 188 changeDatum[TYPE].path,
184 'be one of "add", "change", or "remove"'); 189 'be one of "add", "change", or "remove"');
185 } 190 }
186 changes[file] = change; 191 changes[file] = change;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 return new Response(request.id); 248 return new Response(request.id);
244 } 249 }
245 } 250 }
246 251
247 252
248 /** 253 /**
249 * A description of the change to the content of a file. 254 * A description of the change to the content of a file.
250 */ 255 */
251 class ContentChange { 256 class ContentChange {
252 /** 257 /**
253 * If [offset] and [length] are null, the full content of the file (or null 258 * Type of content change. 'add' means that [content] contains the full
254 * if the file should be read from the filesystem). 259 * content of the file, and [changes] should be null. 'change' means that
255 * 260 * [changes] contains changes to be applied to the file, and [content] should
256 * If [offset] and [length] are non-null, the replacement text which should 261 * be null. 'remove' means that the file should be read from the filesystem,
257 * take the place of the [length] characters of the file starting at [offset]. 262 * and both [content] and [changes] should be null.
258 */ 263 */
259 String contentOrReplacement; 264 String type;
260 265
261 int offset; 266 String content;
262 int length; 267 List<Edit> changes;
263 } 268 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/test/domain_analysis_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698