| 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.inline_local; | 5 library test.services.refactoring.inline_local; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart' hide Element; | 7 import 'package:analysis_server/src/protocol.dart' hide Element; |
| 8 import 'package:analysis_server/src/services/correction/status.dart'; | 8 import 'package:analysis_server/src/services/correction/status.dart'; |
| 9 import 'package:analysis_server/src/services/refactoring/inline_local.dart'; | 9 import 'package:analysis_server/src/services/refactoring/inline_local.dart'; |
| 10 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; | 10 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 _createRefactoring('test ='); | 527 _createRefactoring('test ='); |
| 528 // validate change | 528 // validate change |
| 529 return assertSuccessfulRefactoring(''' | 529 return assertSuccessfulRefactoring(''' |
| 530 class A {} | 530 class A {} |
| 531 main() { | 531 main() { |
| 532 var list = [new A()]; | 532 var list = [new A()]; |
| 533 } | 533 } |
| 534 '''); | 534 '''); |
| 535 } | 535 } |
| 536 | 536 |
| 537 test_OK_parenthesis_intoIndexExpression_index() { |
| 538 indexTestUnit(''' |
| 539 main() { |
| 540 var items = []; |
| 541 var test = 1 + 2; |
| 542 items[test] * 5; |
| 543 } |
| 544 '''); |
| 545 _createRefactoring('test ='); |
| 546 // validate change |
| 547 return assertSuccessfulRefactoring(''' |
| 548 main() { |
| 549 var items = []; |
| 550 items[1 + 2] * 5; |
| 551 } |
| 552 '''); |
| 553 } |
| 554 |
| 555 test_OK_parenthesis_intoParenthesizedExpression() { |
| 556 indexTestUnit(''' |
| 557 f(m, x, y) { |
| 558 int test = x as int; |
| 559 m[test] = y; |
| 560 return m[test]; |
| 561 } |
| 562 '''); |
| 563 _createRefactoring('test ='); |
| 564 // validate change |
| 565 return assertSuccessfulRefactoring(''' |
| 566 f(m, x, y) { |
| 567 m[x as int] = y; |
| 568 return m[x as int]; |
| 569 } |
| 570 '''); |
| 571 } |
| 572 |
| 537 test_OK_parenthesis_negate_intoNegate() { | 573 test_OK_parenthesis_negate_intoNegate() { |
| 538 indexTestUnit(''' | 574 indexTestUnit(''' |
| 539 main() { | 575 main() { |
| 540 var a = 1; | 576 var a = 1; |
| 541 var test = -a; | 577 var test = -a; |
| 542 var b = -test; | 578 var b = -test; |
| 543 } | 579 } |
| 544 '''); | 580 '''); |
| 545 _createRefactoring('test ='); | 581 _createRefactoring('test ='); |
| 546 // validate change | 582 // validate change |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 assertRefactoringStatus(status, RefactoringProblemSeverity.FATAL, | 628 assertRefactoringStatus(status, RefactoringProblemSeverity.FATAL, |
| 593 expectedMessage: 'Local variable declaration or reference must be ' | 629 expectedMessage: 'Local variable declaration or reference must be ' |
| 594 'selected to activate this refactoring.'); | 630 'selected to activate this refactoring.'); |
| 595 } | 631 } |
| 596 | 632 |
| 597 void _createRefactoring(String search) { | 633 void _createRefactoring(String search) { |
| 598 int offset = findOffset(search); | 634 int offset = findOffset(search); |
| 599 refactoring = new InlineLocalRefactoring(searchEngine, testUnit, offset); | 635 refactoring = new InlineLocalRefactoring(searchEngine, testUnit, offset); |
| 600 } | 636 } |
| 601 } | 637 } |
| OLD | NEW |