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/protocol/protocol.dart'; | 9 import 'package:analysis_server/protocol/protocol.dart'; |
10 import 'package:analysis_server/protocol/protocol_generated.dart'; | 10 import 'package:analysis_server/protocol/protocol_generated.dart'; |
(...skipping 17 matching lines...) Expand all Loading... |
28 defineReflectiveTests(InlineLocalTest); | 28 defineReflectiveTests(InlineLocalTest); |
29 defineReflectiveTests(InlineMethodTest); | 29 defineReflectiveTests(InlineMethodTest); |
30 defineReflectiveTests(MoveFileTest); | 30 defineReflectiveTests(MoveFileTest); |
31 defineReflectiveTests(RenameTest); | 31 defineReflectiveTests(RenameTest); |
32 defineReflectiveTests(_NoSearchEngine); | 32 defineReflectiveTests(_NoSearchEngine); |
33 }); | 33 }); |
34 } | 34 } |
35 | 35 |
36 @reflectiveTest | 36 @reflectiveTest |
37 class ConvertGetterMethodToMethodTest extends _AbstractGetRefactoring_Test { | 37 class ConvertGetterMethodToMethodTest extends _AbstractGetRefactoring_Test { |
| 38 @override |
| 39 void setUp() { |
| 40 enableNewAnalysisDriver = true; |
| 41 super.setUp(); |
| 42 } |
| 43 |
38 test_function() { | 44 test_function() { |
39 addTestFile(''' | 45 addTestFile(''' |
40 int get test => 42; | 46 int get test => 42; |
41 main() { | 47 main() { |
42 var a = 1 + test; | 48 var a = 1 + test; |
43 var b = 2 + test; | 49 var b = 2 + test; |
44 } | 50 } |
45 '''); | 51 '''); |
46 return assertSuccessfulRefactoring(() { | 52 return assertSuccessfulRefactoring(() { |
47 return _sendConvertRequest('test =>'); | 53 return _sendConvertRequest('test =>'); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 findOffset(search), | 131 findOffset(search), |
126 0, | 132 0, |
127 false) | 133 false) |
128 .toRequest('0'); | 134 .toRequest('0'); |
129 return serverChannel.sendRequest(request); | 135 return serverChannel.sendRequest(request); |
130 } | 136 } |
131 } | 137 } |
132 | 138 |
133 @reflectiveTest | 139 @reflectiveTest |
134 class ConvertMethodToGetterTest extends _AbstractGetRefactoring_Test { | 140 class ConvertMethodToGetterTest extends _AbstractGetRefactoring_Test { |
| 141 @override |
| 142 void setUp() { |
| 143 enableNewAnalysisDriver = true; |
| 144 super.setUp(); |
| 145 } |
| 146 |
135 test_function() { | 147 test_function() { |
136 addTestFile(''' | 148 addTestFile(''' |
137 int test() => 42; | 149 int test() => 42; |
138 main() { | 150 main() { |
139 var a = 1 + test(); | 151 var a = 1 + test(); |
140 var b = 2 + test(); | 152 var b = 2 + test(); |
141 } | 153 } |
142 '''); | 154 '''); |
143 return assertSuccessfulRefactoring(() { | 155 return assertSuccessfulRefactoring(() { |
144 return _sendConvertRequest('test() =>'); | 156 return _sendConvertRequest('test() =>'); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 } | 519 } |
508 } | 520 } |
509 | 521 |
510 @reflectiveTest | 522 @reflectiveTest |
511 class ExtractMethodTest extends _AbstractGetRefactoring_Test { | 523 class ExtractMethodTest extends _AbstractGetRefactoring_Test { |
512 int offset; | 524 int offset; |
513 int length; | 525 int length; |
514 String name = 'res'; | 526 String name = 'res'; |
515 ExtractMethodOptions options; | 527 ExtractMethodOptions options; |
516 | 528 |
| 529 @override |
| 530 void setUp() { |
| 531 enableNewAnalysisDriver = true; |
| 532 super.setUp(); |
| 533 } |
| 534 |
517 test_expression() { | 535 test_expression() { |
518 addTestFile(''' | 536 addTestFile(''' |
519 main() { | 537 main() { |
520 print(1 + 2); | 538 print(1 + 2); |
521 print(1 + 2); | 539 print(1 + 2); |
522 } | 540 } |
523 '''); | 541 '''); |
524 _setOffsetLengthForString('1 + 2'); | 542 _setOffsetLengthForString('1 + 2'); |
525 return assertSuccessfulRefactoring( | 543 return assertSuccessfulRefactoring( |
526 _computeChange, | 544 _computeChange, |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 return getRefactorings(offset, 0); | 792 return getRefactorings(offset, 0); |
775 } | 793 } |
776 | 794 |
777 Future getRefactoringsForString(String search) { | 795 Future getRefactoringsForString(String search) { |
778 int offset = findOffset(search); | 796 int offset = findOffset(search); |
779 return getRefactorings(offset, search.length); | 797 return getRefactorings(offset, search.length); |
780 } | 798 } |
781 | 799 |
782 @override | 800 @override |
783 void setUp() { | 801 void setUp() { |
| 802 enableNewAnalysisDriver = true; |
784 super.setUp(); | 803 super.setUp(); |
785 createProject(); | 804 createProject(); |
786 ExtensionManager manager = new ExtensionManager(); | 805 ExtensionManager manager = new ExtensionManager(); |
787 manager.processPlugins([server.serverPlugin]); | 806 manager.processPlugins([server.serverPlugin]); |
788 handler = new EditDomainHandler(server); | 807 handler = new EditDomainHandler(server); |
789 server.handlers = [handler]; | 808 server.handlers = [handler]; |
790 } | 809 } |
791 | 810 |
792 Future test_convertMethodToGetter_hasElement() { | 811 Future test_convertMethodToGetter_hasElement() { |
793 return assertHasKind( | 812 return assertHasKind( |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 false) | 1087 false) |
1069 .toRequest('0'); | 1088 .toRequest('0'); |
1070 return serverChannel.sendRequest(request); | 1089 return serverChannel.sendRequest(request); |
1071 } | 1090 } |
1072 } | 1091 } |
1073 | 1092 |
1074 @reflectiveTest | 1093 @reflectiveTest |
1075 class InlineMethodTest extends _AbstractGetRefactoring_Test { | 1094 class InlineMethodTest extends _AbstractGetRefactoring_Test { |
1076 InlineMethodOptions options = new InlineMethodOptions(true, true); | 1095 InlineMethodOptions options = new InlineMethodOptions(true, true); |
1077 | 1096 |
| 1097 @override |
| 1098 void setUp() { |
| 1099 enableNewAnalysisDriver = true; |
| 1100 super.setUp(); |
| 1101 } |
| 1102 |
1078 test_feedback() { | 1103 test_feedback() { |
1079 addTestFile(''' | 1104 addTestFile(''' |
1080 class A { | 1105 class A { |
1081 int f; | 1106 int f; |
1082 test(int p) { | 1107 test(int p) { |
1083 print(f + p); | 1108 print(f + p); |
1084 } | 1109 } |
1085 main() { | 1110 main() { |
1086 test(1); | 1111 test(1); |
1087 } | 1112 } |
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2065 .toRequest('0'); | 2090 .toRequest('0'); |
2066 return _assertErrorResponseNoIndex(request); | 2091 return _assertErrorResponseNoIndex(request); |
2067 } | 2092 } |
2068 | 2093 |
2069 _assertErrorResponseNoIndex(Request request) async { | 2094 _assertErrorResponseNoIndex(Request request) async { |
2070 Response response = await serverChannel.sendRequest(request); | 2095 Response response = await serverChannel.sendRequest(request); |
2071 expect(response.error, isNotNull); | 2096 expect(response.error, isNotNull); |
2072 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); | 2097 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); |
2073 } | 2098 } |
2074 } | 2099 } |
OLD | NEW |