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/src/services/correction/status.dart'; | 5 import 'package:analysis_server/src/services/correction/status.dart'; |
6 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | 6 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
7 import 'package:test/test.dart'; | 7 import 'package:test/test.dart'; |
8 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 8 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
9 | 9 |
10 import 'abstract_rename.dart'; | 10 import 'abstract_rename.dart'; |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 } | 440 } |
441 '''); | 441 '''); |
442 } | 442 } |
443 | 443 |
444 test_createChange_parameter_named_inOtherFile() async { | 444 test_createChange_parameter_named_inOtherFile() async { |
445 await indexTestUnit(''' | 445 await indexTestUnit(''' |
446 class A { | 446 class A { |
447 A({test}); | 447 A({test}); |
448 } | 448 } |
449 '''); | 449 '''); |
450 await indexUnit( | 450 await indexUnit('/test2.dart', ''' |
451 '/test2.dart', | |
452 ''' | |
453 import 'test.dart'; | 451 import 'test.dart'; |
454 main() { | 452 main() { |
455 new A(test: 2); | 453 new A(test: 2); |
456 } | 454 } |
457 '''); | 455 '''); |
458 // configure refactoring | 456 // configure refactoring |
459 createRenameRefactoringAtString('test});'); | 457 createRenameRefactoringAtString('test});'); |
460 expect(refactoring.refactoringName, 'Rename Parameter'); | 458 expect(refactoring.refactoringName, 'Rename Parameter'); |
461 refactoring.newName = 'newName'; | 459 refactoring.newName = 'newName'; |
462 // validate change | 460 // validate change |
463 await assertSuccessfulRefactoring(''' | 461 await assertSuccessfulRefactoring(''' |
464 class A { | 462 class A { |
465 A({newName}); | 463 A({newName}); |
466 } | 464 } |
467 '''); | 465 '''); |
468 assertFileChangeResult( | 466 assertFileChangeResult('/test2.dart', ''' |
469 '/test2.dart', | |
470 ''' | |
471 import 'test.dart'; | 467 import 'test.dart'; |
472 main() { | 468 main() { |
473 new A(newName: 2); | 469 new A(newName: 2); |
474 } | 470 } |
475 '''); | 471 '''); |
476 } | 472 } |
477 | 473 |
478 test_createChange_parameter_named_updateHierarchy() async { | 474 test_createChange_parameter_named_updateHierarchy() async { |
479 await indexUnit( | 475 await indexUnit('/test2.dart', ''' |
480 '/test2.dart', | |
481 ''' | |
482 library test2; | 476 library test2; |
483 class A { | 477 class A { |
484 void foo({int test: 1}) { | 478 void foo({int test: 1}) { |
485 print(test); | 479 print(test); |
486 } | 480 } |
487 } | 481 } |
488 class B extends A { | 482 class B extends A { |
489 void foo({int test: 2}) { | 483 void foo({int test: 2}) { |
490 print(test); | 484 print(test); |
491 } | 485 } |
(...skipping 23 matching lines...) Expand all Loading... |
515 new A().foo(newName: 10); | 509 new A().foo(newName: 10); |
516 new B().foo(newName: 20); | 510 new B().foo(newName: 20); |
517 new C().foo(newName: 30); | 511 new C().foo(newName: 30); |
518 } | 512 } |
519 class C extends A { | 513 class C extends A { |
520 void foo({int newName: 3}) { | 514 void foo({int newName: 3}) { |
521 print(newName); | 515 print(newName); |
522 } | 516 } |
523 } | 517 } |
524 '''); | 518 '''); |
525 assertFileChangeResult( | 519 assertFileChangeResult('/test2.dart', ''' |
526 '/test2.dart', | |
527 ''' | |
528 library test2; | 520 library test2; |
529 class A { | 521 class A { |
530 void foo({int newName: 1}) { | 522 void foo({int newName: 1}) { |
531 print(newName); | 523 print(newName); |
532 } | 524 } |
533 } | 525 } |
534 class B extends A { | 526 class B extends A { |
535 void foo({int newName: 2}) { | 527 void foo({int newName: 2}) { |
536 print(newName); | 528 print(newName); |
537 } | 529 } |
538 } | 530 } |
539 '''); | 531 '''); |
540 } | 532 } |
541 | 533 |
542 test_oldName() async { | 534 test_oldName() async { |
543 await indexTestUnit(''' | 535 await indexTestUnit(''' |
544 main() { | 536 main() { |
545 int test = 0; | 537 int test = 0; |
546 } | 538 } |
547 '''); | 539 '''); |
548 // configure refactoring | 540 // configure refactoring |
549 createRenameRefactoringAtString('test = 0'); | 541 createRenameRefactoringAtString('test = 0'); |
550 // old name | 542 // old name |
551 expect(refactoring.oldName, 'test'); | 543 expect(refactoring.oldName, 'test'); |
552 } | 544 } |
553 } | 545 } |
OLD | NEW |