OLD | NEW |
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.rename_class_member; | 5 library test.services.refactoring.rename_class_member; |
6 | 6 |
7 import 'package:analysis_server/src/protocol.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
8 import 'package:analysis_server/src/services/correction/status.dart'; | 8 import 'package:analysis_server/src/services/correction/status.dart'; |
9 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 9 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 } | 575 } |
576 main(var a) { | 576 main(var a) { |
577 a.newName(); // 1 | 577 a.newName(); // 1 |
578 new A().newName(); | 578 new A().newName(); |
579 a.newName(); // 2 | 579 a.newName(); // 2 |
580 } | 580 } |
581 '''); | 581 '''); |
582 assertPotentialEdits(['test(); // 1', 'test(); // 2']); | 582 assertPotentialEdits(['test(); // 1', 'test(); // 2']); |
583 } | 583 } |
584 | 584 |
| 585 test_createChange_MethodElement_potential_inPubCache() async { |
| 586 String pkgLib = '/.pub-cache/lib.dart'; |
| 587 indexUnit( |
| 588 pkgLib, |
| 589 r''' |
| 590 processObj(p) { |
| 591 p.test(); |
| 592 } |
| 593 '''); |
| 594 indexTestUnit(''' |
| 595 import '$pkgLib'; |
| 596 class A { |
| 597 test() {} |
| 598 } |
| 599 main(var a) { |
| 600 a.test(); |
| 601 } |
| 602 '''); |
| 603 // configure refactoring |
| 604 createRenameRefactoringAtString('test() {}'); |
| 605 expect(refactoring.refactoringName, 'Rename Method'); |
| 606 expect(refactoring.oldName, 'test'); |
| 607 refactoring.newName = 'newName'; |
| 608 // validate change |
| 609 await assertSuccessfulRefactoring(''' |
| 610 import '/.pub-cache/lib.dart'; |
| 611 class A { |
| 612 newName() {} |
| 613 } |
| 614 main(var a) { |
| 615 a.newName(); |
| 616 } |
| 617 '''); |
| 618 SourceFileEdit fileEdit = refactoringChange.getFileEdit(pkgLib); |
| 619 expect(fileEdit, isNull); |
| 620 } |
| 621 |
585 test_createChange_MethodElement_potential_private_otherLibrary() async { | 622 test_createChange_MethodElement_potential_private_otherLibrary() async { |
586 indexUnit( | 623 indexUnit( |
587 '/lib.dart', | 624 '/lib.dart', |
588 ''' | 625 ''' |
589 library lib; | 626 library lib; |
590 main(p) { | 627 main(p) { |
591 p._test(); | 628 p._test(); |
592 } | 629 } |
593 '''); | 630 '''); |
594 indexTestUnit(''' | 631 indexTestUnit(''' |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 // validate change | 782 // validate change |
746 return assertSuccessfulRefactoring(''' | 783 return assertSuccessfulRefactoring(''' |
747 class A<NewName> { | 784 class A<NewName> { |
748 NewName field; | 785 NewName field; |
749 List<NewName> items; | 786 List<NewName> items; |
750 NewName method(NewName p) => null; | 787 NewName method(NewName p) => null; |
751 } | 788 } |
752 '''); | 789 '''); |
753 } | 790 } |
754 } | 791 } |
OLD | NEW |