| 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.member_declarations; | 5 library test.search.member_declarations; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/computer/element.dart'; | 9 import 'package:analysis_server/src/computer/element.dart'; |
| 10 import 'package:analysis_server/src/constants.dart'; | |
| 11 import 'package:analysis_server/src/protocol.dart'; | 10 import 'package:analysis_server/src/protocol.dart'; |
| 12 import 'package:analysis_server/src/protocol2.dart' show | 11 import 'package:analysis_server/src/protocol2.dart' show |
| 13 SearchFindMemberDeclarationsParams; | 12 SearchFindMemberDeclarationsParams, ElementKind, |
| 13 SearchFindMemberDeclarationsResult; |
| 14 import 'package:analysis_server/src/search/search_result.dart'; | 14 import 'package:analysis_server/src/search/search_result.dart'; |
| 15 import 'package:analysis_testing/reflective_tests.dart'; | 15 import 'package:analysis_testing/reflective_tests.dart'; |
| 16 import 'package:unittest/unittest.dart'; | 16 import 'package:unittest/unittest.dart'; |
| 17 | 17 |
| 18 import 'abstract_search_domain.dart'; | 18 import 'abstract_search_domain.dart'; |
| 19 | 19 |
| 20 | 20 |
| 21 main() { | 21 main() { |
| 22 groupSep = ' | '; | 22 groupSep = ' | '; |
| 23 runReflectiveTests(MemberDeclarationsTest); | 23 runReflectiveTests(MemberDeclarationsTest); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 38 if (result != null) { | 38 if (result != null) { |
| 39 fail('Unexpected: kind=$kind in="$className"\nin\n' + results.join('\n')); | 39 fail('Unexpected: kind=$kind in="$className"\nin\n' + results.join('\n')); |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 Future findMemberDeclarations(String name) { | 43 Future findMemberDeclarations(String name) { |
| 44 return waitForTasksFinished().then((_) { | 44 return waitForTasksFinished().then((_) { |
| 45 Request request = | 45 Request request = |
| 46 new SearchFindMemberDeclarationsParams(name).toRequest('0'); | 46 new SearchFindMemberDeclarationsParams(name).toRequest('0'); |
| 47 Response response = handleSuccessfulRequest(request); | 47 Response response = handleSuccessfulRequest(request); |
| 48 searchId = response.getResult(ID); | 48 var result = new SearchFindMemberDeclarationsResult.fromResponse(response)
; |
| 49 searchId = result.id; |
| 49 results.clear(); | 50 results.clear(); |
| 50 return waitForSearchResults(); | 51 return waitForSearchResults(); |
| 51 }); | 52 }); |
| 52 } | 53 } |
| 53 | 54 |
| 54 SearchResult findTopLevelResult(ElementKind kind, String enclosingClass) { | 55 SearchResult findTopLevelResult(ElementKind kind, String enclosingClass) { |
| 55 for (SearchResult result in results) { | 56 for (SearchResult result in results) { |
| 56 Element element = result.path[0]; | 57 Element element = result.path[0]; |
| 57 Element clazz = result.path[1]; | 58 Element clazz = result.path[1]; |
| 58 if (element.kind == kind && clazz.name == enclosingClass) { | 59 if (element.kind == kind && clazz.name == enclosingClass) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 set foo(x) {} | 170 set foo(x) {} |
| 170 } | 171 } |
| 171 '''); | 172 '''); |
| 172 return findMemberDeclarations('foo').then((_) { | 173 return findMemberDeclarations('foo').then((_) { |
| 173 expect(results, hasLength(2)); | 174 expect(results, hasLength(2)); |
| 174 assertHasDeclaration(ElementKind.METHOD, 'A'); | 175 assertHasDeclaration(ElementKind.METHOD, 'A'); |
| 175 assertHasDeclaration(ElementKind.SETTER, 'B'); | 176 assertHasDeclaration(ElementKind.SETTER, 'B'); |
| 176 }); | 177 }); |
| 177 } | 178 } |
| 178 } | 179 } |
| OLD | NEW |