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

Side by Side Diff: pkg/analysis_server/lib/src/services/refactoring/extract_method.dart

Issue 580273002: Push add*Edit helpers into SourceChange. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 services.src.refactoring.extract_method; 5 library services.src.refactoring.extract_method;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart' hide Element; 9 import 'package:analysis_server/src/protocol.dart' hide Element;
10 import 'package:analysis_server/src/services/correction/name_suggestion.dart'; 10 import 'package:analysis_server/src/services/correction/name_suggestion.dart';
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 sb.write(')'); 269 sb.write(')');
270 } 270 }
271 invocationSource = sb.toString(); 271 invocationSource = sb.toString();
272 // statements as extracted with their ";", so add new after invocation 272 // statements as extracted with their ";", so add new after invocation
273 if (_selectionStatements != null) { 273 if (_selectionStatements != null) {
274 invocationSource += ';'; 274 invocationSource += ';';
275 } 275 }
276 } 276 }
277 // add replace edit 277 // add replace edit
278 SourceEdit edit = new SourceEdit.range(range, invocationSource); 278 SourceEdit edit = new SourceEdit.range(range, invocationSource);
279 addElementSourceChange(change, unitElement, edit); 279 change.addElementEdit(unitElement, edit);
280 } 280 }
281 // add method declaration 281 // add method declaration
282 { 282 {
283 // prepare environment 283 // prepare environment
284 String prefix = utils.getNodePrefix(_parentMember); 284 String prefix = utils.getNodePrefix(_parentMember);
285 String eol = utils.endOfLine; 285 String eol = utils.endOfLine;
286 // prepare annotations 286 // prepare annotations
287 String annotations = ''; 287 String annotations = '';
288 { 288 {
289 // may be "static" 289 // may be "static"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 '${prefix} return ${_returnVariableName};$eol'; 326 '${prefix} return ${_returnVariableName};$eol';
327 } 327 }
328 declarationSource += '${prefix}}'; 328 declarationSource += '${prefix}}';
329 } 329 }
330 } 330 }
331 // insert declaration 331 // insert declaration
332 if (declarationSource != null) { 332 if (declarationSource != null) {
333 int offset = _parentMember.end; 333 int offset = _parentMember.end;
334 SourceEdit edit = 334 SourceEdit edit =
335 new SourceEdit(offset, 0, '${eol}${eol}${prefix}${declarationSource} '); 335 new SourceEdit(offset, 0, '${eol}${eol}${prefix}${declarationSource} ');
336 addElementSourceChange(change, unitElement, edit); 336 change.addElementEdit(unitElement, edit);
337 } 337 }
338 } 338 }
339 // done 339 // done
340 return new Future.value(change); 340 return new Future.value(change);
341 } 341 }
342 342
343 @override 343 @override
344 bool requiresPreview() => false; 344 bool requiresPreview() => false;
345 345
346 /** 346 /**
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 1098
1099 /** 1099 /**
1100 * Generalized version of some source, in which references to the specific 1100 * Generalized version of some source, in which references to the specific
1101 * variables are replaced with pattern variables, with back mapping from the 1101 * variables are replaced with pattern variables, with back mapping from the
1102 * pattern to the original variable names. 1102 * pattern to the original variable names.
1103 */ 1103 */
1104 class _SourcePattern { 1104 class _SourcePattern {
1105 String patternSource; 1105 String patternSource;
1106 Map<String, String> originalToPatternNames = {}; 1106 Map<String, String> originalToPatternNames = {};
1107 } 1107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698