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 import 'package:analysis_server/src/services/correction/status.dart'; | 5 import 'package:analysis_server/src/services/correction/status.dart'; |
6 import 'package:analyzer/src/generated/source.dart'; | 6 import 'package:analyzer/src/generated/source.dart'; |
7 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | 7 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
8 import 'package:test/test.dart'; | 8 import 'package:test/test.dart'; |
9 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 9 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
10 | 10 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 RefactoringStatus status = await refactoring.checkFinalConditions(); | 125 RefactoringStatus status = await refactoring.checkFinalConditions(); |
126 assertRefactoringStatusOK(status); | 126 assertRefactoringStatusOK(status); |
127 } | 127 } |
128 | 128 |
129 test_checkFinalConditions_publicToPrivate_usedInOtherLibrary() async { | 129 test_checkFinalConditions_publicToPrivate_usedInOtherLibrary() async { |
130 await indexTestUnit(''' | 130 await indexTestUnit(''' |
131 class A { | 131 class A { |
132 test() {} | 132 test() {} |
133 } | 133 } |
134 '''); | 134 '''); |
135 await indexUnit( | 135 await indexUnit('/lib.dart', ''' |
136 '/lib.dart', | |
137 ''' | |
138 library my.lib; | 136 library my.lib; |
139 import 'test.dart'; | 137 import 'test.dart'; |
140 | 138 |
141 main(A a) { | 139 main(A a) { |
142 a.test(); | 140 a.test(); |
143 } | 141 } |
144 '''); | 142 '''); |
145 createRenameRefactoringAtString('test() {}'); | 143 createRenameRefactoringAtString('test() {}'); |
146 // check status | 144 // check status |
147 refactoring.newName = '_newName'; | 145 refactoring.newName = '_newName'; |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 a.newName(); // 1 | 684 a.newName(); // 1 |
687 new A().newName(); | 685 new A().newName(); |
688 a.newName(); // 2 | 686 a.newName(); // 2 |
689 } | 687 } |
690 '''); | 688 '''); |
691 assertPotentialEdits(['test(); // 1', 'test(); // 2']); | 689 assertPotentialEdits(['test(); // 1', 'test(); // 2']); |
692 } | 690 } |
693 | 691 |
694 test_createChange_MethodElement_potential_inPubCache() async { | 692 test_createChange_MethodElement_potential_inPubCache() async { |
695 String pkgLib = '/.pub-cache/lib.dart'; | 693 String pkgLib = '/.pub-cache/lib.dart'; |
696 await indexUnit( | 694 await indexUnit(pkgLib, r''' |
697 pkgLib, | |
698 r''' | |
699 processObj(p) { | 695 processObj(p) { |
700 p.test(); | 696 p.test(); |
701 } | 697 } |
702 '''); | 698 '''); |
703 await indexTestUnit(''' | 699 await indexTestUnit(''' |
704 import '$pkgLib'; | 700 import '$pkgLib'; |
705 class A { | 701 class A { |
706 test() {} | 702 test() {} |
707 } | 703 } |
708 main(var a) { | 704 main(var a) { |
(...skipping 13 matching lines...) Expand all Loading... |
722 } | 718 } |
723 main(var a) { | 719 main(var a) { |
724 a.newName(); | 720 a.newName(); |
725 } | 721 } |
726 '''); | 722 '''); |
727 SourceFileEdit fileEdit = refactoringChange.getFileEdit(pkgLib); | 723 SourceFileEdit fileEdit = refactoringChange.getFileEdit(pkgLib); |
728 expect(fileEdit, isNull); | 724 expect(fileEdit, isNull); |
729 } | 725 } |
730 | 726 |
731 test_createChange_MethodElement_potential_private_otherLibrary() async { | 727 test_createChange_MethodElement_potential_private_otherLibrary() async { |
732 await indexUnit( | 728 await indexUnit('/lib.dart', ''' |
733 '/lib.dart', | |
734 ''' | |
735 library lib; | 729 library lib; |
736 main(p) { | 730 main(p) { |
737 p._test(); | 731 p._test(); |
738 } | 732 } |
739 '''); | 733 '''); |
740 await indexTestUnit(''' | 734 await indexTestUnit(''' |
741 class A { | 735 class A { |
742 _test() {} | 736 _test() {} |
743 } | 737 } |
744 main(var a) { | 738 main(var a) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 // validate change | 885 // validate change |
892 return assertSuccessfulRefactoring(''' | 886 return assertSuccessfulRefactoring(''' |
893 class A<NewName> { | 887 class A<NewName> { |
894 NewName field; | 888 NewName field; |
895 List<NewName> items; | 889 List<NewName> items; |
896 NewName method(NewName p) => null; | 890 NewName method(NewName p) => null; |
897 } | 891 } |
898 '''); | 892 '''); |
899 } | 893 } |
900 } | 894 } |
OLD | NEW |