| 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/constants.dart'; | 9 import 'package:analysis_server/src/constants.dart'; |
| 10 import 'package:analysis_server/src/edit/edit_domain.dart'; | 10 import 'package:analysis_server/src/edit/edit_domain.dart'; |
| 11 import 'package:analysis_server/src/protocol.dart'; | 11 import 'package:analysis_server/src/protocol.dart'; |
| 12 import 'package:analysis_server/src/protocol2.dart' show |
| 13 EditGetAvailableRefactoringsParams; |
| 12 import 'package:analysis_testing/reflective_tests.dart'; | 14 import 'package:analysis_testing/reflective_tests.dart'; |
| 13 import 'package:unittest/unittest.dart' hide ERROR; | 15 import 'package:unittest/unittest.dart' hide ERROR; |
| 14 | 16 |
| 15 import '../analysis_abstract.dart'; | 17 import '../analysis_abstract.dart'; |
| 16 | 18 |
| 17 | 19 |
| 18 main() { | 20 main() { |
| 19 groupSep = ' | '; | 21 groupSep = ' | '; |
| 20 runReflectiveTests(GetAvailableRefactoringsTest); | 22 runReflectiveTests(GetAvailableRefactoringsTest); |
| 21 } | 23 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 32 List<String> kinds = getAvailableRefactorings(search); | 34 List<String> kinds = getAvailableRefactorings(search); |
| 33 expect(kinds, contains(RefactoringKind.RENAME)); | 35 expect(kinds, contains(RefactoringKind.RENAME)); |
| 34 }); | 36 }); |
| 35 } | 37 } |
| 36 | 38 |
| 37 /** | 39 /** |
| 38 * Returns the list of available refactorings of the offset of [search] with | 40 * Returns the list of available refactorings of the offset of [search] with |
| 39 * [length] characters selected. | 41 * [length] characters selected. |
| 40 */ | 42 */ |
| 41 List<String> getAvailableRefactorings(String search, [int length = 0]) { | 43 List<String> getAvailableRefactorings(String search, [int length = 0]) { |
| 42 Request request = new Request('0', EDIT_GET_AVAILABLE_REFACTORINGS); | 44 Request request = new EditGetAvailableRefactoringsParams(testFile, |
| 43 request.setParameter(FILE, testFile); | 45 findOffset(search), length).toRequest('0'); |
| 44 request.setParameter(OFFSET, findOffset(search)); | |
| 45 request.setParameter(LENGTH, length); | |
| 46 Response response = handleSuccessfulRequest(request); | 46 Response response = handleSuccessfulRequest(request); |
| 47 return response.getResult(KINDS); | 47 return response.getResult(KINDS); |
| 48 } | 48 } |
| 49 | 49 |
| 50 @override | 50 @override |
| 51 void setUp() { | 51 void setUp() { |
| 52 super.setUp(); | 52 super.setUp(); |
| 53 createProject(); | 53 createProject(); |
| 54 handler = new EditDomainHandler(server); | 54 handler = new EditDomainHandler(server); |
| 55 } | 55 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 main() { | 164 main() { |
| 165 // not an element | 165 // not an element |
| 166 } | 166 } |
| 167 '''); | 167 '''); |
| 168 return waitForTasksFinished().then((_) { | 168 return waitForTasksFinished().then((_) { |
| 169 List<String> kinds = getAvailableRefactorings('// not an element'); | 169 List<String> kinds = getAvailableRefactorings('// not an element'); |
| 170 expect(kinds, isNot(contains(RefactoringKind.RENAME))); | 170 expect(kinds, isNot(contains(RefactoringKind.RENAME))); |
| 171 }); | 171 }); |
| 172 } | 172 } |
| 173 } | 173 } |
| OLD | NEW |