| 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/protocol/protocol_generated.dart'; | 5 import 'package:analysis_server/protocol/protocol_generated.dart'; |
| 6 import 'package:analysis_server/src/services/correction/status.dart'; | 6 import 'package:analysis_server/src/services/correction/status.dart'; |
| 7 import 'package:analyzer/src/generated/source.dart'; | 7 import 'package:analyzer/src/generated/source.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 |
| 11 import 'abstract_rename.dart'; | 11 import 'abstract_rename.dart'; |
| 12 | 12 |
| 13 main() { | 13 main() { |
| 14 defineReflectiveSuite(() { | 14 defineReflectiveSuite(() { |
| 15 defineReflectiveTests(RenameClassMemberTest); | 15 defineReflectiveTests(RenameClassMemberTest); |
| 16 defineReflectiveTests(RenameClassMemberTest_Driver); | |
| 17 }); | 16 }); |
| 18 } | 17 } |
| 19 | 18 |
| 20 @reflectiveTest | 19 @reflectiveTest |
| 21 class RenameClassMemberTest extends RenameRefactoringTest { | 20 class RenameClassMemberTest extends RenameRefactoringTest { |
| 21 @override |
| 22 bool get enableNewAnalysisDriver => true; |
| 23 |
| 22 test_checkFinalConditions_classNameConflict_sameClass() async { | 24 test_checkFinalConditions_classNameConflict_sameClass() async { |
| 23 await indexTestUnit(''' | 25 await indexTestUnit(''' |
| 24 class NewName { | 26 class NewName { |
| 25 void test() {} | 27 void test() {} |
| 26 } | 28 } |
| 27 '''); | 29 '''); |
| 28 createRenameRefactoringAtString('test() {}'); | 30 createRenameRefactoringAtString('test() {}'); |
| 29 // check status | 31 // check status |
| 30 refactoring.newName = 'NewName'; | 32 refactoring.newName = 'NewName'; |
| 31 RefactoringStatus status = await refactoring.checkFinalConditions(); | 33 RefactoringStatus status = await refactoring.checkFinalConditions(); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 } | 146 } |
| 145 '''); | 147 '''); |
| 146 createRenameRefactoringAtString('test() {}'); | 148 createRenameRefactoringAtString('test() {}'); |
| 147 // check status | 149 // check status |
| 148 refactoring.newName = '_newName'; | 150 refactoring.newName = '_newName'; |
| 149 RefactoringStatus status = await refactoring.checkFinalConditions(); | 151 RefactoringStatus status = await refactoring.checkFinalConditions(); |
| 150 assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR, | 152 assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR, |
| 151 expectedMessage: "Renamed method will be invisible in 'my.lib'."); | 153 expectedMessage: "Renamed method will be invisible in 'my.lib'."); |
| 152 } | 154 } |
| 153 | 155 |
| 156 @failingTest |
| 154 test_checkFinalConditions_shadowed_byLocalFunction_inSameClass() async { | 157 test_checkFinalConditions_shadowed_byLocalFunction_inSameClass() async { |
| 155 await indexTestUnit(''' | 158 await indexTestUnit(''' |
| 156 class A { | 159 class A { |
| 157 test() {} | 160 test() {} |
| 158 main() { | 161 main() { |
| 159 newName() {} | 162 newName() {} |
| 160 test(); // marker | 163 test(); // marker |
| 161 } | 164 } |
| 162 } | 165 } |
| 163 '''); | 166 '''); |
| 164 createRenameRefactoringAtString('test() {}'); | 167 createRenameRefactoringAtString('test() {}'); |
| 165 // check status | 168 // check status |
| 166 refactoring.newName = 'newName'; | 169 refactoring.newName = 'newName'; |
| 167 RefactoringStatus status = await refactoring.checkFinalConditions(); | 170 RefactoringStatus status = await refactoring.checkFinalConditions(); |
| 168 assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR, | 171 assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR, |
| 169 expectedMessage: | 172 expectedMessage: |
| 170 "Usage of renamed method will be shadowed by function 'newName'.", | 173 "Usage of renamed method will be shadowed by function 'newName'.", |
| 171 expectedContextSearch: 'test(); // marker'); | 174 expectedContextSearch: 'test(); // marker'); |
| 172 } | 175 } |
| 173 | 176 |
| 177 @failingTest |
| 174 test_checkFinalConditions_shadowed_byLocalVariable_inSameClass() async { | 178 test_checkFinalConditions_shadowed_byLocalVariable_inSameClass() async { |
| 175 await indexTestUnit(''' | 179 await indexTestUnit(''' |
| 176 class A { | 180 class A { |
| 177 test() {} | 181 test() {} |
| 178 main() { | 182 main() { |
| 179 var newName; | 183 var newName; |
| 180 test(); // marker | 184 test(); // marker |
| 181 } | 185 } |
| 182 } | 186 } |
| 183 '''); | 187 '''); |
| 184 createRenameRefactoringAtString('test() {}'); | 188 createRenameRefactoringAtString('test() {}'); |
| 185 // check status | 189 // check status |
| 186 refactoring.newName = 'newName'; | 190 refactoring.newName = 'newName'; |
| 187 RefactoringStatus status = await refactoring.checkFinalConditions(); | 191 RefactoringStatus status = await refactoring.checkFinalConditions(); |
| 188 assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR, | 192 assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR, |
| 189 expectedMessage: | 193 expectedMessage: |
| 190 "Usage of renamed method will be shadowed by local variable 'newName
'.", | 194 "Usage of renamed method will be shadowed by local variable 'newName
'.", |
| 191 expectedContextSearch: 'test(); // marker'); | 195 expectedContextSearch: 'test(); // marker'); |
| 192 } | 196 } |
| 193 | 197 |
| 198 @failingTest |
| 194 test_checkFinalConditions_shadowed_byLocalVariable_inSubClass() async { | 199 test_checkFinalConditions_shadowed_byLocalVariable_inSubClass() async { |
| 195 await indexTestUnit(''' | 200 await indexTestUnit(''' |
| 196 class A { | 201 class A { |
| 197 test() {} | 202 test() {} |
| 198 } | 203 } |
| 199 class B extends A { | 204 class B extends A { |
| 200 main() { | 205 main() { |
| 201 var newName; | 206 var newName; |
| 202 test(); // marker | 207 test(); // marker |
| 203 } | 208 } |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 // validate change | 897 // validate change |
| 893 return assertSuccessfulRefactoring(''' | 898 return assertSuccessfulRefactoring(''' |
| 894 class A<NewName> { | 899 class A<NewName> { |
| 895 NewName field; | 900 NewName field; |
| 896 List<NewName> items; | 901 List<NewName> items; |
| 897 NewName method(NewName p) => null; | 902 NewName method(NewName p) => null; |
| 898 } | 903 } |
| 899 '''); | 904 '''); |
| 900 } | 905 } |
| 901 } | 906 } |
| 902 | |
| 903 @reflectiveTest | |
| 904 class RenameClassMemberTest_Driver extends RenameClassMemberTest { | |
| 905 @override | |
| 906 bool get enableNewAnalysisDriver => true; | |
| 907 | |
| 908 @failingTest | |
| 909 @override | |
| 910 test_checkFinalConditions_shadowed_byLocalFunction_inSameClass() { | |
| 911 return super | |
| 912 .test_checkFinalConditions_shadowed_byLocalFunction_inSameClass(); | |
| 913 } | |
| 914 | |
| 915 @failingTest | |
| 916 @override | |
| 917 test_checkFinalConditions_shadowed_byLocalVariable_inSameClass() { | |
| 918 return super | |
| 919 .test_checkFinalConditions_shadowed_byLocalVariable_inSameClass(); | |
| 920 } | |
| 921 | |
| 922 @failingTest | |
| 923 @override | |
| 924 test_checkFinalConditions_shadowed_byLocalVariable_inSubClass() { | |
| 925 return super | |
| 926 .test_checkFinalConditions_shadowed_byLocalVariable_inSubClass(); | |
| 927 } | |
| 928 } | |
| OLD | NEW |