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

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

Issue 879463004: Fix for extracting local variable in if-else-if statements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 return _assertSuccessfulRefactoring(''' 761 return _assertSuccessfulRefactoring('''
762 main() { 762 main() {
763 print((x) { 763 print((x) {
764 var res = x.y; 764 var res = x.y;
765 return res * res + 1; 765 return res * res + 1;
766 }); 766 });
767 } 767 }
768 '''); 768 ''');
769 } 769 }
770 770
771 test_singleExpression_inIfElseIf() {
772 indexTestUnit('''
773 main(int p) {
774 if (p == 1) {
775 print(1);
776 } else if (p == 2) {
777 print(2);
778 }
779 }
780 ''');
781 _createRefactoringForString('2');
782 // apply refactoring
783 return _assertSuccessfulRefactoring('''
784 main(int p) {
785 var res = 2;
786 if (p == 1) {
787 print(1);
788 } else if (p == res) {
789 print(res);
790 }
791 }
792 ''');
793 }
794
771 test_singleExpression_inMethod() { 795 test_singleExpression_inMethod() {
772 indexTestUnit(''' 796 indexTestUnit('''
773 class A { 797 class A {
774 main() { 798 main() {
775 print(1 + 2); 799 print(1 + 2);
776 } 800 }
777 } 801 }
778 '''); 802 ''');
779 _createRefactoringForString('1 + 2'); 803 _createRefactoringForString('1 + 2');
780 // apply refactoring 804 // apply refactoring
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 int length = search.length; 991 int length = search.length;
968 _createRefactoring(offset, length); 992 _createRefactoring(offset, length);
969 } 993 }
970 994
971 void _createRefactoringWithSuffix(String selectionSearch, String suffix) { 995 void _createRefactoringWithSuffix(String selectionSearch, String suffix) {
972 int offset = findOffset(selectionSearch + suffix); 996 int offset = findOffset(selectionSearch + suffix);
973 int length = selectionSearch.length; 997 int length = selectionSearch.length;
974 _createRefactoring(offset, length); 998 _createRefactoring(offset, length);
975 } 999 }
976 } 1000 }
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