| 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 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 return getRefactoringResult(() { | 1037 return getRefactoringResult(() { |
| 1038 return sendRenameRequest('test = 0', 'newName', false); | 1038 return sendRenameRequest('test = 0', 'newName', false); |
| 1039 }).then((result) { | 1039 }).then((result) { |
| 1040 List<RefactoringProblem> problems = result.finalProblems; | 1040 List<RefactoringProblem> problems = result.finalProblems; |
| 1041 expect(problems, hasLength(1)); | 1041 expect(problems, hasLength(1)); |
| 1042 assertResultProblemsError( | 1042 assertResultProblemsError( |
| 1043 problems, | 1043 problems, |
| 1044 "Duplicate local variable 'newName'."); | 1044 "Duplicate local variable 'newName'."); |
| 1045 }); | 1045 }); |
| 1046 } | 1046 } |
| 1047 |
| 1048 test_resetOnAnalysis() { |
| 1049 addTestFile(''' |
| 1050 main() { |
| 1051 int initialName = 0; |
| 1052 print(initialName); |
| 1053 } |
| 1054 '''); |
| 1055 // send the first request |
| 1056 return getRefactoringResult(() { |
| 1057 return sendRenameRequest('initialName =', 'newName', true); |
| 1058 }).then((result) { |
| 1059 RenameFeedback feedback = result.feedback; |
| 1060 expect(feedback.oldName, 'initialName'); |
| 1061 // update the file |
| 1062 modifyTestFile(''' |
| 1063 main() { |
| 1064 int otherName = 0; |
| 1065 print(otherName); |
| 1066 } |
| 1067 '''); |
| 1068 // send the second request, with the same kind, file and offset |
| 1069 return waitForTasksFinished().then((_) { |
| 1070 return getRefactoringResult(() { |
| 1071 return sendRenameRequest('otherName =', 'newName', true); |
| 1072 }).then((result) { |
| 1073 RenameFeedback feedback = result.feedback; |
| 1074 // the refactoring was reset, so we don't get a stale result |
| 1075 expect(feedback.oldName, 'otherName'); |
| 1076 }); |
| 1077 }); |
| 1078 }); |
| 1079 } |
| 1047 } | 1080 } |
| 1048 | 1081 |
| 1049 | 1082 |
| 1050 @ReflectiveTestCase() | 1083 @ReflectiveTestCase() |
| 1051 class _AbstractGetRefactoring_Test extends AbstractAnalysisTest { | 1084 class _AbstractGetRefactoring_Test extends AbstractAnalysisTest { |
| 1052 /** | 1085 /** |
| 1053 * Asserts that [problems] has a single ERROR problem. | 1086 * Asserts that [problems] has a single ERROR problem. |
| 1054 */ | 1087 */ |
| 1055 void assertResultProblemsError(List<RefactoringProblem> problems, | 1088 void assertResultProblemsError(List<RefactoringProblem> problems, |
| 1056 [String message]) { | 1089 [String message]) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 } | 1191 } |
| 1159 | 1192 |
| 1160 @override | 1193 @override |
| 1161 void setUp() { | 1194 void setUp() { |
| 1162 super.setUp(); | 1195 super.setUp(); |
| 1163 server.handlers = [new EditDomainHandler(server),]; | 1196 server.handlers = [new EditDomainHandler(server),]; |
| 1164 createProject(); | 1197 createProject(); |
| 1165 handler = new EditDomainHandler(server); | 1198 handler = new EditDomainHandler(server); |
| 1166 } | 1199 } |
| 1167 } | 1200 } |
| OLD | NEW |