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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 createRenameRefactoringAtString('test() {}'); | 234 createRenameRefactoringAtString('test() {}'); |
235 // check status | 235 // check status |
236 refactoring.newName = 'newName'; | 236 refactoring.newName = 'newName'; |
237 RefactoringStatus status = await refactoring.checkFinalConditions(); | 237 RefactoringStatus status = await refactoring.checkFinalConditions(); |
238 assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR, | 238 assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR, |
239 expectedMessage: | 239 expectedMessage: |
240 "Renamed method will be shadowed by method 'B.newName'.", | 240 "Renamed method will be shadowed by method 'B.newName'.", |
241 expectedContextSearch: 'newName() {} // marker'); | 241 expectedContextSearch: 'newName() {} // marker'); |
242 } | 242 } |
243 | 243 |
| 244 test_checkInitialConditions_inSDK() async { |
| 245 indexTestUnit(''' |
| 246 main() { |
| 247 'abc'.toUpperCase(); |
| 248 } |
| 249 '''); |
| 250 createRenameRefactoringAtString('toUpperCase()'); |
| 251 // check status |
| 252 refactoring.newName = 'NewName'; |
| 253 RefactoringStatus status = await refactoring.checkInitialConditions(); |
| 254 assertRefactoringStatus(status, RefactoringProblemSeverity.FATAL, |
| 255 expectedMessage: |
| 256 "The method 'String.toUpperCase' is defined in the SDK, so cannot be
renamed."); |
| 257 } |
| 258 |
244 test_checkInitialConditions_operator() async { | 259 test_checkInitialConditions_operator() async { |
245 indexTestUnit(''' | 260 indexTestUnit(''' |
246 class A { | 261 class A { |
247 operator -(other) => this; | 262 operator -(other) => this; |
248 } | 263 } |
249 '''); | 264 '''); |
250 createRenameRefactoringAtString('-(other)'); | 265 createRenameRefactoringAtString('-(other)'); |
251 // check status | 266 // check status |
252 refactoring.newName = 'newName'; | 267 refactoring.newName = 'newName'; |
253 RefactoringStatus status = await refactoring.checkInitialConditions(); | 268 RefactoringStatus status = await refactoring.checkInitialConditions(); |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 // validate change | 745 // validate change |
731 return assertSuccessfulRefactoring(''' | 746 return assertSuccessfulRefactoring(''' |
732 class A<NewName> { | 747 class A<NewName> { |
733 NewName field; | 748 NewName field; |
734 List<NewName> items; | 749 List<NewName> items; |
735 NewName method(NewName p) => null; | 750 NewName method(NewName p) => null; |
736 } | 751 } |
737 '''); | 752 '''); |
738 } | 753 } |
739 } | 754 } |
OLD | NEW |