| 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.search.top_level_declarations; | 5 library test.search.top_level_declarations; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/constants.dart'; | 7 import 'package:analysis_server/src/constants.dart'; |
| 8 import 'package:analysis_server/src/protocol.dart'; | 8 import 'package:analysis_server/src/protocol.dart'; |
| 9 import 'package:analysis_server/src/protocol2.dart' show |
| 10 SearchFindTopLevelDeclarationsParams; |
| 9 import 'package:analysis_server/src/search/search_result.dart'; | 11 import 'package:analysis_server/src/search/search_result.dart'; |
| 10 import 'package:analysis_testing/reflective_tests.dart'; | 12 import 'package:analysis_testing/reflective_tests.dart'; |
| 11 import 'package:unittest/unittest.dart'; | 13 import 'package:unittest/unittest.dart'; |
| 12 | 14 |
| 13 import 'abstract_search_domain.dart'; | 15 import 'abstract_search_domain.dart'; |
| 14 import 'dart:async'; | 16 import 'dart:async'; |
| 15 import 'package:analysis_server/src/computer/element.dart'; | 17 import 'package:analysis_server/src/computer/element.dart'; |
| 16 | 18 |
| 17 | 19 |
| 18 main() { | 20 main() { |
| 19 groupSep = ' | '; | 21 groupSep = ' | '; |
| 20 runReflectiveTests(TopLevelDeclarationsTest); | 22 runReflectiveTests(TopLevelDeclarationsTest); |
| 21 } | 23 } |
| 22 | 24 |
| 23 | 25 |
| 24 @ReflectiveTestCase() | 26 @ReflectiveTestCase() |
| 25 class TopLevelDeclarationsTest extends AbstractSearchDomainTest { | 27 class TopLevelDeclarationsTest extends AbstractSearchDomainTest { |
| 26 Future findTopLevelDeclarations(String pattern) { | 28 Future findTopLevelDeclarations(String pattern) { |
| 27 return waitForTasksFinished().then((_) { | 29 return waitForTasksFinished().then((_) { |
| 28 Request request = new Request('0', SEARCH_FIND_TOP_LEVEL_DECLARATIONS); | 30 Request request = new SearchFindTopLevelDeclarationsParams( |
| 29 request.setParameter(PATTERN, pattern); | 31 pattern).toRequest('0'); |
| 30 Response response = handleSuccessfulRequest(request); | 32 Response response = handleSuccessfulRequest(request); |
| 31 searchId = response.getResult(ID); | 33 searchId = response.getResult(ID); |
| 32 results.clear(); | 34 results.clear(); |
| 33 return waitForSearchResults(); | 35 return waitForSearchResults(); |
| 34 }); | 36 }); |
| 35 } | 37 } |
| 36 | 38 |
| 37 void assertHasDeclaration(ElementKind kind, String name) { | 39 void assertHasDeclaration(ElementKind kind, String name) { |
| 38 result = findTopLevelResult(kind, name); | 40 result = findTopLevelResult(kind, name); |
| 39 if (result == null) { | 41 if (result == null) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 70 return findTopLevelDeclarations('^[A-E]\$').then((_) { | 72 return findTopLevelDeclarations('^[A-E]\$').then((_) { |
| 71 assertHasDeclaration(ElementKind.CLASS, 'A'); | 73 assertHasDeclaration(ElementKind.CLASS, 'A'); |
| 72 assertHasDeclaration(ElementKind.CLASS, 'B'); | 74 assertHasDeclaration(ElementKind.CLASS, 'B'); |
| 73 assertHasDeclaration(ElementKind.FUNCTION_TYPE_ALIAS, 'C'); | 75 assertHasDeclaration(ElementKind.FUNCTION_TYPE_ALIAS, 'C'); |
| 74 assertHasDeclaration(ElementKind.FUNCTION, 'D'); | 76 assertHasDeclaration(ElementKind.FUNCTION, 'D'); |
| 75 assertHasDeclaration(ElementKind.TOP_LEVEL_VARIABLE, 'E'); | 77 assertHasDeclaration(ElementKind.TOP_LEVEL_VARIABLE, 'E'); |
| 76 assertNoDeclaration(ElementKind.CLASS, 'ABC'); | 78 assertNoDeclaration(ElementKind.CLASS, 'ABC'); |
| 77 }); | 79 }); |
| 78 } | 80 } |
| 79 } | 81 } |
| OLD | NEW |