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

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

Issue 1629533003: Issue 25404. 'Inline Method' should update implicit 'this' and class references. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/inline_method.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.inline_method; 5 library test.services.refactoring.inline_method;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/protocol/protocol.dart' hide Element; 9 import 'package:analysis_server/plugin/protocol/protocol.dart' hide Element;
10 import 'package:analysis_server/src/services/correction/status.dart'; 10 import 'package:analysis_server/src/services/correction/status.dart';
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 return _assertSuccessfulRefactoring(r''' 910 return _assertSuccessfulRefactoring(r'''
911 class A { 911 class A {
912 static var F = 1; 912 static var F = 1;
913 foo() { 913 foo() {
914 print(A.F); 914 print(A.F);
915 } 915 }
916 } 916 }
917 '''); 917 ''');
918 } 918 }
919 919
920 test_method_methodInstance() {
921 indexTestUnit(r'''
922 class A {
923 ma() {}
924 }
925 class B extends A {
926 test() {
927 ma();
928 mb();
929 }
930 mb() {}
931 }
932 main(B b) {
933 b.test();
934 }
935 ''');
936 _createRefactoring('test();');
937 // validate change
938 return _assertSuccessfulRefactoring(r'''
939 class A {
940 ma() {}
941 }
942 class B extends A {
943 test() {
944 ma();
945 mb();
946 }
947 mb() {}
948 }
949 main(B b) {
950 b.ma();
951 b.mb();
952 }
953 ''');
954 }
955
956 test_method_methodStatic() {
957 indexTestUnit(r'''
958 class A {
959 static ma() {}
960 }
961 class B extends A {
962 static mb() {}
963 test() {
964 mb();
965 A.ma();
966 B.mb();
967 }
968 }
969 main(B b) {
970 b.test();
971 }
972 ''');
973 _createRefactoring('test();');
974 // validate change
975 return _assertSuccessfulRefactoring(r'''
976 class A {
977 static ma() {}
978 }
979 class B extends A {
980 static mb() {}
981 test() {
982 mb();
983 A.ma();
984 B.mb();
985 }
986 }
987 main(B b) {
988 B.mb();
989 A.ma();
990 B.mb();
991 }
992 ''');
993 }
994
920 test_method_singleStatement() { 995 test_method_singleStatement() {
921 indexTestUnit(r''' 996 indexTestUnit(r'''
922 class A { 997 class A {
923 test() { 998 test() {
924 print(0); 999 print(0);
925 } 1000 }
926 foo() { 1001 foo() {
927 test(); 1002 test();
928 } 1003 }
929 } 1004 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 } 1041 }
967 main() { 1042 main() {
968 B b = new B(); 1043 B b = new B();
969 A a = new A(); 1044 A a = new A();
970 print(b); 1045 print(b);
971 a.accept(b); 1046 a.accept(b);
972 } 1047 }
973 '''); 1048 ''');
974 } 1049 }
975 1050
976 test_method_unqualifiedUnvocation() { 1051 test_method_unqualifiedInvocation() {
977 indexTestUnit(r''' 1052 indexTestUnit(r'''
978 class A { 1053 class A {
979 test(a, b) { 1054 test(a, b) {
980 print(a); 1055 print(a);
981 print(b); 1056 print(b);
982 return a + b; 1057 return a + b;
983 } 1058 }
984 foo() { 1059 foo() {
985 var v = test(1, 2); 1060 var v = test(1, 2);
986 } 1061 }
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 _createRefactoring('test(a, b)'); 1429 _createRefactoring('test(a, b)');
1355 // validate change 1430 // validate change
1356 return _assertSuccessfulRefactoring(r''' 1431 return _assertSuccessfulRefactoring(r'''
1357 main() { 1432 main() {
1358 var res1 = 1 * (2 + 3); 1433 var res1 = 1 * (2 + 3);
1359 var res2 = 1 * (2 + 3); 1434 var res2 = 1 * (2 + 3);
1360 } 1435 }
1361 '''); 1436 ''');
1362 } 1437 }
1363 1438
1364 test_singleExpression_wrapIntoParenthesized_bools() { 1439 test_singleExpression_wrapIntoParenthesized_bool() {
1365 indexTestUnit(r''' 1440 indexTestUnit(r'''
1366 test(bool a, bool b) { 1441 test(bool a, bool b) {
1367 return a || b; 1442 return a || b;
1368 } 1443 }
1369 main(bool p, bool p2, bool p3) { 1444 main(bool p, bool p2, bool p3) {
1370 var res1 = p && test(p2, p3); 1445 var res1 = p && test(p2, p3);
1371 var res2 = p || test(p2, p3); 1446 var res2 = p || test(p2, p3);
1372 } 1447 }
1373 '''); 1448 ''');
1374 _createRefactoring('test(bool a, bool b)'); 1449 _createRefactoring('test(bool a, bool b)');
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 SourceChange change = await refactoring.createChange(); 1490 SourceChange change = await refactoring.createChange();
1416 this.refactoringChange = change; 1491 this.refactoringChange = change;
1417 assertTestChangeResult(expectedCode); 1492 assertTestChangeResult(expectedCode);
1418 } 1493 }
1419 1494
1420 void _createRefactoring(String search) { 1495 void _createRefactoring(String search) {
1421 int offset = findOffset(search); 1496 int offset = findOffset(search);
1422 refactoring = new InlineMethodRefactoring(searchEngine, testUnit, offset); 1497 refactoring = new InlineMethodRefactoring(searchEngine, testUnit, offset);
1423 } 1498 }
1424 } 1499 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/inline_method.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698