| 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_unit_member; | 5 library test.services.refactoring.rename_unit_member; |
| 6 | 6 |
| 7 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 7 import 'package:analysis_server/plugin/protocol/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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 newName() {} | 489 newName() {} |
| 490 foo() {} | 490 foo() {} |
| 491 main() { | 491 main() { |
| 492 print(newName); | 492 print(newName); |
| 493 print(newName()); | 493 print(newName()); |
| 494 foo(); | 494 foo(); |
| 495 } | 495 } |
| 496 '''); | 496 '''); |
| 497 } | 497 } |
| 498 | 498 |
| 499 test_createChange_FunctionElement_imported() async { |
| 500 indexUnit( |
| 501 '/foo.dart', |
| 502 r''' |
| 503 test() {} |
| 504 foo() {} |
| 505 '''); |
| 506 indexTestUnit(''' |
| 507 import 'foo.dart'; |
| 508 main() { |
| 509 print(test); |
| 510 print(test()); |
| 511 foo(); |
| 512 } |
| 513 '''); |
| 514 // configure refactoring |
| 515 createRenameRefactoringAtString('test);'); |
| 516 expect(refactoring.refactoringName, 'Rename Top-Level Function'); |
| 517 expect(refactoring.elementKindName, 'function'); |
| 518 expect(refactoring.oldName, 'test'); |
| 519 refactoring.newName = 'newName'; |
| 520 // validate change |
| 521 await assertSuccessfulRefactoring(''' |
| 522 import 'foo.dart'; |
| 523 main() { |
| 524 print(newName); |
| 525 print(newName()); |
| 526 foo(); |
| 527 } |
| 528 '''); |
| 529 assertFileChangeResult( |
| 530 '/foo.dart', |
| 531 ''' |
| 532 newName() {} |
| 533 foo() {} |
| 534 '''); |
| 535 } |
| 536 |
| 499 test_createChange_PropertyAccessorElement_getter_declaration() { | 537 test_createChange_PropertyAccessorElement_getter_declaration() { |
| 500 return _test_createChange_PropertyAccessorElement("test {}"); | 538 return _test_createChange_PropertyAccessorElement("test {}"); |
| 501 } | 539 } |
| 502 | 540 |
| 503 test_createChange_PropertyAccessorElement_getter_usage() { | 541 test_createChange_PropertyAccessorElement_getter_usage() { |
| 504 return _test_createChange_PropertyAccessorElement("test);"); | 542 return _test_createChange_PropertyAccessorElement("test);"); |
| 505 } | 543 } |
| 506 | 544 |
| 507 test_createChange_PropertyAccessorElement_mix() { | 545 test_createChange_PropertyAccessorElement_mix() { |
| 508 return _test_createChange_PropertyAccessorElement("test += 2"); | 546 return _test_createChange_PropertyAccessorElement("test += 2"); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 return assertSuccessfulRefactoring(''' | 616 return assertSuccessfulRefactoring(''' |
| 579 int newName = 0; | 617 int newName = 0; |
| 580 main() { | 618 main() { |
| 581 print(newName); | 619 print(newName); |
| 582 newName = 1; | 620 newName = 1; |
| 583 newName += 2; | 621 newName += 2; |
| 584 } | 622 } |
| 585 '''); | 623 '''); |
| 586 } | 624 } |
| 587 } | 625 } |
| OLD | NEW |