| 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/protocol2.dart'; | 7 import 'package:analysis_server/src/protocol2.dart'; |
| 8 import 'package:analysis_testing/reflective_tests.dart'; | 8 import 'package:analysis_testing/reflective_tests.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 | 10 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 indexTestUnit(''' | 257 indexTestUnit(''' |
| 258 class A { | 258 class A { |
| 259 int test; | 259 int test; |
| 260 } | 260 } |
| 261 '''); | 261 '''); |
| 262 createRenameRefactoringAtString('test;'); | 262 createRenameRefactoringAtString('test;'); |
| 263 // null | 263 // null |
| 264 refactoring.newName = null; | 264 refactoring.newName = null; |
| 265 assertRefactoringStatus( | 265 assertRefactoringStatus( |
| 266 refactoring.checkNewName(), | 266 refactoring.checkNewName(), |
| 267 RefactoringProblemSeverity.ERROR, | 267 RefactoringProblemSeverity.FATAL, |
| 268 expectedMessage: "Field name must not be null."); | 268 expectedMessage: "Field name must not be null."); |
| 269 // OK | 269 // OK |
| 270 refactoring.newName = 'newName'; | 270 refactoring.newName = 'newName'; |
| 271 assertRefactoringStatusOK(refactoring.checkNewName()); | 271 assertRefactoringStatusOK(refactoring.checkNewName()); |
| 272 } | 272 } |
| 273 | 273 |
| 274 test_checkNewName_FieldElement_const() { | 274 test_checkNewName_FieldElement_const() { |
| 275 indexTestUnit(''' | 275 indexTestUnit(''' |
| 276 class A { | 276 class A { |
| 277 static const int TEST = 0; | 277 static const int TEST = 0; |
| 278 } | 278 } |
| 279 '''); | 279 '''); |
| 280 createRenameRefactoringAtString('TEST ='); | 280 createRenameRefactoringAtString('TEST ='); |
| 281 // null | 281 // null |
| 282 refactoring.newName = null; | 282 refactoring.newName = null; |
| 283 assertRefactoringStatus( | 283 assertRefactoringStatus( |
| 284 refactoring.checkNewName(), | 284 refactoring.checkNewName(), |
| 285 RefactoringProblemSeverity.ERROR, | 285 RefactoringProblemSeverity.FATAL, |
| 286 expectedMessage: "Constant name must not be null."); | 286 expectedMessage: "Constant name must not be null."); |
| 287 // not upper case | 287 // not upper case |
| 288 refactoring.newName = 'newName'; | 288 refactoring.newName = 'newName'; |
| 289 assertRefactoringStatus( | 289 assertRefactoringStatus( |
| 290 refactoring.checkNewName(), | 290 refactoring.checkNewName(), |
| 291 RefactoringProblemSeverity.WARNING); | 291 RefactoringProblemSeverity.WARNING); |
| 292 // OK | 292 // OK |
| 293 refactoring.newName = 'NEW_NAME'; | 293 refactoring.newName = 'NEW_NAME'; |
| 294 assertRefactoringStatusOK(refactoring.checkNewName()); | 294 assertRefactoringStatusOK(refactoring.checkNewName()); |
| 295 } | 295 } |
| 296 | 296 |
| 297 test_checkNewName_MethodElement() { | 297 test_checkNewName_MethodElement() { |
| 298 indexTestUnit(''' | 298 indexTestUnit(''' |
| 299 class A { | 299 class A { |
| 300 test() {} | 300 test() {} |
| 301 } | 301 } |
| 302 '''); | 302 '''); |
| 303 createRenameRefactoringAtString('test() {}'); | 303 createRenameRefactoringAtString('test() {}'); |
| 304 // null | 304 // null |
| 305 refactoring.newName = null; | 305 refactoring.newName = null; |
| 306 assertRefactoringStatus( | 306 assertRefactoringStatus( |
| 307 refactoring.checkNewName(), | 307 refactoring.checkNewName(), |
| 308 RefactoringProblemSeverity.ERROR, | 308 RefactoringProblemSeverity.FATAL, |
| 309 expectedMessage: "Method name must not be null."); | 309 expectedMessage: "Method name must not be null."); |
| 310 // empty | 310 // empty |
| 311 refactoring.newName = ''; | 311 refactoring.newName = ''; |
| 312 assertRefactoringStatus( | 312 assertRefactoringStatus( |
| 313 refactoring.checkNewName(), | 313 refactoring.checkNewName(), |
| 314 RefactoringProblemSeverity.ERROR, | 314 RefactoringProblemSeverity.FATAL, |
| 315 expectedMessage: "Method name must not be empty."); | 315 expectedMessage: "Method name must not be empty."); |
| 316 // same | 316 // same |
| 317 refactoring.newName = 'test'; | 317 refactoring.newName = 'test'; |
| 318 assertRefactoringStatus( | 318 assertRefactoringStatus( |
| 319 refactoring.checkNewName(), | 319 refactoring.checkNewName(), |
| 320 RefactoringProblemSeverity.FATAL, | 320 RefactoringProblemSeverity.FATAL, |
| 321 expectedMessage: "The new name must be different than the current name."
); | 321 expectedMessage: "The new name must be different than the current name."
); |
| 322 // OK | 322 // OK |
| 323 refactoring.newName = 'newName'; | 323 refactoring.newName = 'newName'; |
| 324 assertRefactoringStatusOK(refactoring.checkNewName()); | 324 assertRefactoringStatusOK(refactoring.checkNewName()); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 // validate change | 725 // validate change |
| 726 return assertSuccessfulRename(''' | 726 return assertSuccessfulRename(''' |
| 727 class A<NewName> { | 727 class A<NewName> { |
| 728 NewName field; | 728 NewName field; |
| 729 List<NewName> items; | 729 List<NewName> items; |
| 730 NewName method(NewName p) => null; | 730 NewName method(NewName p) => null; |
| 731 } | 731 } |
| 732 '''); | 732 '''); |
| 733 } | 733 } |
| 734 } | 734 } |
| OLD | NEW |