| 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_local; | 5 library test.services.refactoring.rename_local; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
| 8 import '../../reflective_tests.dart'; | 8 import '../../reflective_tests.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 | 10 |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 indexTestUnit(''' | 277 indexTestUnit(''' |
| 278 main() { | 278 main() { |
| 279 int test() => 0; | 279 int test() => 0; |
| 280 print(test); | 280 print(test); |
| 281 print(test()); | 281 print(test()); |
| 282 } | 282 } |
| 283 '''); | 283 '''); |
| 284 // configure refactoring | 284 // configure refactoring |
| 285 createRenameRefactoringAtString('test() => 0'); | 285 createRenameRefactoringAtString('test() => 0'); |
| 286 expect(refactoring.refactoringName, 'Rename Local Function'); | 286 expect(refactoring.refactoringName, 'Rename Local Function'); |
| 287 expect(refactoring.elementKindName, 'function'); |
| 287 refactoring.newName = 'newName'; | 288 refactoring.newName = 'newName'; |
| 288 // validate change | 289 // validate change |
| 289 return assertSuccessfulRefactoring(''' | 290 return assertSuccessfulRefactoring(''' |
| 290 main() { | 291 main() { |
| 291 int newName() => 0; | 292 int newName() => 0; |
| 292 print(newName); | 293 print(newName); |
| 293 print(newName()); | 294 print(newName()); |
| 294 } | 295 } |
| 295 '''); | 296 '''); |
| 296 } | 297 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 main() { | 341 main() { |
| 341 int test = 0; | 342 int test = 0; |
| 342 test = 1; | 343 test = 1; |
| 343 test += 2; | 344 test += 2; |
| 344 print(test); | 345 print(test); |
| 345 } | 346 } |
| 346 '''); | 347 '''); |
| 347 // configure refactoring | 348 // configure refactoring |
| 348 createRenameRefactoringAtString('test = 0'); | 349 createRenameRefactoringAtString('test = 0'); |
| 349 expect(refactoring.refactoringName, 'Rename Local Variable'); | 350 expect(refactoring.refactoringName, 'Rename Local Variable'); |
| 351 expect(refactoring.elementKindName, 'local variable'); |
| 350 refactoring.newName = 'newName'; | 352 refactoring.newName = 'newName'; |
| 351 // validate change | 353 // validate change |
| 352 return assertSuccessfulRefactoring(''' | 354 return assertSuccessfulRefactoring(''' |
| 353 main() { | 355 main() { |
| 354 int newName = 0; | 356 int newName = 0; |
| 355 newName = 1; | 357 newName = 1; |
| 356 newName += 2; | 358 newName += 2; |
| 357 print(newName); | 359 print(newName); |
| 358 } | 360 } |
| 359 '''); | 361 '''); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 test += 2; | 408 test += 2; |
| 407 print(test); | 409 print(test); |
| 408 } | 410 } |
| 409 main() { | 411 main() { |
| 410 myFunction(test: 2); | 412 myFunction(test: 2); |
| 411 } | 413 } |
| 412 '''); | 414 '''); |
| 413 // configure refactoring | 415 // configure refactoring |
| 414 createRenameRefactoringAtString('test}) {'); | 416 createRenameRefactoringAtString('test}) {'); |
| 415 expect(refactoring.refactoringName, 'Rename Parameter'); | 417 expect(refactoring.refactoringName, 'Rename Parameter'); |
| 418 expect(refactoring.elementKindName, 'parameter'); |
| 416 refactoring.newName = 'newName'; | 419 refactoring.newName = 'newName'; |
| 417 // validate change | 420 // validate change |
| 418 return assertSuccessfulRefactoring(''' | 421 return assertSuccessfulRefactoring(''' |
| 419 myFunction({int newName}) { | 422 myFunction({int newName}) { |
| 420 newName = 1; | 423 newName = 1; |
| 421 newName += 2; | 424 newName += 2; |
| 422 print(newName); | 425 print(newName); |
| 423 } | 426 } |
| 424 main() { | 427 main() { |
| 425 myFunction(newName: 2); | 428 myFunction(newName: 2); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 main() { | 466 main() { |
| 464 int test = 0; | 467 int test = 0; |
| 465 } | 468 } |
| 466 '''); | 469 '''); |
| 467 // configure refactoring | 470 // configure refactoring |
| 468 createRenameRefactoringAtString('test = 0'); | 471 createRenameRefactoringAtString('test = 0'); |
| 469 // old name | 472 // old name |
| 470 expect(refactoring.oldName, 'test'); | 473 expect(refactoring.oldName, 'test'); |
| 471 } | 474 } |
| 472 } | 475 } |
| OLD | NEW |