| 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.services.src.search.search_engine_internal; | 5 library test.services.src.search.search_engine_internal; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/services/index/index.dart'; | 9 import 'package:analysis_server/src/services/index/index.dart'; |
| 10 import 'package:analysis_server/src/services/search/search_engine.dart'; | 10 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 75 } |
| 76 | 76 |
| 77 test_searchAllSubtypes() async { | 77 test_searchAllSubtypes() async { |
| 78 _indexTestUnit(''' | 78 _indexTestUnit(''' |
| 79 class T {} | 79 class T {} |
| 80 class A extends T {} | 80 class A extends T {} |
| 81 class B extends A {} | 81 class B extends A {} |
| 82 class C implements B {} | 82 class C implements B {} |
| 83 '''); | 83 '''); |
| 84 ClassElement element = findElement('T'); | 84 ClassElement element = findElement('T'); |
| 85 ClassElement elementA = findElement('A'); | 85 Set<ClassElement> subtypes = await searchEngine.searchAllSubtypes(element); |
| 86 ClassElement elementB = findElement('B'); | 86 expect(subtypes, hasLength(3)); |
| 87 ClassElement elementC = findElement('C'); | 87 expect(subtypes, contains(predicate((ClassElement e) => e.name == 'A'))); |
| 88 var expected = [ | 88 expect(subtypes, contains(predicate((ClassElement e) => e.name == 'B'))); |
| 89 _expectId(elementA, MatchKind.DECLARATION, 'A extends T'), | 89 expect(subtypes, contains(predicate((ClassElement e) => e.name == 'C'))); |
| 90 _expectId(elementB, MatchKind.DECLARATION, 'B extends A'), | |
| 91 _expectId(elementC, MatchKind.DECLARATION, 'C implements B') | |
| 92 ]; | |
| 93 List<SearchMatch> matches = await searchEngine.searchAllSubtypes(element); | |
| 94 _assertMatches(matches, expected); | |
| 95 } | 90 } |
| 96 | 91 |
| 97 test_searchMemberDeclarations() async { | 92 test_searchMemberDeclarations() async { |
| 98 _indexTestUnit(''' | 93 _indexTestUnit(''' |
| 99 class A { | 94 class A { |
| 100 test() {} | 95 test() {} |
| 101 } | 96 } |
| 102 class B { | 97 class B { |
| 103 int test = 1; | 98 int test = 1; |
| 104 int testTwo = 2; | 99 int testTwo = 2; |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 List<SearchMatch> matches = await searchEngine.searchReferences(element); | 940 List<SearchMatch> matches = await searchEngine.searchReferences(element); |
| 946 _assertMatches(matches, expectedMatches); | 941 _assertMatches(matches, expectedMatches); |
| 947 expect(matches, hasLength(expectedMatches.length)); | 942 expect(matches, hasLength(expectedMatches.length)); |
| 948 } | 943 } |
| 949 | 944 |
| 950 static void _assertMatches( | 945 static void _assertMatches( |
| 951 List<SearchMatch> matches, List<ExpectedMatch> expectedMatches) { | 946 List<SearchMatch> matches, List<ExpectedMatch> expectedMatches) { |
| 952 expect(matches, unorderedEquals(expectedMatches)); | 947 expect(matches, unorderedEquals(expectedMatches)); |
| 953 } | 948 } |
| 954 } | 949 } |
| OLD | NEW |