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

Side by Side Diff: pkg/analysis_server/test/services/refactoring/extract_local_test.dart

Issue 619723002: Fix for 'Extract Local' refactoring - take into account local variable elements. (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
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/extract_local.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 test.services.refactoring.extract_local; 5 library test.services.refactoring.extract_local;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
10 import 'package:analysis_server/src/services/refactoring/extract_local.dart'; 10 import 'package:analysis_server/src/services/refactoring/extract_local.dart';
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 return _assertSuccessfulRefactoring(''' 589 return _assertSuccessfulRefactoring('''
590 int foo() => 42; 590 int foo() => 42;
591 main() { 591 main() {
592 var res = foo(); 592 var res = foo();
593 int a = 1 + res; 593 int a = 1 + res;
594 int b = 2 + res; // marker 594 int b = 2 + res; // marker
595 } 595 }
596 '''); 596 ''');
597 } 597 }
598 598
599 test_occurences_differentVariable() {
600 indexTestUnit('''
601 main() {
602 {
603 int v = 1;
604 print(v + 1); // marker
605 print(v + 1);
606 }
607 {
608 int v = 2;
609 print(v + 1);
610 }
611 }
612 ''');
613 _createRefactoringWithSuffix('v + 1', '); // marker');
614 // apply refactoring
615 return _assertSuccessfulRefactoring('''
616 main() {
617 {
618 int v = 1;
619 var res = v + 1;
620 print(res); // marker
621 print(res);
622 }
623 {
624 int v = 2;
625 print(v + 1);
626 }
627 }
628 ''');
629 }
630
599 test_occurences_useDominator() { 631 test_occurences_useDominator() {
600 indexTestUnit(''' 632 indexTestUnit('''
601 main() { 633 main() {
602 if (true) { 634 if (true) {
603 print(42); 635 print(42);
604 } else { 636 } else {
605 print(42); 637 print(42);
606 } 638 }
607 } 639 }
608 '''); 640 ''');
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 int length = search.length; 947 int length = search.length;
916 _createRefactoring(offset, length); 948 _createRefactoring(offset, length);
917 } 949 }
918 950
919 void _createRefactoringWithSuffix(String selectionSearch, String suffix) { 951 void _createRefactoringWithSuffix(String selectionSearch, String suffix) {
920 int offset = findOffset(selectionSearch + suffix); 952 int offset = findOffset(selectionSearch + suffix);
921 int length = selectionSearch.length; 953 int length = selectionSearch.length;
922 _createRefactoring(offset, length); 954 _createRefactoring(offset, length);
923 } 955 }
924 } 956 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/extract_local.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698