| 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.edit.refactoring; | 5 library test.edit.refactoring; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/edit/edit_domain.dart'; | 9 import 'package:analysis_server/src/edit/edit_domain.dart'; |
| 10 import 'package:analysis_server/src/protocol.dart'; | 10 import 'package:analysis_server/src/protocol.dart'; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 groupSep = ' | '; | 21 groupSep = ' | '; |
| 22 runReflectiveTests(ConvertGetterMethodToMethodTest); | 22 runReflectiveTests(ConvertGetterMethodToMethodTest); |
| 23 runReflectiveTests(ConvertMethodToGetterTest); | 23 runReflectiveTests(ConvertMethodToGetterTest); |
| 24 runReflectiveTests(ExtractLocalVariableTest); | 24 runReflectiveTests(ExtractLocalVariableTest); |
| 25 runReflectiveTests(ExtractMethodTest); | 25 runReflectiveTests(ExtractMethodTest); |
| 26 runReflectiveTests(GetAvailableRefactoringsTest); | 26 runReflectiveTests(GetAvailableRefactoringsTest); |
| 27 runReflectiveTests(InlineLocalTest); | 27 runReflectiveTests(InlineLocalTest); |
| 28 runReflectiveTests(InlineMethodTest); | 28 runReflectiveTests(InlineMethodTest); |
| 29 runReflectiveTests(MoveFileTest); | 29 runReflectiveTests(MoveFileTest); |
| 30 runReflectiveTests(RenameTest); | 30 runReflectiveTests(RenameTest); |
| 31 runReflectiveTests(_NoSearchEngine); |
| 31 } | 32 } |
| 32 | 33 |
| 33 | 34 |
| 34 @reflectiveTest | 35 @reflectiveTest |
| 35 class ConvertGetterMethodToMethodTest extends _AbstractGetRefactoring_Test { | 36 class ConvertGetterMethodToMethodTest extends _AbstractGetRefactoring_Test { |
| 36 test_function() { | 37 test_function() { |
| 37 addTestFile(''' | 38 addTestFile(''' |
| 38 int get test => 42; | 39 int get test => 42; |
| 39 main() { | 40 main() { |
| 40 var a = 1 + test; | 41 var a = 1 + test; |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 * Tests that there is a RENAME refactoring available at the [search] offset. | 632 * Tests that there is a RENAME refactoring available at the [search] offset. |
| 632 */ | 633 */ |
| 633 Future assertHasRenameRefactoring(String code, String search) { | 634 Future assertHasRenameRefactoring(String code, String search) { |
| 634 addTestFile(code); | 635 addTestFile(code); |
| 635 return waitForTasksFinished().then((_) { | 636 return waitForTasksFinished().then((_) { |
| 636 List<RefactoringKind> kinds = getRefactoringsAtString(search); | 637 List<RefactoringKind> kinds = getRefactoringsAtString(search); |
| 637 expect(kinds, contains(RefactoringKind.RENAME)); | 638 expect(kinds, contains(RefactoringKind.RENAME)); |
| 638 }); | 639 }); |
| 639 } | 640 } |
| 640 | 641 |
| 642 @override |
| 643 Index createIndex() { |
| 644 return createLocalMemoryIndex(); |
| 645 } |
| 646 |
| 641 /** | 647 /** |
| 642 * Returns the list of available refactorings for the given [offset] and | 648 * Returns the list of available refactorings for the given [offset] and |
| 643 * [length]. | 649 * [length]. |
| 644 */ | 650 */ |
| 645 List<RefactoringKind> getRefactorings(int offset, int length) { | 651 List<RefactoringKind> getRefactorings(int offset, int length) { |
| 646 Request request = new EditGetAvailableRefactoringsParams( | 652 Request request = new EditGetAvailableRefactoringsParams( |
| 647 testFile, | 653 testFile, |
| 648 offset, | 654 offset, |
| 649 length).toRequest('0'); | 655 length).toRequest('0'); |
| 650 Response response = handleSuccessfulRequest(request); | 656 Response response = handleSuccessfulRequest(request); |
| (...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1737 } | 1743 } |
| 1738 | 1744 |
| 1739 @override | 1745 @override |
| 1740 void setUp() { | 1746 void setUp() { |
| 1741 super.setUp(); | 1747 super.setUp(); |
| 1742 server.handlers = [new EditDomainHandler(server),]; | 1748 server.handlers = [new EditDomainHandler(server),]; |
| 1743 createProject(); | 1749 createProject(); |
| 1744 handler = new EditDomainHandler(server); | 1750 handler = new EditDomainHandler(server); |
| 1745 } | 1751 } |
| 1746 } | 1752 } |
| 1753 |
| 1754 |
| 1755 @reflectiveTest |
| 1756 class _NoSearchEngine extends _AbstractGetRefactoring_Test { |
| 1757 @override |
| 1758 Index createIndex() { |
| 1759 return null; |
| 1760 } |
| 1761 |
| 1762 test_getAvailableRefactorings() async { |
| 1763 addTestFile(''' |
| 1764 main() { |
| 1765 print(1 + 2); |
| 1766 } |
| 1767 '''); |
| 1768 await waitForTasksFinished(); |
| 1769 Request request = |
| 1770 new EditGetAvailableRefactoringsParams(testFile, 0, 0).toRequest('0'); |
| 1771 return _assertErrorResposeNoIndex(request); |
| 1772 } |
| 1773 |
| 1774 test_getRefactoring_noSearchEngine() async { |
| 1775 addTestFile(''' |
| 1776 main() { |
| 1777 print(1 + 2); |
| 1778 } |
| 1779 '''); |
| 1780 await waitForTasksFinished(); |
| 1781 Request request = new EditGetRefactoringParams( |
| 1782 RefactoringKind.EXTRACT_LOCAL_VARIABLE, |
| 1783 testFile, |
| 1784 0, |
| 1785 0, |
| 1786 true).toRequest('0'); |
| 1787 return _assertErrorResposeNoIndex(request); |
| 1788 } |
| 1789 |
| 1790 _assertErrorResposeNoIndex(Request request) async { |
| 1791 Response response = await serverChannel.sendRequest(request); |
| 1792 expect(response.error, isNotNull); |
| 1793 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); |
| 1794 } |
| 1795 } |
| OLD | NEW |