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

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

Issue 628293004: Remove references to Engine classes from protocol.dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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_server.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';
11 import 'package:analysis_server/src/services/correction/selection_analyzer.dart' ; 11 import 'package:analysis_server/src/services/correction/selection_analyzer.dart' ;
12 import 'package:analysis_server/src/services/correction/source_range.dart'; 12 import 'package:analysis_server/src/services/correction/source_range.dart';
13 import 'package:analysis_server/src/services/correction/statement_analyzer.dart' ; 13 import 'package:analysis_server/src/services/correction/statement_analyzer.dart' ;
14 import 'package:analysis_server/src/services/correction/status.dart'; 14 import 'package:analysis_server/src/services/correction/status.dart';
15 import 'package:analysis_server/src/services/correction/util.dart'; 15 import 'package:analysis_server/src/services/correction/util.dart';
16 import 'package:analysis_server/src/services/refactoring/naming_conventions.dart '; 16 import 'package:analysis_server/src/services/refactoring/naming_conventions.dart ';
17 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; 17 import 'package:analysis_server/src/services/refactoring/refactoring.dart';
18 import 'package:analysis_server/src/services/refactoring/refactoring_internal.da rt'; 18 import 'package:analysis_server/src/services/refactoring/refactoring_internal.da rt';
19 import 'package:analysis_server/src/services/refactoring/rename_class_member.dar t'; 19 import 'package:analysis_server/src/services/refactoring/rename_class_member.dar t';
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 268 }
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 = newSourceEdit_range(range, invocationSource);
279 change.addElementEdit(unitElement, edit); 279 doSourceChange_addElementEdit(change, 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 change.addElementEdit(unitElement, edit); 336 doSourceChange_addElementEdit(change, 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 'Extend selection to a valid range.'); 723 'Extend selection to a valid range.');
724 } 724 }
725 725
726 @override 726 @override
727 Object visitAssignmentExpression(AssignmentExpression node) { 727 Object visitAssignmentExpression(AssignmentExpression node) {
728 super.visitAssignmentExpression(node); 728 super.visitAssignmentExpression(node);
729 Expression lhs = node.leftHandSide; 729 Expression lhs = node.leftHandSide;
730 if (_isFirstSelectedNode(lhs)) { 730 if (_isFirstSelectedNode(lhs)) {
731 invalidSelection( 731 invalidSelection(
732 'Cannot extract the left-hand side of an assignment.', 732 'Cannot extract the left-hand side of an assignment.',
733 new Location.fromNode(lhs)); 733 newLocation_fromNode(lhs));
734 } 734 }
735 return null; 735 return null;
736 } 736 }
737 737
738 @override 738 @override
739 Object visitConstructorInitializer(ConstructorInitializer node) { 739 Object visitConstructorInitializer(ConstructorInitializer node) {
740 super.visitConstructorInitializer(node); 740 super.visitConstructorInitializer(node);
741 if (_isFirstSelectedNode(node)) { 741 if (_isFirstSelectedNode(node)) {
742 invalidSelection( 742 invalidSelection(
743 'Cannot extract a constructor initializer. ' 743 'Cannot extract a constructor initializer. '
744 'Select expression part of initializer.', 744 'Select expression part of initializer.',
745 new Location.fromNode(node)); 745 newLocation_fromNode(node));
746 } 746 }
747 return null; 747 return null;
748 } 748 }
749 749
750 @override 750 @override
751 Object visitForStatement(ForStatement node) { 751 Object visitForStatement(ForStatement node) {
752 super.visitForStatement(node); 752 super.visitForStatement(node);
753 if (identical(node.variables, firstSelectedNode)) { 753 if (identical(node.variables, firstSelectedNode)) {
754 invalidSelection( 754 invalidSelection(
755 "Cannot extract initialization part of a 'for' statement."); 755 "Cannot extract initialization part of a 'for' statement.");
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 return null; 790 return null;
791 } 791 }
792 792
793 @override 793 @override
794 Object visitVariableDeclaration(VariableDeclaration node) { 794 Object visitVariableDeclaration(VariableDeclaration node) {
795 super.visitVariableDeclaration(node); 795 super.visitVariableDeclaration(node);
796 if (_isFirstSelectedNode(node)) { 796 if (_isFirstSelectedNode(node)) {
797 invalidSelection( 797 invalidSelection(
798 'Cannot extract a variable declaration fragment. ' 798 'Cannot extract a variable declaration fragment. '
799 'Select whole declaration statement.', 799 'Select whole declaration statement.',
800 new Location.fromNode(node)); 800 newLocation_fromNode(node));
801 } 801 }
802 return null; 802 return null;
803 } 803 }
804 804
805 void _checkParent(AstNode node) { 805 void _checkParent(AstNode node) {
806 AstNode firstParent = firstSelectedNode.parent; 806 AstNode firstParent = firstSelectedNode.parent;
807 do { 807 do {
808 node = node.parent; 808 node = node.parent;
809 if (identical(node, firstParent)) { 809 if (identical(node, firstParent)) {
810 return; 810 return;
(...skipping 287 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