Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: pkg/analyzer/test/search/search_engine_test.dart

Issue 375693002: Move index/search to services. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/test/index/test_all.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information.
7
8 library engine.search_engine_test;
9
10
11 main() {
12 }
13
14
15 //class AndSearchPatternTest extends EngineTestCase {
16 // Element _element = mock(Element);
17 //
18 // SearchPattern _patternA = mock(SearchPattern);
19 //
20 // SearchPattern _patternB = mock(SearchPattern);
21 //
22 // AndSearchPattern _pattern = new AndSearchPattern([_patternA, _patternB]);
23 //
24 // void test_allExact() {
25 // when(_patternA.matches(_element)).thenReturn(MatchQuality.EXACT);
26 // when(_patternB.matches(_element)).thenReturn(MatchQuality.EXACT);
27 // // validate
28 // JUnitTestCase.assertSame(MatchQuality.EXACT, _pattern.matches(_element));
29 // }
30 //
31 // void test_ExactName() {
32 // when(_patternA.matches(_element)).thenReturn(MatchQuality.EXACT);
33 // when(_patternB.matches(_element)).thenReturn(MatchQuality.NAME);
34 // // validate
35 // JUnitTestCase.assertSame(MatchQuality.EXACT, _pattern.matches(_element));
36 // }
37 //
38 // void test_NameExact() {
39 // when(_patternA.matches(_element)).thenReturn(MatchQuality.NAME);
40 // when(_patternB.matches(_element)).thenReturn(MatchQuality.EXACT);
41 // // validate
42 // JUnitTestCase.assertSame(MatchQuality.EXACT, _pattern.matches(_element));
43 // }
44 //
45 // void test_oneNull() {
46 // when(_patternA.matches(_element)).thenReturn(MatchQuality.EXACT);
47 // when(_patternB.matches(_element)).thenReturn(null);
48 // // validate
49 // JUnitTestCase.assertSame(null, _pattern.matches(_element));
50 // }
51 //
52 // static dartSuite() {
53 // _ut.group('AndSearchPatternTest', () {
54 // _ut.test('test_ExactName', () {
55 // final __test = new AndSearchPatternTest();
56 // runJUnitTest(__test, __test.test_ExactName);
57 // });
58 // _ut.test('test_NameExact', () {
59 // final __test = new AndSearchPatternTest();
60 // runJUnitTest(__test, __test.test_NameExact);
61 // });
62 // _ut.test('test_allExact', () {
63 // final __test = new AndSearchPatternTest();
64 // runJUnitTest(__test, __test.test_allExact);
65 // });
66 // _ut.test('test_oneNull', () {
67 // final __test = new AndSearchPatternTest();
68 // runJUnitTest(__test, __test.test_oneNull);
69 // });
70 // });
71 // }
72 //}
73 //
74 //class CamelCaseSearchPatternTest extends EngineTestCase {
75 // void test_matchExact_samePartCount() {
76 // Element element = mock(Element);
77 // when(element.displayName).thenReturn("HashMap");
78 // //
79 // CamelCaseSearchPattern pattern = new CamelCaseSearchPattern("HM", true);
80 // JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(element));
81 // }
82 //
83 // void test_matchExact_withLowerCase() {
84 // Element element = mock(Element);
85 // when(element.displayName).thenReturn("HashMap");
86 // //
87 // CamelCaseSearchPattern pattern = new CamelCaseSearchPattern("HaMa", true);
88 // JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(element));
89 // }
90 //
91 // void test_matchNot_nullName() {
92 // Element element = mock(Element);
93 // when(element.displayName).thenReturn(null);
94 // //
95 // CamelCaseSearchPattern pattern = new CamelCaseSearchPattern("HM", true);
96 // JUnitTestCase.assertSame(null, pattern.matches(element));
97 // }
98 //
99 // void test_matchNot_samePartCount() {
100 // Element element = mock(Element);
101 // when(element.displayName).thenReturn("LinkedHashMap");
102 // //
103 // CamelCaseSearchPattern pattern = new CamelCaseSearchPattern("LH", true);
104 // JUnitTestCase.assertSame(null, pattern.matches(element));
105 // }
106 //
107 // void test_matchNot_withLowerCase() {
108 // Element element = mock(Element);
109 // when(element.displayName).thenReturn("HashMap");
110 // //
111 // CamelCaseSearchPattern pattern = new CamelCaseSearchPattern("HaMu", true);
112 // JUnitTestCase.assertSame(null, pattern.matches(element));
113 // }
114 //
115 // static dartSuite() {
116 // _ut.group('CamelCaseSearchPatternTest', () {
117 // _ut.test('test_matchExact_samePartCount', () {
118 // final __test = new CamelCaseSearchPatternTest();
119 // runJUnitTest(__test, __test.test_matchExact_samePartCount);
120 // });
121 // _ut.test('test_matchExact_withLowerCase', () {
122 // final __test = new CamelCaseSearchPatternTest();
123 // runJUnitTest(__test, __test.test_matchExact_withLowerCase);
124 // });
125 // _ut.test('test_matchNot_nullName', () {
126 // final __test = new CamelCaseSearchPatternTest();
127 // runJUnitTest(__test, __test.test_matchNot_nullName);
128 // });
129 // _ut.test('test_matchNot_samePartCount', () {
130 // final __test = new CamelCaseSearchPatternTest();
131 // runJUnitTest(__test, __test.test_matchNot_samePartCount);
132 // });
133 // _ut.test('test_matchNot_withLowerCase', () {
134 // final __test = new CamelCaseSearchPatternTest();
135 // runJUnitTest(__test, __test.test_matchNot_withLowerCase);
136 // });
137 // });
138 // }
139 //}
140 //
141 //class CountingSearchListenerTest extends EngineTestCase {
142 // void test_matchFound() {
143 // SearchListener listener = mock(SearchListener);
144 // SearchMatch match = mock(SearchMatch);
145 // SearchListener countingListener = new CountingSearchListener(2, listener);
146 // // "match" should be passed to "listener"
147 // countingListener.matchFound(match);
148 // verify(listener).matchFound(match);
149 // verifyNoMoreInteractions(listener);
150 // }
151 //
152 // void test_searchComplete() {
153 // SearchListener listener = mock(SearchListener);
154 // SearchListener countingListener = new CountingSearchListener(2, listener);
155 // // complete 2 -> 1
156 // countingListener.searchComplete();
157 // verifyZeroInteractions(listener);
158 // // complete 2 -> 0
159 // countingListener.searchComplete();
160 // verify(listener).searchComplete();
161 // }
162 //
163 // void test_searchComplete_zero() {
164 // SearchListener listener = mock(SearchListener);
165 // new CountingSearchListener(0, listener);
166 // // complete at 0
167 // verify(listener).searchComplete();
168 // }
169 //
170 // static dartSuite() {
171 // _ut.group('CountingSearchListenerTest', () {
172 // _ut.test('test_matchFound', () {
173 // final __test = new CountingSearchListenerTest();
174 // runJUnitTest(__test, __test.test_matchFound);
175 // });
176 // _ut.test('test_searchComplete', () {
177 // final __test = new CountingSearchListenerTest();
178 // runJUnitTest(__test, __test.test_searchComplete);
179 // });
180 // _ut.test('test_searchComplete_zero', () {
181 // final __test = new CountingSearchListenerTest();
182 // runJUnitTest(__test, __test.test_searchComplete_zero);
183 // });
184 // });
185 // }
186 //}
187 //
188 //class ExactSearchPatternTest extends EngineTestCase {
189 // Element _element = mock(Element);
190 //
191 // void test_caseInsensitive_false() {
192 // SearchPattern pattern = new ExactSearchPattern("HashMa", false);
193 // when(_element.displayName).thenReturn("HashMap");
194 // // validate
195 // JUnitTestCase.assertSame(null, pattern.matches(_element));
196 // }
197 //
198 // void test_caseInsensitive_true() {
199 // SearchPattern pattern = new ExactSearchPattern("HashMap", false);
200 // when(_element.displayName).thenReturn("HashMaP");
201 // // validate
202 // JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element));
203 // }
204 //
205 // void test_caseSensitive_false() {
206 // SearchPattern pattern = new ExactSearchPattern("HashMa", true);
207 // when(_element.displayName).thenReturn("HashMap");
208 // // validate
209 // JUnitTestCase.assertSame(null, pattern.matches(_element));
210 // }
211 //
212 // void test_caseSensitive_true() {
213 // SearchPattern pattern = new ExactSearchPattern("HashMap", true);
214 // when(_element.displayName).thenReturn("HashMap");
215 // // validate
216 // JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element));
217 // }
218 //
219 // void test_nullName() {
220 // SearchPattern pattern = new ExactSearchPattern("HashMap", true);
221 // when(_element.displayName).thenReturn(null);
222 // // validate
223 // JUnitTestCase.assertSame(null, pattern.matches(_element));
224 // }
225 //
226 // static dartSuite() {
227 // _ut.group('ExactSearchPatternTest', () {
228 // _ut.test('test_caseInsensitive_false', () {
229 // final __test = new ExactSearchPatternTest();
230 // runJUnitTest(__test, __test.test_caseInsensitive_false);
231 // });
232 // _ut.test('test_caseInsensitive_true', () {
233 // final __test = new ExactSearchPatternTest();
234 // runJUnitTest(__test, __test.test_caseInsensitive_true);
235 // });
236 // _ut.test('test_caseSensitive_false', () {
237 // final __test = new ExactSearchPatternTest();
238 // runJUnitTest(__test, __test.test_caseSensitive_false);
239 // });
240 // _ut.test('test_caseSensitive_true', () {
241 // final __test = new ExactSearchPatternTest();
242 // runJUnitTest(__test, __test.test_caseSensitive_true);
243 // });
244 // _ut.test('test_nullName', () {
245 // final __test = new ExactSearchPatternTest();
246 // runJUnitTest(__test, __test.test_nullName);
247 // });
248 // });
249 // }
250 //}
251 //
252 //class FilterSearchListenerTest extends EngineTestCase {
253 // SearchListener _listener = mock(SearchListener);
254 //
255 // SearchMatch _match = mock(SearchMatch);
256 //
257 // SearchFilter _filter = mock(SearchFilter);
258 //
259 // SearchListener _filteredListener = new FilteredSearchListener(_filter, _list ener);
260 //
261 // void test_matchFound_filterFalse() {
262 // when(_filter.passes(_match)).thenReturn(false);
263 // // "match" should be passed to "listener"
264 // _filteredListener.matchFound(_match);
265 // verifyNoMoreInteractions(_listener);
266 // }
267 //
268 // void test_matchFound_filterTrue() {
269 // when(_filter.passes(_match)).thenReturn(true);
270 // // "match" should be passed to "listener"
271 // _filteredListener.matchFound(_match);
272 // verify(_listener).matchFound(_match);
273 // verifyNoMoreInteractions(_listener);
274 // }
275 //
276 // void test_searchComplete() {
277 // _filteredListener.searchComplete();
278 // verify(_listener).searchComplete();
279 // verifyNoMoreInteractions(_listener);
280 // }
281 //
282 // static dartSuite() {
283 // _ut.group('FilterSearchListenerTest', () {
284 // _ut.test('test_matchFound_filterFalse', () {
285 // final __test = new FilterSearchListenerTest();
286 // runJUnitTest(__test, __test.test_matchFound_filterFalse);
287 // });
288 // _ut.test('test_matchFound_filterTrue', () {
289 // final __test = new FilterSearchListenerTest();
290 // runJUnitTest(__test, __test.test_matchFound_filterTrue);
291 // });
292 // _ut.test('test_searchComplete', () {
293 // final __test = new FilterSearchListenerTest();
294 // runJUnitTest(__test, __test.test_searchComplete);
295 // });
296 // });
297 // }
298 //}
299 //
300 //class GatheringSearchListenerTest extends EngineTestCase {
301 // SearchMatch _matchA = mock(SearchMatch);
302 //
303 // SearchMatch _matchB = mock(SearchMatch);
304 //
305 // GatheringSearchListener _gatheringListener = new GatheringSearchListener();
306 //
307 // void test_matchFound() {
308 // Element elementA = mock(Element);
309 // Element elementB = mock(Element);
310 // when(elementA.displayName).thenReturn("A");
311 // when(elementB.displayName).thenReturn("B");
312 // when(_matchA.element).thenReturn(elementA);
313 // when(_matchB.element).thenReturn(elementB);
314 // // matchB
315 // _gatheringListener.matchFound(_matchB);
316 // JUnitTestCase.assertFalse(_gatheringListener.isComplete);
317 // assertThat(_gatheringListener.matches).containsExactly(_matchB);
318 // // matchA
319 // _gatheringListener.matchFound(_matchA);
320 // JUnitTestCase.assertFalse(_gatheringListener.isComplete);
321 // assertThat(_gatheringListener.matches).containsExactly(_matchA, _matchB);
322 // }
323 //
324 // void test_searchComplete() {
325 // JUnitTestCase.assertFalse(_gatheringListener.isComplete);
326 // // complete
327 // _gatheringListener.searchComplete();
328 // JUnitTestCase.assertTrue(_gatheringListener.isComplete);
329 // }
330 //
331 // static dartSuite() {
332 // _ut.group('GatheringSearchListenerTest', () {
333 // _ut.test('test_matchFound', () {
334 // final __test = new GatheringSearchListenerTest();
335 // runJUnitTest(__test, __test.test_matchFound);
336 // });
337 // _ut.test('test_searchComplete', () {
338 // final __test = new GatheringSearchListenerTest();
339 // runJUnitTest(__test, __test.test_searchComplete);
340 // });
341 // });
342 // }
343 //}
344 //
345 //class LibrarySearchScopeTest extends EngineTestCase {
346 // LibraryElement _libraryA = mock(LibraryElement);
347 //
348 // LibraryElement _libraryB = mock(LibraryElement);
349 //
350 // Element _element = mock(Element);
351 //
352 // void test_arrayConstructor_inA_false() {
353 // when(_element.getAncestor((element) => element is LibraryElement)).thenRet urn(_libraryB);
354 // LibrarySearchScope scope = new LibrarySearchScope.con2([_libraryA]);
355 // assertThat(scope.libraries).containsOnly(_libraryA);
356 // JUnitTestCase.assertFalse(scope.encloses(_element));
357 // }
358 //
359 // void test_arrayConstructor_inA_true() {
360 // when(_element.getAncestor((element) => element is LibraryElement)).thenRet urn(_libraryA);
361 // LibrarySearchScope scope = new LibrarySearchScope.con2([_libraryA, _librar yB]);
362 // assertThat(scope.libraries).containsOnly(_libraryA, _libraryB);
363 // JUnitTestCase.assertTrue(scope.encloses(_element));
364 // }
365 //
366 // void test_collectionConstructor_inB() {
367 // when(_element.getAncestor((element) => element is LibraryElement)).thenRet urn(_libraryB);
368 // LibrarySearchScope scope = new LibrarySearchScope.con1(ImmutableSet.of(_li braryA, _libraryB));
369 // assertThat(scope.libraries).containsOnly(_libraryA, _libraryB);
370 // JUnitTestCase.assertTrue(scope.encloses(_element));
371 // }
372 //
373 // static dartSuite() {
374 // _ut.group('LibrarySearchScopeTest', () {
375 // _ut.test('test_arrayConstructor_inA_false', () {
376 // final __test = new LibrarySearchScopeTest();
377 // runJUnitTest(__test, __test.test_arrayConstructor_inA_false);
378 // });
379 // _ut.test('test_arrayConstructor_inA_true', () {
380 // final __test = new LibrarySearchScopeTest();
381 // runJUnitTest(__test, __test.test_arrayConstructor_inA_true);
382 // });
383 // _ut.test('test_collectionConstructor_inB', () {
384 // final __test = new LibrarySearchScopeTest();
385 // runJUnitTest(__test, __test.test_collectionConstructor_inB);
386 // });
387 // });
388 // }
389 //}
390 //
391 //class NameMatchingSearchListenerTest extends EngineTestCase {
392 // SearchListener _listener = mock(SearchListener);
393 //
394 // Element _element = mock(Element);
395 //
396 // SearchMatch _match = mock(SearchMatch);
397 //
398 // SearchPattern _pattern = mock(SearchPattern);
399 //
400 // SearchListener _nameMatchingListener = new NameMatchingSearchListener(_patte rn, _listener);
401 //
402 // void test_matchFound_patternFalse() {
403 // when(_pattern.matches(_element)).thenReturn(null);
404 // // verify
405 // _nameMatchingListener.matchFound(_match);
406 // verifyNoMoreInteractions(_listener);
407 // }
408 //
409 // void test_matchFound_patternTrue() {
410 // when(_pattern.matches(_element)).thenReturn(MatchQuality.EXACT);
411 // // verify
412 // _nameMatchingListener.matchFound(_match);
413 // verify(_listener).matchFound(_match);
414 // verifyNoMoreInteractions(_listener);
415 // }
416 //
417 // @override
418 // void setUp() {
419 // super.setUp();
420 // when(_match.element).thenReturn(_element);
421 // }
422 //
423 // static dartSuite() {
424 // _ut.group('NameMatchingSearchListenerTest', () {
425 // _ut.test('test_matchFound_patternFalse', () {
426 // final __test = new NameMatchingSearchListenerTest();
427 // runJUnitTest(__test, __test.test_matchFound_patternFalse);
428 // });
429 // _ut.test('test_matchFound_patternTrue', () {
430 // final __test = new NameMatchingSearchListenerTest();
431 // runJUnitTest(__test, __test.test_matchFound_patternTrue);
432 // });
433 // });
434 // }
435 //}
436 //
437 //class OrSearchPatternTest extends EngineTestCase {
438 // Element _element = mock(Element);
439 //
440 // SearchPattern _patternA = mock(SearchPattern);
441 //
442 // SearchPattern _patternB = mock(SearchPattern);
443 //
444 // SearchPattern _pattern = new OrSearchPattern([_patternA, _patternB]);
445 //
446 // void test_allExact() {
447 // when(_patternA.matches(_element)).thenReturn(MatchQuality.EXACT);
448 // when(_patternB.matches(_element)).thenReturn(MatchQuality.EXACT);
449 // // validate
450 // JUnitTestCase.assertSame(MatchQuality.EXACT, _pattern.matches(_element));
451 // }
452 //
453 // void test_ExactName() {
454 // when(_patternA.matches(_element)).thenReturn(MatchQuality.EXACT);
455 // when(_patternB.matches(_element)).thenReturn(MatchQuality.NAME);
456 // // validate
457 // JUnitTestCase.assertSame(MatchQuality.EXACT, _pattern.matches(_element));
458 // }
459 //
460 // void test_NameExact() {
461 // when(_patternA.matches(_element)).thenReturn(MatchQuality.NAME);
462 // when(_patternB.matches(_element)).thenReturn(MatchQuality.EXACT);
463 // // validate
464 // JUnitTestCase.assertSame(MatchQuality.NAME, _pattern.matches(_element));
465 // }
466 //
467 // void test_NullNull() {
468 // when(_patternA.matches(_element)).thenReturn(null);
469 // when(_patternB.matches(_element)).thenReturn(null);
470 // // validate
471 // JUnitTestCase.assertSame(null, _pattern.matches(_element));
472 // }
473 //
474 // static dartSuite() {
475 // _ut.group('OrSearchPatternTest', () {
476 // _ut.test('test_ExactName', () {
477 // final __test = new OrSearchPatternTest();
478 // runJUnitTest(__test, __test.test_ExactName);
479 // });
480 // _ut.test('test_NameExact', () {
481 // final __test = new OrSearchPatternTest();
482 // runJUnitTest(__test, __test.test_NameExact);
483 // });
484 // _ut.test('test_NullNull', () {
485 // final __test = new OrSearchPatternTest();
486 // runJUnitTest(__test, __test.test_NullNull);
487 // });
488 // _ut.test('test_allExact', () {
489 // final __test = new OrSearchPatternTest();
490 // runJUnitTest(__test, __test.test_allExact);
491 // });
492 // });
493 // }
494 //}
495 //
496 //class PrefixSearchPatternTest extends EngineTestCase {
497 // Element _element = mock(Element);
498 //
499 // void test_caseInsensitive_contentMatch_caseMatch() {
500 // SearchPattern pattern = new PrefixSearchPattern("HashMa", false);
501 // when(_element.displayName).thenReturn("HashMap");
502 // // validate
503 // JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element));
504 // }
505 //
506 // void test_caseInsensitive_contentMatch_caseMismatch() {
507 // SearchPattern pattern = new PrefixSearchPattern("HaSHMa", false);
508 // when(_element.displayName).thenReturn("hashMaP");
509 // // validate
510 // JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element));
511 // }
512 //
513 // void test_caseInsensitive_contentMismatch() {
514 // SearchPattern pattern = new PrefixSearchPattern("HashMa", false);
515 // when(_element.displayName).thenReturn("HashTable");
516 // // validate
517 // JUnitTestCase.assertSame(null, pattern.matches(_element));
518 // }
519 //
520 // void test_caseSensitive_contentMatch() {
521 // SearchPattern pattern = new PrefixSearchPattern("HashMa", true);
522 // when(_element.displayName).thenReturn("HashMap");
523 // // validate
524 // JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element));
525 // }
526 //
527 // void test_caseSensitive_contentMismatch() {
528 // SearchPattern pattern = new PrefixSearchPattern("HashMa", true);
529 // when(_element.displayName).thenReturn("HashTable");
530 // // validate
531 // JUnitTestCase.assertSame(null, pattern.matches(_element));
532 // }
533 //
534 // void test_nullElement() {
535 // SearchPattern pattern = new PrefixSearchPattern("HashMa", false);
536 // // validate
537 // JUnitTestCase.assertSame(null, pattern.matches(null));
538 // }
539 //
540 // void test_nullName() {
541 // SearchPattern pattern = new PrefixSearchPattern("HashMa", false);
542 // when(_element.displayName).thenReturn(null);
543 // // validate
544 // JUnitTestCase.assertSame(null, pattern.matches(_element));
545 // }
546 //
547 // static dartSuite() {
548 // _ut.group('PrefixSearchPatternTest', () {
549 // _ut.test('test_caseInsensitive_contentMatch_caseMatch', () {
550 // final __test = new PrefixSearchPatternTest();
551 // runJUnitTest(__test, __test.test_caseInsensitive_contentMatch_caseMatc h);
552 // });
553 // _ut.test('test_caseInsensitive_contentMatch_caseMismatch', () {
554 // final __test = new PrefixSearchPatternTest();
555 // runJUnitTest(__test, __test.test_caseInsensitive_contentMatch_caseMism atch);
556 // });
557 // _ut.test('test_caseInsensitive_contentMismatch', () {
558 // final __test = new PrefixSearchPatternTest();
559 // runJUnitTest(__test, __test.test_caseInsensitive_contentMismatch);
560 // });
561 // _ut.test('test_caseSensitive_contentMatch', () {
562 // final __test = new PrefixSearchPatternTest();
563 // runJUnitTest(__test, __test.test_caseSensitive_contentMatch);
564 // });
565 // _ut.test('test_caseSensitive_contentMismatch', () {
566 // final __test = new PrefixSearchPatternTest();
567 // runJUnitTest(__test, __test.test_caseSensitive_contentMismatch);
568 // });
569 // _ut.test('test_nullElement', () {
570 // final __test = new PrefixSearchPatternTest();
571 // runJUnitTest(__test, __test.test_nullElement);
572 // });
573 // _ut.test('test_nullName', () {
574 // final __test = new PrefixSearchPatternTest();
575 // runJUnitTest(__test, __test.test_nullName);
576 // });
577 // });
578 // }
579 //}
580 //
581 //class RegularExpressionSearchPatternTest extends EngineTestCase {
582 // Element _element = mock(Element);
583 //
584 // void test_caseInsensitive_false_contentMismatch() {
585 // SearchPattern pattern = new RegularExpressionSearchPattern("H[a-z]*Map", f alse);
586 // when(_element.displayName).thenReturn("Maps");
587 // // validate
588 // JUnitTestCase.assertSame(null, pattern.matches(_element));
589 // }
590 //
591 // void test_caseInsensitive_true_caseMismatch() {
592 // SearchPattern pattern = new RegularExpressionSearchPattern("H[a-z]*MaP", f alse);
593 // when(_element.displayName).thenReturn("HashMap");
594 // // validate
595 // JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element));
596 // }
597 //
598 // void test_caseSensitive_false_caseMismatch() {
599 // SearchPattern pattern = new RegularExpressionSearchPattern("H[a-z]*MaP", t rue);
600 // when(_element.displayName).thenReturn("HashMap");
601 // // validate
602 // JUnitTestCase.assertSame(null, pattern.matches(_element));
603 // }
604 //
605 // void test_caseSensitive_false_contentMismatch() {
606 // SearchPattern pattern = new RegularExpressionSearchPattern("H[a-z]*Map", t rue);
607 // when(_element.displayName).thenReturn("Maps");
608 // // validate
609 // JUnitTestCase.assertSame(null, pattern.matches(_element));
610 // }
611 //
612 // void test_caseSensitive_true() {
613 // SearchPattern pattern = new RegularExpressionSearchPattern("H.*Map", true) ;
614 // when(_element.displayName).thenReturn("HashMap");
615 // // validate
616 // JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element));
617 // }
618 //
619 // void test_nullElement() {
620 // SearchPattern pattern = new RegularExpressionSearchPattern("H.*Map", true) ;
621 // // validate
622 // JUnitTestCase.assertSame(null, pattern.matches(null));
623 // }
624 //
625 // void test_nullName() {
626 // SearchPattern pattern = new RegularExpressionSearchPattern("H.*Map", true) ;
627 // when(_element.displayName).thenReturn(null);
628 // // validate
629 // JUnitTestCase.assertSame(null, pattern.matches(_element));
630 // }
631 //
632 // static dartSuite() {
633 // _ut.group('RegularExpressionSearchPatternTest', () {
634 // _ut.test('test_caseInsensitive_false_contentMismatch', () {
635 // final __test = new RegularExpressionSearchPatternTest();
636 // runJUnitTest(__test, __test.test_caseInsensitive_false_contentMismatch );
637 // });
638 // _ut.test('test_caseInsensitive_true_caseMismatch', () {
639 // final __test = new RegularExpressionSearchPatternTest();
640 // runJUnitTest(__test, __test.test_caseInsensitive_true_caseMismatch);
641 // });
642 // _ut.test('test_caseSensitive_false_caseMismatch', () {
643 // final __test = new RegularExpressionSearchPatternTest();
644 // runJUnitTest(__test, __test.test_caseSensitive_false_caseMismatch);
645 // });
646 // _ut.test('test_caseSensitive_false_contentMismatch', () {
647 // final __test = new RegularExpressionSearchPatternTest();
648 // runJUnitTest(__test, __test.test_caseSensitive_false_contentMismatch);
649 // });
650 // _ut.test('test_caseSensitive_true', () {
651 // final __test = new RegularExpressionSearchPatternTest();
652 // runJUnitTest(__test, __test.test_caseSensitive_true);
653 // });
654 // _ut.test('test_nullElement', () {
655 // final __test = new RegularExpressionSearchPatternTest();
656 // runJUnitTest(__test, __test.test_nullElement);
657 // });
658 // _ut.test('test_nullName', () {
659 // final __test = new RegularExpressionSearchPatternTest();
660 // runJUnitTest(__test, __test.test_nullName);
661 // });
662 // });
663 // }
664 //}
665 //
666 //class SearchEngineImplTest extends EngineTestCase {
667 // static void _assertMatches(List<SearchMatch> matches, List<SearchEngineImplT est_ExpectedMatch> expectedMatches) {
668 // assertThat(matches).hasSize(expectedMatches.length);
669 // for (SearchMatch match in matches) {
670 // bool found = false;
671 // String msg = match.toString();
672 // for (SearchEngineImplTest_ExpectedMatch expectedMatch in expectedMatches ) {
673 // if (match.element == expectedMatch._element && match.kind == expectedM atch._kind && match.quality == expectedMatch._quality && match.sourceRange == ex pectedMatch._range && match.isQualified == expectedMatch._qualified) {
674 // found = true;
675 // break;
676 // }
677 // }
678 // if (!found) {
679 // JUnitTestCase.fail("Not found: ${msg}");
680 // }
681 // }
682 // }
683 //
684 // IndexStore _indexStore = IndexFactory.newSplitIndexStore(new MemoryNodeManag er());
685 //
686 // static AnalysisContext _CONTEXT = mock(AnalysisContext);
687 //
688 // int _nextLocationId = 0;
689 //
690 // SearchScope _scope;
691 //
692 // SearchPattern _pattern = null;
693 //
694 // SearchFilter _filter = null;
695 //
696 // Source _source = mock(Source);
697 //
698 // CompilationUnitElement _unitElement = mock(CompilationUnitElement);
699 //
700 // LibraryElement _libraryElement = mock(LibraryElement);
701 //
702 // Element _elementA = _mockElement(Element, ElementKind.CLASS);
703 //
704 // Element _elementB = _mockElement(Element, ElementKind.CLASS);
705 //
706 // Element _elementC = _mockElement(Element, ElementKind.CLASS);
707 //
708 // Element _elementD = _mockElement(Element, ElementKind.CLASS);
709 //
710 // Element _elementE = _mockElement(Element, ElementKind.CLASS);
711 //
712 // void fail_searchAssignedTypes_assignments() {
713 // // TODO(scheglov) does not work - new split index store cannot store types (yet?)
714 // PropertyAccessorElement setterElement = _mockElement(PropertyAccessorEleme nt, ElementKind.SETTER);
715 // FieldElement fieldElement = _mockElement(FieldElement, ElementKind.FIELD);
716 // when(fieldElement.setter).thenReturn(setterElement);
717 // DartType typeA = mock(DartType);
718 // DartType typeB = mock(DartType);
719 // DartType typeC = mock(DartType);
720 // _indexStore.aboutToIndexDart(_CONTEXT, _unitElement);
721 // {
722 // Location location = new Location(_elementA, 1, 10);
723 // location = new LocationWithData<DartType>.con1(location, typeA);
724 // _indexStore.recordRelationship(setterElement, IndexConstants.IS_REFERENC ED_BY_QUALIFIED, location);
725 // }
726 // {
727 // Location location = new Location(_elementB, 2, 20);
728 // location = new LocationWithData<DartType>.con1(location, typeB);
729 // _indexStore.recordRelationship(setterElement, IndexConstants.IS_REFERENC ED_BY_UNQUALIFIED, location);
730 // }
731 // // will be filtered by scope
732 // {
733 // Location location = new Location(_elementC, 3, 30);
734 // location = new LocationWithData<DartType>.con1(location, typeC);
735 // _indexStore.recordRelationship(setterElement, IndexConstants.IS_REFERENC ED_BY_QUALIFIED, location);
736 // }
737 // // not LocationWithData
738 // {
739 // Location location = new Location(_elementD, 4, 40);
740 // _indexStore.recordRelationship(setterElement, IndexConstants.IS_REFERENC ED_BY_QUALIFIED, location);
741 // }
742 // _indexStore.doneIndex();
743 // // ask types
744 // Set<DartType> types = _runSearch(new SearchRunner_SearchEngineImplTest_fai l_searchAssignedTypes_assignments(fieldElement));
745 // assertThat(types).containsOnly(typeA, typeB);
746 // }
747 //
748 // void fail_searchAssignedTypes_initializers() {
749 // // TODO(scheglov) does not work - new split index store cannot store types (yet?)
750 // FieldElement fieldElement = _mockElement(FieldElement, ElementKind.FIELD);
751 // DartType typeA = mock(DartType);
752 // DartType typeB = mock(DartType);
753 // {
754 // Location location = new Location(_elementA, 10, 1);
755 // location = new LocationWithData<DartType>.con1(location, typeA);
756 // _indexStore.recordRelationship(fieldElement, IndexConstants.IS_DEFINED_B Y, location);
757 // }
758 // {
759 // Location location = new Location(_elementB, 20, 1);
760 // location = new LocationWithData<DartType>.con1(location, typeB);
761 // _indexStore.recordRelationship(fieldElement, IndexConstants.IS_REFERENCE D_BY, location);
762 // }
763 // _indexStore.doneIndex();
764 // // ask types
765 // Set<DartType> types = _runSearch(new SearchRunner_SearchEngineImplTest_fai l_searchAssignedTypes_initializers(fieldElement));
766 // assertThat(types).containsOnly(typeA, typeB);
767 // }
768 //
769 // void test_searchDeclarations_String() {
770 // Element referencedElement = new NameElementImpl("test");
771 // {
772 // Location locationA = new Location(_elementA, 1, 2);
773 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_DEFI NED_BY, locationA);
774 // }
775 // {
776 // Location locationB = new Location(_elementB, 10, 20);
777 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_DEFI NED_BY, locationB);
778 // }
779 // _indexStore.doneIndex();
780 // // search matches
781 // List<SearchMatch> matches = _runSearch(new SearchRunner_SearchEngineImplTe st_test_searchDeclarations_String(this));
782 // // verify
783 // _assertMatches(matches, [
784 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.NAME_ DECLARATION, 1, 2),
785 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.NAME_ DECLARATION, 10, 20)]);
786 // }
787 //
788 // void test_searchFunctionDeclarations() {
789 // LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY) ;
790 // _defineFunctionsAB(library);
791 // _scope = new LibrarySearchScope.con2([library]);
792 // // search matches
793 // List<SearchMatch> matches = _searchFunctionDeclarationsSync();
794 // // verify
795 // _assertMatches(matches, [
796 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.FUNCT ION_DECLARATION, 1, 2),
797 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.FUNCT ION_DECLARATION, 10, 20)]);
798 // }
799 //
800 // void test_searchFunctionDeclarations_async() {
801 // LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY) ;
802 // _defineFunctionsAB(library);
803 // _scope = new LibrarySearchScope.con2([library]);
804 // // search matches
805 // List<SearchMatch> matches = _searchFunctionDeclarationsAsync();
806 // // verify
807 // _assertMatches(matches, [
808 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.FUNCT ION_DECLARATION, 1, 2),
809 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.FUNCT ION_DECLARATION, 10, 20)]);
810 // }
811 //
812 // void test_searchFunctionDeclarations_inUniverse() {
813 // {
814 // Location locationA = new Location(_elementA, 1, 2);
815 // _indexStore.recordRelationship(IndexConstants.UNIVERSE, IndexConstants.D EFINES_FUNCTION, locationA);
816 // }
817 // {
818 // Location locationB = new Location(_elementB, 10, 20);
819 // _indexStore.recordRelationship(IndexConstants.UNIVERSE, IndexConstants.D EFINES_FUNCTION, locationB);
820 // }
821 // _indexStore.doneIndex();
822 // _scope = SearchScopeFactory.createUniverseScope();
823 // // search matches
824 // List<SearchMatch> matches = _searchFunctionDeclarationsSync();
825 // // verify
826 // _assertMatches(matches, [
827 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.FUNCT ION_DECLARATION, 1, 2),
828 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.FUNCT ION_DECLARATION, 10, 20)]);
829 // }
830 //
831 // void test_searchFunctionDeclarations_useFilter() {
832 // LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY) ;
833 // _defineFunctionsAB(library);
834 // _scope = new LibrarySearchScope.con2([library]);
835 // // search "elementA"
836 // {
837 // _filter = new SearchFilter_SearchEngineImplTest_test_searchFunctionDecla rations_useFilter_2(this);
838 // List<SearchMatch> matches = _searchFunctionDeclarationsSync();
839 // _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_el ementA, MatchKind.FUNCTION_DECLARATION, 1, 2)]);
840 // }
841 // // search "elementB"
842 // {
843 // _filter = new SearchFilter_SearchEngineImplTest_test_searchFunctionDecla rations_useFilter(this);
844 // List<SearchMatch> matches = _searchFunctionDeclarationsSync();
845 // _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_el ementB, MatchKind.FUNCTION_DECLARATION, 10, 20)]);
846 // }
847 // }
848 //
849 // void test_searchFunctionDeclarations_usePattern() {
850 // LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY) ;
851 // _defineFunctionsAB(library);
852 // _scope = new LibrarySearchScope.con2([library]);
853 // // search "A"
854 // {
855 // _pattern = SearchPatternFactory.createExactPattern("A", true);
856 // List<SearchMatch> matches = _searchFunctionDeclarationsSync();
857 // _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_el ementA, MatchKind.FUNCTION_DECLARATION, 1, 2)]);
858 // }
859 // // search "B"
860 // {
861 // _pattern = SearchPatternFactory.createExactPattern("B", true);
862 // List<SearchMatch> matches = _searchFunctionDeclarationsSync();
863 // _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_el ementB, MatchKind.FUNCTION_DECLARATION, 10, 20)]);
864 // }
865 // }
866 //
867 // void test_searchReferences_AngularComponentElement() {
868 // AngularComponentElement referencedElement = _mockElement(AngularComponentE lement, ElementKind.ANGULAR_COMPONENT);
869 // {
870 // Location locationA = new Location(_elementA, 1, 2);
871 // _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR _REFERENCE, locationA);
872 // }
873 // {
874 // Location locationB = new Location(_elementB, 10, 20);
875 // _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR _CLOSING_TAG_REFERENCE, locationB);
876 // }
877 // _indexStore.doneIndex();
878 // // search matches
879 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
880 // _assertMatches(matches, [
881 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.ANGUL AR_REFERENCE, 1, 2),
882 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.ANGUL AR_CLOSING_TAG_REFERENCE, 10, 20)]);
883 // }
884 //
885 // void test_searchReferences_AngularControllerElement() {
886 // AngularControllerElement referencedElement = _mockElement(AngularControlle rElement, ElementKind.ANGULAR_CONTROLLER);
887 // {
888 // Location locationA = new Location(_elementA, 1, 2);
889 // _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR _REFERENCE, locationA);
890 // }
891 // {
892 // Location locationB = new Location(_elementB, 10, 20);
893 // _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR _REFERENCE, locationB);
894 // }
895 // _indexStore.doneIndex();
896 // // search matches
897 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
898 // _assertMatches(matches, [
899 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.ANGUL AR_REFERENCE, 1, 2),
900 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.ANGUL AR_REFERENCE, 10, 20)]);
901 // }
902 //
903 // void test_searchReferences_AngularFilterElement() {
904 // AngularFormatterElement referencedElement = _mockElement(AngularFormatterE lement, ElementKind.ANGULAR_FORMATTER);
905 // {
906 // Location locationA = new Location(_elementA, 1, 2);
907 // _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR _REFERENCE, locationA);
908 // }
909 // {
910 // Location locationB = new Location(_elementB, 10, 20);
911 // _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR _REFERENCE, locationB);
912 // }
913 // _indexStore.doneIndex();
914 // // search matches
915 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
916 // _assertMatches(matches, [
917 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.ANGUL AR_REFERENCE, 1, 2),
918 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.ANGUL AR_REFERENCE, 10, 20)]);
919 // }
920 //
921 // void test_searchReferences_AngularPropertyElement() {
922 // AngularPropertyElement referencedElement = _mockElement(AngularPropertyEle ment, ElementKind.ANGULAR_PROPERTY);
923 // {
924 // Location locationA = new Location(_elementA, 1, 2);
925 // _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR _REFERENCE, locationA);
926 // }
927 // {
928 // Location locationB = new Location(_elementB, 10, 20);
929 // _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR _REFERENCE, locationB);
930 // }
931 // _indexStore.doneIndex();
932 // // search matches
933 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
934 // _assertMatches(matches, [
935 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.ANGUL AR_REFERENCE, 1, 2),
936 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.ANGUL AR_REFERENCE, 10, 20)]);
937 // }
938 //
939 // void test_searchReferences_AngularScopePropertyElement() {
940 // AngularScopePropertyElement referencedElement = _mockElement(AngularScopeP ropertyElement, ElementKind.ANGULAR_SCOPE_PROPERTY);
941 // {
942 // Location locationA = new Location(_elementA, 1, 2);
943 // _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR _REFERENCE, locationA);
944 // }
945 // {
946 // Location locationB = new Location(_elementB, 10, 20);
947 // _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR _REFERENCE, locationB);
948 // }
949 // _indexStore.doneIndex();
950 // // search matches
951 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
952 // _assertMatches(matches, [
953 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.ANGUL AR_REFERENCE, 1, 2),
954 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.ANGUL AR_REFERENCE, 10, 20)]);
955 // }
956 //
957 // void test_searchReferences_AngularSelectorElement() {
958 // AngularSelectorElement referencedElement = _mockElement(AngularSelectorEle ment, ElementKind.ANGULAR_SELECTOR);
959 // {
960 // Location locationA = new Location(_elementA, 1, 2);
961 // _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR _REFERENCE, locationA);
962 // }
963 // {
964 // Location locationB = new Location(_elementB, 10, 20);
965 // _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR _REFERENCE, locationB);
966 // }
967 // _indexStore.doneIndex();
968 // // search matches
969 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
970 // _assertMatches(matches, [
971 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.ANGUL AR_REFERENCE, 1, 2),
972 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.ANGUL AR_REFERENCE, 10, 20)]);
973 // }
974 //
975 // void test_searchReferences_ClassElement() {
976 // ClassElement referencedElement = _mockElement(ClassElement, ElementKind.CL ASS);
977 // {
978 // Location locationA = new Location(_elementA, 1, 2);
979 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY, locationA);
980 // }
981 // {
982 // Location locationB = new Location(_elementB, 10, 20);
983 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY, locationB);
984 // }
985 // _indexStore.doneIndex();
986 // // search matches
987 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
988 // // verify
989 // _assertMatches(matches, [
990 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.TYPE_ REFERENCE, 1, 2),
991 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.TYPE_ REFERENCE, 10, 20)]);
992 // }
993 //
994 // void test_searchReferences_ClassElement_useScope() {
995 // LibraryElement libraryA = _mockElement(LibraryElement, ElementKind.LIBRARY );
996 // LibraryElement libraryB = _mockElement(LibraryElement, ElementKind.LIBRARY );
997 // ClassElement referencedElement = _mockElement(ClassElement, ElementKind.CL ASS);
998 // {
999 // when(_elementA.getAncestor((element) => element is LibraryElement)).then Return(libraryA);
1000 // Location locationA = new Location(_elementA, 1, 2);
1001 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY, locationA);
1002 // }
1003 // {
1004 // when(_elementB.getAncestor((element) => element is LibraryElement)).then Return(libraryB);
1005 // Location locationB = new Location(_elementB, 10, 20);
1006 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY, locationB);
1007 // }
1008 // _indexStore.doneIndex();
1009 // // search matches, in "libraryA"
1010 // _scope = SearchScopeFactory.createLibraryScope3(libraryA);
1011 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
1012 // // verify
1013 // _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elem entA, MatchKind.TYPE_REFERENCE, 1, 2)]);
1014 // }
1015 //
1016 // void test_searchReferences_CompilationUnitElement() {
1017 // CompilationUnitElement referencedElement = _mockElement(CompilationUnitEle ment, ElementKind.COMPILATION_UNIT);
1018 // {
1019 // Location location = new Location(_elementA, 1, 2);
1020 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY, location);
1021 // }
1022 // _indexStore.doneIndex();
1023 // // search matches
1024 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
1025 // // verify
1026 // _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elem entA, MatchKind.UNIT_REFERENCE, 1, 2)]);
1027 // }
1028 //
1029 // void test_searchReferences_ConstructorElement() {
1030 // ConstructorElement referencedElement = _mockElement(ConstructorElement, El ementKind.CONSTRUCTOR);
1031 // {
1032 // Location location = new Location(_elementA, 10, 1);
1033 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_DEFI NED_BY, location);
1034 // }
1035 // {
1036 // Location location = new Location(_elementB, 20, 2);
1037 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY, location);
1038 // }
1039 // {
1040 // Location location = new Location(_elementC, 30, 3);
1041 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY, location);
1042 // }
1043 // _indexStore.doneIndex();
1044 // // search matches
1045 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
1046 // // verify
1047 // _assertMatches(matches, [
1048 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.CONST RUCTOR_DECLARATION, 10, 1),
1049 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.CONST RUCTOR_REFERENCE, 20, 2),
1050 // new SearchEngineImplTest_ExpectedMatch.con1(_elementC, MatchKind.CONST RUCTOR_REFERENCE, 30, 3)]);
1051 // }
1052 //
1053 // void test_searchReferences_Element_unknown() {
1054 // List<SearchMatch> matches = _searchReferencesSync(Element, null);
1055 // assertThat(matches).isEmpty();
1056 // }
1057 //
1058 // void test_searchReferences_FieldElement() {
1059 // PropertyAccessorElement getterElement = _mockElement(PropertyAccessorEleme nt, ElementKind.GETTER);
1060 // PropertyAccessorElement setterElement = _mockElement(PropertyAccessorEleme nt, ElementKind.SETTER);
1061 // FieldElement fieldElement = _mockElement(FieldElement, ElementKind.FIELD);
1062 // when(fieldElement.getter).thenReturn(getterElement);
1063 // when(fieldElement.setter).thenReturn(setterElement);
1064 // {
1065 // Location location = new Location(_elementA, 1, 10);
1066 // _indexStore.recordRelationship(getterElement, IndexConstants.IS_REFERENC ED_BY_UNQUALIFIED, location);
1067 // }
1068 // {
1069 // Location location = new Location(_elementB, 2, 20);
1070 // _indexStore.recordRelationship(getterElement, IndexConstants.IS_REFERENC ED_BY_QUALIFIED, location);
1071 // }
1072 // {
1073 // Location location = new Location(_elementC, 3, 30);
1074 // _indexStore.recordRelationship(setterElement, IndexConstants.IS_REFERENC ED_BY_UNQUALIFIED, location);
1075 // }
1076 // {
1077 // Location location = new Location(_elementD, 4, 40);
1078 // _indexStore.recordRelationship(setterElement, IndexConstants.IS_REFERENC ED_BY_QUALIFIED, location);
1079 // }
1080 // _indexStore.doneIndex();
1081 // // search matches
1082 // List<SearchMatch> matches = _searchReferencesSync(Element, fieldElement);
1083 // // verify
1084 // _assertMatches(matches, [
1085 // new SearchEngineImplTest_ExpectedMatch.con2(_elementA, MatchKind.FIELD _READ, 1, 10, false),
1086 // new SearchEngineImplTest_ExpectedMatch.con2(_elementB, MatchKind.FIELD _READ, 2, 20, true),
1087 // new SearchEngineImplTest_ExpectedMatch.con2(_elementC, MatchKind.FIELD _WRITE, 3, 30, false),
1088 // new SearchEngineImplTest_ExpectedMatch.con2(_elementD, MatchKind.FIELD _WRITE, 4, 40, true)]);
1089 // }
1090 //
1091 // void test_searchReferences_FieldElement_invocation() {
1092 // PropertyAccessorElement getterElement = _mockElement(PropertyAccessorEleme nt, ElementKind.GETTER);
1093 // FieldElement fieldElement = _mockElement(FieldElement, ElementKind.FIELD);
1094 // when(fieldElement.getter).thenReturn(getterElement);
1095 // {
1096 // Location location = new Location(_elementA, 1, 10);
1097 // _indexStore.recordRelationship(getterElement, IndexConstants.IS_INVOKED_ BY_QUALIFIED, location);
1098 // }
1099 // {
1100 // Location location = new Location(_elementB, 2, 20);
1101 // _indexStore.recordRelationship(getterElement, IndexConstants.IS_INVOKED_ BY_UNQUALIFIED, location);
1102 // }
1103 // _indexStore.doneIndex();
1104 // // search matches
1105 // List<SearchMatch> matches = _searchReferencesSync(Element, fieldElement);
1106 // // verify
1107 // _assertMatches(matches, [
1108 // new SearchEngineImplTest_ExpectedMatch.con2(_elementA, MatchKind.FIELD _INVOCATION, 1, 10, true),
1109 // new SearchEngineImplTest_ExpectedMatch.con2(_elementB, MatchKind.FIELD _INVOCATION, 2, 20, false)]);
1110 // }
1111 //
1112 // void test_searchReferences_FieldElement2() {
1113 // FieldElement fieldElement = _mockElement(FieldElement, ElementKind.FIELD);
1114 // {
1115 // Location location = new Location(_elementA, 1, 10);
1116 // _indexStore.recordRelationship(fieldElement, IndexConstants.IS_REFERENCE D_BY, location);
1117 // }
1118 // {
1119 // Location location = new Location(_elementB, 2, 20);
1120 // _indexStore.recordRelationship(fieldElement, IndexConstants.IS_REFERENCE D_BY_QUALIFIED, location);
1121 // }
1122 // _indexStore.doneIndex();
1123 // // search matches
1124 // List<SearchMatch> matches = _searchReferencesSync(Element, fieldElement);
1125 // // verify
1126 // _assertMatches(matches, [
1127 // new SearchEngineImplTest_ExpectedMatch.con2(_elementA, MatchKind.FIELD _REFERENCE, 1, 10, false),
1128 // new SearchEngineImplTest_ExpectedMatch.con2(_elementB, MatchKind.FIELD _REFERENCE, 2, 20, true)]);
1129 // }
1130 //
1131 // void test_searchReferences_FunctionElement() {
1132 // FunctionElement referencedElement = _mockElement(FunctionElement, ElementK ind.FUNCTION);
1133 // {
1134 // Location location = new Location(_elementA, 1, 10);
1135 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_INVO KED_BY, location);
1136 // }
1137 // {
1138 // Location location = new Location(_elementB, 2, 20);
1139 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY, location);
1140 // }
1141 // _indexStore.doneIndex();
1142 // // search matches
1143 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
1144 // // verify
1145 // _assertMatches(matches, [
1146 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.FUNCT ION_EXECUTION, 1, 10),
1147 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.FUNCT ION_REFERENCE, 2, 20)]);
1148 // }
1149 //
1150 // void test_searchReferences_ImportElement() {
1151 // ImportElement referencedElement = _mockElement(ImportElement, ElementKind. IMPORT);
1152 // {
1153 // Location locationA = new Location(_elementA, 1, 2);
1154 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY, locationA);
1155 // }
1156 // {
1157 // Location locationB = new Location(_elementB, 10, 0);
1158 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY, locationB);
1159 // }
1160 // _indexStore.doneIndex();
1161 // // search matches
1162 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
1163 // // verify
1164 // _assertMatches(matches, [
1165 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.IMPOR T_REFERENCE, 1, 2),
1166 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.IMPOR T_REFERENCE, 10, 0)]);
1167 // }
1168 //
1169 // void test_searchReferences_LibraryElement() {
1170 // LibraryElement referencedElement = _mockElement(LibraryElement, ElementKin d.LIBRARY);
1171 // {
1172 // Location location = new Location(_elementA, 1, 2);
1173 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY, location);
1174 // }
1175 // _indexStore.doneIndex();
1176 // // search matches
1177 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
1178 // // verify
1179 // _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elem entA, MatchKind.LIBRARY_REFERENCE, 1, 2)]);
1180 // }
1181 //
1182 // void test_searchReferences_MethodElement() {
1183 // MethodElement referencedElement = _mockElement(MethodElement, ElementKind. METHOD);
1184 // {
1185 // Location location = new Location(_elementA, 1, 10);
1186 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_INVO KED_BY_UNQUALIFIED, location);
1187 // }
1188 // {
1189 // Location location = new Location(_elementB, 2, 20);
1190 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_INVO KED_BY_QUALIFIED, location);
1191 // }
1192 // {
1193 // Location location = new Location(_elementC, 3, 30);
1194 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY_UNQUALIFIED, location);
1195 // }
1196 // {
1197 // Location location = new Location(_elementD, 4, 40);
1198 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY_QUALIFIED, location);
1199 // }
1200 // _indexStore.doneIndex();
1201 // // search matches
1202 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
1203 // // verify
1204 // _assertMatches(matches, [
1205 // new SearchEngineImplTest_ExpectedMatch.con2(_elementA, MatchKind.METHO D_INVOCATION, 1, 10, false),
1206 // new SearchEngineImplTest_ExpectedMatch.con2(_elementB, MatchKind.METHO D_INVOCATION, 2, 20, true),
1207 // new SearchEngineImplTest_ExpectedMatch.con2(_elementC, MatchKind.METHO D_REFERENCE, 3, 30, false),
1208 // new SearchEngineImplTest_ExpectedMatch.con2(_elementD, MatchKind.METHO D_REFERENCE, 4, 40, true)]);
1209 // }
1210 //
1211 // void test_searchReferences_MethodMember() {
1212 // MethodElement referencedElement = _mockElement(MethodElement, ElementKind. METHOD);
1213 // {
1214 // Location location = new Location(_elementA, 1, 10);
1215 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_INVO KED_BY_UNQUALIFIED, location);
1216 // }
1217 // {
1218 // Location location = new Location(_elementB, 2, 20);
1219 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_INVO KED_BY_QUALIFIED, location);
1220 // }
1221 // {
1222 // Location location = new Location(_elementC, 3, 30);
1223 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY_UNQUALIFIED, location);
1224 // }
1225 // {
1226 // Location location = new Location(_elementD, 4, 40);
1227 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY_QUALIFIED, location);
1228 // }
1229 // _indexStore.doneIndex();
1230 // // search matches
1231 // MethodMember referencedMember = new MethodMember(referencedElement, null);
1232 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedMembe r);
1233 // // verify
1234 // _assertMatches(matches, [
1235 // new SearchEngineImplTest_ExpectedMatch.con2(_elementA, MatchKind.METHO D_INVOCATION, 1, 10, false),
1236 // new SearchEngineImplTest_ExpectedMatch.con2(_elementB, MatchKind.METHO D_INVOCATION, 2, 20, true),
1237 // new SearchEngineImplTest_ExpectedMatch.con2(_elementC, MatchKind.METHO D_REFERENCE, 3, 30, false),
1238 // new SearchEngineImplTest_ExpectedMatch.con2(_elementD, MatchKind.METHO D_REFERENCE, 4, 40, true)]);
1239 // }
1240 //
1241 // void test_searchReferences_notSupported() {
1242 // Element referencedElement = _mockElement(Element, ElementKind.UNIVERSE);
1243 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
1244 // assertThat(matches).isEmpty();
1245 // }
1246 //
1247 // void test_searchReferences_ParameterElement() {
1248 // ParameterElement referencedElement = _mockElement(ParameterElement, Elemen tKind.PARAMETER);
1249 // {
1250 // Location location = new Location(_elementA, 1, 10);
1251 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_READ _BY, location);
1252 // }
1253 // {
1254 // Location location = new Location(_elementB, 2, 20);
1255 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_WRIT TEN_BY, location);
1256 // }
1257 // {
1258 // Location location = new Location(_elementC, 3, 30);
1259 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_READ _WRITTEN_BY, location);
1260 // }
1261 // {
1262 // Location location = new Location(_elementD, 4, 40);
1263 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY, location);
1264 // }
1265 // {
1266 // Location location = new Location(_elementD, 5, 50);
1267 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_INVO KED_BY, location);
1268 // }
1269 // _indexStore.doneIndex();
1270 // // search matches
1271 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
1272 // // verify
1273 // // TODO(scheglov) why no MatchKind.FIELD_READ_WRITE ?
1274 // _assertMatches(matches, [
1275 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.VARIA BLE_READ, 1, 10),
1276 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.VARIA BLE_WRITE, 2, 20),
1277 // new SearchEngineImplTest_ExpectedMatch.con1(_elementC, MatchKind.VARIA BLE_READ_WRITE, 3, 30),
1278 // new SearchEngineImplTest_ExpectedMatch.con1(_elementD, MatchKind.NAMED _PARAMETER_REFERENCE, 4, 40),
1279 // new SearchEngineImplTest_ExpectedMatch.con1(_elementD, MatchKind.FUNCT ION_EXECUTION, 5, 50)]);
1280 // }
1281 //
1282 // void test_searchReferences_PropertyAccessorElement_getter() {
1283 // PropertyAccessorElement accessor = _mockElement(PropertyAccessorElement, E lementKind.GETTER);
1284 // {
1285 // Location location = new Location(_elementA, 1, 10);
1286 // _indexStore.recordRelationship(accessor, IndexConstants.IS_REFERENCED_BY _UNQUALIFIED, location);
1287 // }
1288 // {
1289 // Location location = new Location(_elementB, 2, 20);
1290 // _indexStore.recordRelationship(accessor, IndexConstants.IS_REFERENCED_BY _QUALIFIED, location);
1291 // }
1292 // _indexStore.doneIndex();
1293 // // search matches
1294 // List<SearchMatch> matches = _searchReferencesSync(Element, accessor);
1295 // // verify
1296 // _assertMatches(matches, [
1297 // new SearchEngineImplTest_ExpectedMatch.con2(_elementA, MatchKind.PROPE RTY_ACCESSOR_REFERENCE, 1, 10, false),
1298 // new SearchEngineImplTest_ExpectedMatch.con2(_elementB, MatchKind.PROPE RTY_ACCESSOR_REFERENCE, 2, 20, true)]);
1299 // }
1300 //
1301 // void test_searchReferences_PropertyAccessorElement_setter() {
1302 // PropertyAccessorElement accessor = _mockElement(PropertyAccessorElement, E lementKind.SETTER);
1303 // {
1304 // Location location = new Location(_elementA, 1, 10);
1305 // _indexStore.recordRelationship(accessor, IndexConstants.IS_REFERENCED_BY _UNQUALIFIED, location);
1306 // }
1307 // {
1308 // Location location = new Location(_elementB, 2, 20);
1309 // _indexStore.recordRelationship(accessor, IndexConstants.IS_REFERENCED_BY _QUALIFIED, location);
1310 // }
1311 // _indexStore.doneIndex();
1312 // // search matches
1313 // List<SearchMatch> matches = _searchReferencesSync(Element, accessor);
1314 // // verify
1315 // _assertMatches(matches, [
1316 // new SearchEngineImplTest_ExpectedMatch.con2(_elementA, MatchKind.PROPE RTY_ACCESSOR_REFERENCE, 1, 10, false),
1317 // new SearchEngineImplTest_ExpectedMatch.con2(_elementB, MatchKind.PROPE RTY_ACCESSOR_REFERENCE, 2, 20, true)]);
1318 // }
1319 //
1320 // void test_searchReferences_TopLevelVariableElement() {
1321 // PropertyAccessorElement getterElement = _mockElement(PropertyAccessorEleme nt, ElementKind.GETTER);
1322 // PropertyAccessorElement setterElement = _mockElement(PropertyAccessorEleme nt, ElementKind.SETTER);
1323 // TopLevelVariableElement topVariableElement = _mockElement(TopLevelVariable Element, ElementKind.TOP_LEVEL_VARIABLE);
1324 // when(topVariableElement.getter).thenReturn(getterElement);
1325 // when(topVariableElement.setter).thenReturn(setterElement);
1326 // {
1327 // Location location = new Location(_elementA, 1, 10);
1328 // _indexStore.recordRelationship(getterElement, IndexConstants.IS_REFERENC ED_BY_UNQUALIFIED, location);
1329 // }
1330 // {
1331 // Location location = new Location(_elementC, 2, 20);
1332 // _indexStore.recordRelationship(setterElement, IndexConstants.IS_REFERENC ED_BY_UNQUALIFIED, location);
1333 // }
1334 // _indexStore.doneIndex();
1335 // // search matches
1336 // List<SearchMatch> matches = _searchReferencesSync(Element, topVariableElem ent);
1337 // // verify
1338 // _assertMatches(matches, [
1339 // new SearchEngineImplTest_ExpectedMatch.con2(_elementA, MatchKind.FIELD _READ, 1, 10, false),
1340 // new SearchEngineImplTest_ExpectedMatch.con2(_elementC, MatchKind.FIELD _WRITE, 2, 20, false)]);
1341 // }
1342 //
1343 // void test_searchReferences_TypeAliasElement() {
1344 // FunctionTypeAliasElement referencedElement = _mockElement(FunctionTypeAlia sElement, ElementKind.FUNCTION_TYPE_ALIAS);
1345 // {
1346 // Location locationA = new Location(_elementA, 1, 2);
1347 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY, locationA);
1348 // }
1349 // {
1350 // Location locationB = new Location(_elementB, 10, 20);
1351 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY, locationB);
1352 // }
1353 // _indexStore.doneIndex();
1354 // // search matches
1355 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
1356 // // verify
1357 // _assertMatches(matches, [
1358 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.FUNCT ION_TYPE_REFERENCE, 1, 2),
1359 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.FUNCT ION_TYPE_REFERENCE, 10, 20)]);
1360 // }
1361 //
1362 // void test_searchReferences_TypeParameterElement() {
1363 // TypeParameterElement referencedElement = _mockElement(TypeParameterElement , ElementKind.TYPE_PARAMETER);
1364 // {
1365 // Location locationA = new Location(_elementA, 1, 2);
1366 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY, locationA);
1367 // }
1368 // {
1369 // Location locationB = new Location(_elementB, 10, 20);
1370 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY, locationB);
1371 // }
1372 // _indexStore.doneIndex();
1373 // // search matches
1374 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
1375 // // verify
1376 // _assertMatches(matches, [
1377 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.TYPE_ PARAMETER_REFERENCE, 1, 2),
1378 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.TYPE_ PARAMETER_REFERENCE, 10, 20)]);
1379 // }
1380 //
1381 // void test_searchReferences_VariableElement() {
1382 // LocalVariableElement referencedElement = _mockElement(LocalVariableElement , ElementKind.LOCAL_VARIABLE);
1383 // {
1384 // Location location = new Location(_elementA, 1, 10);
1385 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_READ _BY, location);
1386 // }
1387 // {
1388 // Location location = new Location(_elementB, 2, 20);
1389 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_WRIT TEN_BY, location);
1390 // }
1391 // {
1392 // Location location = new Location(_elementC, 3, 30);
1393 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_READ _WRITTEN_BY, location);
1394 // }
1395 // {
1396 // Location location = new Location(_elementD, 4, 40);
1397 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_INVO KED_BY, location);
1398 // }
1399 // _indexStore.doneIndex();
1400 // // search matches
1401 // List<SearchMatch> matches = _searchReferencesSync(Element, referencedEleme nt);
1402 // // verify
1403 // _assertMatches(matches, [
1404 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.VARIA BLE_READ, 1, 10),
1405 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.VARIA BLE_WRITE, 2, 20),
1406 // new SearchEngineImplTest_ExpectedMatch.con1(_elementC, MatchKind.VARIA BLE_READ_WRITE, 3, 30),
1407 // new SearchEngineImplTest_ExpectedMatch.con1(_elementD, MatchKind.FUNCT ION_EXECUTION, 4, 40)]);
1408 // }
1409 //
1410 // void test_searchSubtypes() {
1411 // ClassElement referencedElement = _mockElement(ClassElement, ElementKind.CL ASS);
1412 // {
1413 // Location locationA = new Location(_elementA, 10, 1);
1414 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_EXTE NDED_BY, locationA);
1415 // }
1416 // {
1417 // Location locationB = new Location(_elementB, 20, 2);
1418 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_MIXE D_IN_BY, locationB);
1419 // }
1420 // {
1421 // Location locationC = new Location(_elementC, 30, 3);
1422 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_IMPL EMENTED_BY, locationC);
1423 // }
1424 // _indexStore.doneIndex();
1425 // // search matches
1426 // List<SearchMatch> matches = _runSearch(new SearchRunner_SearchEngineImplTe st_test_searchSubtypes(this, referencedElement));
1427 // // verify
1428 // _assertMatches(matches, [
1429 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.EXTEN DS_REFERENCE, 10, 1),
1430 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.WITH_ REFERENCE, 20, 2),
1431 // new SearchEngineImplTest_ExpectedMatch.con1(_elementC, MatchKind.IMPLE MENTS_REFERENCE, 30, 3)]);
1432 // }
1433 //
1434 // void test_searchTypeDeclarations_async() {
1435 // LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY) ;
1436 // {
1437 // when(_elementA.getAncestor((element) => element is LibraryElement)).then Return(library);
1438 // Location locationA = new Location(_elementA, 1, 2);
1439 // _indexStore.recordRelationship(library, IndexConstants.DEFINES_CLASS, lo cationA);
1440 // }
1441 // _indexStore.doneIndex();
1442 // _scope = new LibrarySearchScope.con2([library]);
1443 // // search matches
1444 // List<SearchMatch> matches = _searchTypeDeclarationsAsync();
1445 // // verify
1446 // _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elem entA, MatchKind.CLASS_DECLARATION, 1, 2)]);
1447 // }
1448 //
1449 // void test_searchTypeDeclarations_class() {
1450 // LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY) ;
1451 // {
1452 // when(_elementA.getAncestor((element) => element is LibraryElement)).then Return(library);
1453 // Location locationA = new Location(_elementA, 1, 2);
1454 // _indexStore.recordRelationship(library, IndexConstants.DEFINES_CLASS, lo cationA);
1455 // }
1456 // _indexStore.doneIndex();
1457 // _scope = new LibrarySearchScope.con2([library]);
1458 // // search matches
1459 // List<SearchMatch> matches = _searchTypeDeclarationsSync();
1460 // // verify
1461 // _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elem entA, MatchKind.CLASS_DECLARATION, 1, 2)]);
1462 // }
1463 //
1464 // void test_searchTypeDeclarations_classAlias() {
1465 // LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY) ;
1466 // {
1467 // when(_elementA.getAncestor((element) => element is LibraryElement)).then Return(library);
1468 // Location locationA = new Location(_elementA, 1, 2);
1469 // _indexStore.recordRelationship(library, IndexConstants.DEFINES_CLASS_ALI AS, locationA);
1470 // }
1471 // _indexStore.doneIndex();
1472 // _scope = new LibrarySearchScope.con2([library]);
1473 // // search matches
1474 // List<SearchMatch> matches = _searchTypeDeclarationsSync();
1475 // // verify
1476 // _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elem entA, MatchKind.CLASS_ALIAS_DECLARATION, 1, 2)]);
1477 // }
1478 //
1479 // void test_searchTypeDeclarations_functionType() {
1480 // LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY) ;
1481 // {
1482 // when(_elementA.getAncestor((element) => element is LibraryElement)).then Return(library);
1483 // Location locationA = new Location(_elementA, 1, 2);
1484 // _indexStore.recordRelationship(library, IndexConstants.DEFINES_FUNCTION_ TYPE, locationA);
1485 // }
1486 // _indexStore.doneIndex();
1487 // _scope = new LibrarySearchScope.con2([library]);
1488 // // search matches
1489 // List<SearchMatch> matches = _searchTypeDeclarationsSync();
1490 // // verify
1491 // _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elem entA, MatchKind.FUNCTION_TYPE_DECLARATION, 1, 2)]);
1492 // }
1493 //
1494 // void test_searchUnresolvedQualifiedReferences() {
1495 // Element referencedElement = new NameElementImpl("test");
1496 // {
1497 // Location locationA = new Location(_elementA, 1, 2);
1498 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY_QUALIFIED_RESOLVED, locationA);
1499 // }
1500 // {
1501 // Location locationB = new Location(_elementB, 10, 20);
1502 // _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFE RENCED_BY_QUALIFIED_UNRESOLVED, locationB);
1503 // }
1504 // _indexStore.doneIndex();
1505 // // search matches
1506 // List<SearchMatch> matches = _searchReferencesSync2("searchQualifiedMemberR eferences", String, "test");
1507 // // verify
1508 // _assertMatches(matches, [
1509 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.NAME_ REFERENCE_RESOLVED, 1, 2),
1510 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.NAME_ REFERENCE_UNRESOLVED, 10, 20)]);
1511 // }
1512 //
1513 // void test_searchVariableDeclarations() {
1514 // LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY) ;
1515 // _defineVariablesAB(library);
1516 // _scope = new LibrarySearchScope.con2([library]);
1517 // // search matches
1518 // List<SearchMatch> matches = _searchVariableDeclarationsSync();
1519 // // verify
1520 // _assertMatches(matches, [
1521 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.VARIA BLE_DECLARATION, 1, 2),
1522 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.VARIA BLE_DECLARATION, 10, 20)]);
1523 // }
1524 //
1525 // void test_searchVariableDeclarations_async() {
1526 // LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY) ;
1527 // _defineVariablesAB(library);
1528 // _scope = new LibrarySearchScope.con2([library]);
1529 // // search matches
1530 // List<SearchMatch> matches = _searchVariableDeclarationsAsync();
1531 // // verify
1532 // _assertMatches(matches, [
1533 // new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.VARIA BLE_DECLARATION, 1, 2),
1534 // new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.VARIA BLE_DECLARATION, 10, 20)]);
1535 // }
1536 //
1537 // void test_searchVariableDeclarations_usePattern() {
1538 // LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY) ;
1539 // _defineVariablesAB(library);
1540 // _scope = new LibrarySearchScope.con2([library]);
1541 // // search "A"
1542 // {
1543 // _pattern = SearchPatternFactory.createExactPattern("A", true);
1544 // List<SearchMatch> matches = _searchVariableDeclarationsSync();
1545 // _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_el ementA, MatchKind.VARIABLE_DECLARATION, 1, 2)]);
1546 // }
1547 // // search "B"
1548 // {
1549 // _pattern = SearchPatternFactory.createExactPattern("B", true);
1550 // List<SearchMatch> matches = _searchVariableDeclarationsSync();
1551 // _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_el ementB, MatchKind.VARIABLE_DECLARATION, 10, 20)]);
1552 // }
1553 // }
1554 //
1555 // @override
1556 // void setUp() {
1557 // super.setUp();
1558 // // library
1559 // when(_unitElement.library).thenReturn(_libraryElement);
1560 // when(_libraryElement.definingCompilationUnit).thenReturn(_unitElement);
1561 // when(_unitElement.source).thenReturn(_source);
1562 // when(_libraryElement.source).thenReturn(_source);
1563 // when(_libraryElement.parts).thenReturn(new List<CompilationUnitElement>(0) );
1564 // // elements
1565 // when(_elementA.toString()).thenReturn("A");
1566 // when(_elementB.toString()).thenReturn("B");
1567 // when(_elementC.toString()).thenReturn("C");
1568 // when(_elementD.toString()).thenReturn("D");
1569 // when(_elementE.toString()).thenReturn("E");
1570 // when(_elementA.displayName).thenReturn("A");
1571 // when(_elementB.displayName).thenReturn("B");
1572 // when(_elementC.displayName).thenReturn("C");
1573 // when(_elementD.displayName).thenReturn("D");
1574 // when(_elementE.displayName).thenReturn("E");
1575 // when(_elementA.source).thenReturn(_source);
1576 // when(_elementB.source).thenReturn(_source);
1577 // when(_elementC.source).thenReturn(_source);
1578 // when(_elementD.source).thenReturn(_source);
1579 // when(_elementE.source).thenReturn(_source);
1580 // when(_elementA.context).thenReturn(_CONTEXT);
1581 // when(_elementB.context).thenReturn(_CONTEXT);
1582 // when(_elementC.context).thenReturn(_CONTEXT);
1583 // when(_elementD.context).thenReturn(_CONTEXT);
1584 // when(_elementE.context).thenReturn(_CONTEXT);
1585 // when(_CONTEXT.getElement(_elementA.location)).thenReturn(_elementA);
1586 // when(_CONTEXT.getElement(_elementB.location)).thenReturn(_elementB);
1587 // when(_CONTEXT.getElement(_elementC.location)).thenReturn(_elementC);
1588 // when(_CONTEXT.getElement(_elementD.location)).thenReturn(_elementD);
1589 // when(_CONTEXT.getElement(_elementE.location)).thenReturn(_elementE);
1590 // // start indexing
1591 // JUnitTestCase.assertTrue(_indexStore.aboutToIndexDart(_CONTEXT, _unitEleme nt));
1592 // }
1593 //
1594 // void _defineFunctionsAB(LibraryElement library) {
1595 // {
1596 // when(_elementA.getAncestor((element) => element is LibraryElement)).then Return(library);
1597 // Location locationA = new Location(_elementA, 1, 2);
1598 // _indexStore.recordRelationship(library, IndexConstants.DEFINES_FUNCTION, locationA);
1599 // }
1600 // {
1601 // when(_elementB.getAncestor((element) => element is LibraryElement)).then Return(library);
1602 // Location locationB = new Location(_elementB, 10, 20);
1603 // _indexStore.recordRelationship(library, IndexConstants.DEFINES_FUNCTION, locationB);
1604 // }
1605 // _indexStore.doneIndex();
1606 // }
1607 //
1608 // void _defineVariablesAB(LibraryElement library) {
1609 // {
1610 // when(_elementA.getAncestor((element) => element is LibraryElement)).then Return(library);
1611 // Location locationA = new Location(_elementA, 1, 2);
1612 // _indexStore.recordRelationship(library, IndexConstants.DEFINES_VARIABLE, locationA);
1613 // }
1614 // {
1615 // when(_elementB.getAncestor((element) => element is LibraryElement)).then Return(library);
1616 // Location locationB = new Location(_elementB, 10, 20);
1617 // _indexStore.recordRelationship(library, IndexConstants.DEFINES_VARIABLE, locationB);
1618 // }
1619 // _indexStore.doneIndex();
1620 // }
1621 //
1622 // Element _mockElement(Type clazz, ElementKind kind) {
1623 // Element element = mock(clazz);
1624 // when(element.context).thenReturn(_CONTEXT);
1625 // when(element.source).thenReturn(_source);
1626 // when(element.kind).thenReturn(kind);
1627 // ElementLocation elementLocation = new ElementLocationImpl.con2("mockLocati on${_nextLocationId++}");
1628 // when(element.location).thenReturn(elementLocation);
1629 // when(_CONTEXT.getElement(element.location)).thenReturn(element);
1630 // return element;
1631 // }
1632 //
1633 // Object _runSearch(SearchEngineImplTest_SearchRunner runner) {
1634 // OperationQueue queue = new OperationQueue();
1635 // OperationProcessor processor = new OperationProcessor(queue);
1636 // Index index = new IndexImpl(_indexStore, queue, processor);
1637 // SearchEngine engine = SearchEngineFactory.createSearchEngine(index);
1638 // try {
1639 // new Thread_SearchEngineImplTest_runSearch(processor).start();
1640 // processor.waitForRunning();
1641 // return runner.run(queue, processor, index, engine);
1642 // } finally {
1643 // processor.stop(false);
1644 // }
1645 // }
1646 //
1647 // List<SearchMatch> _searchDeclarationsAsync(String methodName) => _runSearch( new SearchRunner_SearchEngineImplTest_searchDeclarationsAsync(this, methodName, this, matches, latch));
1648 //
1649 // List<SearchMatch> _searchDeclarationsSync(String methodName) => _runSearch(n ew SearchRunner_SearchEngineImplTest_searchDeclarationsSync(this, methodName));
1650 //
1651 // List<SearchMatch> _searchFunctionDeclarationsAsync() => _searchDeclarationsA sync("searchFunctionDeclarations");
1652 //
1653 // List<SearchMatch> _searchFunctionDeclarationsSync() => _searchDeclarationsSy nc("searchFunctionDeclarations");
1654 //
1655 // List<SearchMatch> _searchReferencesSync(Type clazz, Object element) => _sear chReferencesSync2("searchReferences", clazz, element);
1656 //
1657 // List<SearchMatch> _searchReferencesSync2(String methodName, Type clazz, Obje ct element) => _runSearch(new SearchRunner_SearchEngineImplTest_searchReferences Sync(this, methodName, clazz, element));
1658 //
1659 // List<SearchMatch> _searchTypeDeclarationsAsync() => _searchDeclarationsAsync ("searchTypeDeclarations");
1660 //
1661 // List<SearchMatch> _searchTypeDeclarationsSync() => _searchDeclarationsSync(" searchTypeDeclarations");
1662 //
1663 // List<SearchMatch> _searchVariableDeclarationsAsync() => _searchDeclarationsA sync("searchVariableDeclarations");
1664 //
1665 // List<SearchMatch> _searchVariableDeclarationsSync() => _searchDeclarationsSy nc("searchVariableDeclarations");
1666 //
1667 // static dartSuite() {
1668 // _ut.group('SearchEngineImplTest', () {
1669 // _ut.test('test_searchDeclarations_String', () {
1670 // final __test = new SearchEngineImplTest();
1671 // runJUnitTest(__test, __test.test_searchDeclarations_String);
1672 // });
1673 // _ut.test('test_searchFunctionDeclarations', () {
1674 // final __test = new SearchEngineImplTest();
1675 // runJUnitTest(__test, __test.test_searchFunctionDeclarations);
1676 // });
1677 // _ut.test('test_searchFunctionDeclarations_async', () {
1678 // final __test = new SearchEngineImplTest();
1679 // runJUnitTest(__test, __test.test_searchFunctionDeclarations_async);
1680 // });
1681 // _ut.test('test_searchFunctionDeclarations_inUniverse', () {
1682 // final __test = new SearchEngineImplTest();
1683 // runJUnitTest(__test, __test.test_searchFunctionDeclarations_inUniverse );
1684 // });
1685 // _ut.test('test_searchFunctionDeclarations_useFilter', () {
1686 // final __test = new SearchEngineImplTest();
1687 // runJUnitTest(__test, __test.test_searchFunctionDeclarations_useFilter) ;
1688 // });
1689 // _ut.test('test_searchFunctionDeclarations_usePattern', () {
1690 // final __test = new SearchEngineImplTest();
1691 // runJUnitTest(__test, __test.test_searchFunctionDeclarations_usePattern );
1692 // });
1693 // _ut.test('test_searchReferences_AngularComponentElement', () {
1694 // final __test = new SearchEngineImplTest();
1695 // runJUnitTest(__test, __test.test_searchReferences_AngularComponentElem ent);
1696 // });
1697 // _ut.test('test_searchReferences_AngularControllerElement', () {
1698 // final __test = new SearchEngineImplTest();
1699 // runJUnitTest(__test, __test.test_searchReferences_AngularControllerEle ment);
1700 // });
1701 // _ut.test('test_searchReferences_AngularFilterElement', () {
1702 // final __test = new SearchEngineImplTest();
1703 // runJUnitTest(__test, __test.test_searchReferences_AngularFilterElement );
1704 // });
1705 // _ut.test('test_searchReferences_AngularPropertyElement', () {
1706 // final __test = new SearchEngineImplTest();
1707 // runJUnitTest(__test, __test.test_searchReferences_AngularPropertyEleme nt);
1708 // });
1709 // _ut.test('test_searchReferences_AngularScopePropertyElement', () {
1710 // final __test = new SearchEngineImplTest();
1711 // runJUnitTest(__test, __test.test_searchReferences_AngularScopeProperty Element);
1712 // });
1713 // _ut.test('test_searchReferences_AngularSelectorElement', () {
1714 // final __test = new SearchEngineImplTest();
1715 // runJUnitTest(__test, __test.test_searchReferences_AngularSelectorEleme nt);
1716 // });
1717 // _ut.test('test_searchReferences_ClassElement', () {
1718 // final __test = new SearchEngineImplTest();
1719 // runJUnitTest(__test, __test.test_searchReferences_ClassElement);
1720 // });
1721 // _ut.test('test_searchReferences_ClassElement_useScope', () {
1722 // final __test = new SearchEngineImplTest();
1723 // runJUnitTest(__test, __test.test_searchReferences_ClassElement_useScop e);
1724 // });
1725 // _ut.test('test_searchReferences_CompilationUnitElement', () {
1726 // final __test = new SearchEngineImplTest();
1727 // runJUnitTest(__test, __test.test_searchReferences_CompilationUnitEleme nt);
1728 // });
1729 // _ut.test('test_searchReferences_ConstructorElement', () {
1730 // final __test = new SearchEngineImplTest();
1731 // runJUnitTest(__test, __test.test_searchReferences_ConstructorElement);
1732 // });
1733 // _ut.test('test_searchReferences_Element_unknown', () {
1734 // final __test = new SearchEngineImplTest();
1735 // runJUnitTest(__test, __test.test_searchReferences_Element_unknown);
1736 // });
1737 // _ut.test('test_searchReferences_FieldElement', () {
1738 // final __test = new SearchEngineImplTest();
1739 // runJUnitTest(__test, __test.test_searchReferences_FieldElement);
1740 // });
1741 // _ut.test('test_searchReferences_FieldElement2', () {
1742 // final __test = new SearchEngineImplTest();
1743 // runJUnitTest(__test, __test.test_searchReferences_FieldElement2);
1744 // });
1745 // _ut.test('test_searchReferences_FieldElement_invocation', () {
1746 // final __test = new SearchEngineImplTest();
1747 // runJUnitTest(__test, __test.test_searchReferences_FieldElement_invocat ion);
1748 // });
1749 // _ut.test('test_searchReferences_FunctionElement', () {
1750 // final __test = new SearchEngineImplTest();
1751 // runJUnitTest(__test, __test.test_searchReferences_FunctionElement);
1752 // });
1753 // _ut.test('test_searchReferences_ImportElement', () {
1754 // final __test = new SearchEngineImplTest();
1755 // runJUnitTest(__test, __test.test_searchReferences_ImportElement);
1756 // });
1757 // _ut.test('test_searchReferences_LibraryElement', () {
1758 // final __test = new SearchEngineImplTest();
1759 // runJUnitTest(__test, __test.test_searchReferences_LibraryElement);
1760 // });
1761 // _ut.test('test_searchReferences_MethodElement', () {
1762 // final __test = new SearchEngineImplTest();
1763 // runJUnitTest(__test, __test.test_searchReferences_MethodElement);
1764 // });
1765 // _ut.test('test_searchReferences_MethodMember', () {
1766 // final __test = new SearchEngineImplTest();
1767 // runJUnitTest(__test, __test.test_searchReferences_MethodMember);
1768 // });
1769 // _ut.test('test_searchReferences_ParameterElement', () {
1770 // final __test = new SearchEngineImplTest();
1771 // runJUnitTest(__test, __test.test_searchReferences_ParameterElement);
1772 // });
1773 // _ut.test('test_searchReferences_PropertyAccessorElement_getter', () {
1774 // final __test = new SearchEngineImplTest();
1775 // runJUnitTest(__test, __test.test_searchReferences_PropertyAccessorElem ent_getter);
1776 // });
1777 // _ut.test('test_searchReferences_PropertyAccessorElement_setter', () {
1778 // final __test = new SearchEngineImplTest();
1779 // runJUnitTest(__test, __test.test_searchReferences_PropertyAccessorElem ent_setter);
1780 // });
1781 // _ut.test('test_searchReferences_TopLevelVariableElement', () {
1782 // final __test = new SearchEngineImplTest();
1783 // runJUnitTest(__test, __test.test_searchReferences_TopLevelVariableElem ent);
1784 // });
1785 // _ut.test('test_searchReferences_TypeAliasElement', () {
1786 // final __test = new SearchEngineImplTest();
1787 // runJUnitTest(__test, __test.test_searchReferences_TypeAliasElement);
1788 // });
1789 // _ut.test('test_searchReferences_TypeParameterElement', () {
1790 // final __test = new SearchEngineImplTest();
1791 // runJUnitTest(__test, __test.test_searchReferences_TypeParameterElement );
1792 // });
1793 // _ut.test('test_searchReferences_VariableElement', () {
1794 // final __test = new SearchEngineImplTest();
1795 // runJUnitTest(__test, __test.test_searchReferences_VariableElement);
1796 // });
1797 // _ut.test('test_searchReferences_notSupported', () {
1798 // final __test = new SearchEngineImplTest();
1799 // runJUnitTest(__test, __test.test_searchReferences_notSupported);
1800 // });
1801 // _ut.test('test_searchSubtypes', () {
1802 // final __test = new SearchEngineImplTest();
1803 // runJUnitTest(__test, __test.test_searchSubtypes);
1804 // });
1805 // _ut.test('test_searchTypeDeclarations_async', () {
1806 // final __test = new SearchEngineImplTest();
1807 // runJUnitTest(__test, __test.test_searchTypeDeclarations_async);
1808 // });
1809 // _ut.test('test_searchTypeDeclarations_class', () {
1810 // final __test = new SearchEngineImplTest();
1811 // runJUnitTest(__test, __test.test_searchTypeDeclarations_class);
1812 // });
1813 // _ut.test('test_searchTypeDeclarations_classAlias', () {
1814 // final __test = new SearchEngineImplTest();
1815 // runJUnitTest(__test, __test.test_searchTypeDeclarations_classAlias);
1816 // });
1817 // _ut.test('test_searchTypeDeclarations_functionType', () {
1818 // final __test = new SearchEngineImplTest();
1819 // runJUnitTest(__test, __test.test_searchTypeDeclarations_functionType);
1820 // });
1821 // _ut.test('test_searchUnresolvedQualifiedReferences', () {
1822 // final __test = new SearchEngineImplTest();
1823 // runJUnitTest(__test, __test.test_searchUnresolvedQualifiedReferences);
1824 // });
1825 // _ut.test('test_searchVariableDeclarations', () {
1826 // final __test = new SearchEngineImplTest();
1827 // runJUnitTest(__test, __test.test_searchVariableDeclarations);
1828 // });
1829 // _ut.test('test_searchVariableDeclarations_async', () {
1830 // final __test = new SearchEngineImplTest();
1831 // runJUnitTest(__test, __test.test_searchVariableDeclarations_async);
1832 // });
1833 // _ut.test('test_searchVariableDeclarations_usePattern', () {
1834 // final __test = new SearchEngineImplTest();
1835 // runJUnitTest(__test, __test.test_searchVariableDeclarations_usePattern );
1836 // });
1837 // });
1838 // }
1839 //}
1840 //
1841 //class SearchEngineImplTest_ExpectedMatch {
1842 // final Element _element;
1843 //
1844 // final MatchKind _kind;
1845 //
1846 // final MatchQuality _quality;
1847 //
1848 // SourceRange _range;
1849 //
1850 // final bool _qualified;
1851 //
1852 // SearchEngineImplTest_ExpectedMatch.con1(Element element, MatchKind kind, int offset, int length) : this.con3(element, kind, MatchQuality.EXACT, offset, leng th);
1853 //
1854 // SearchEngineImplTest_ExpectedMatch.con2(Element element, MatchKind kind, int offset, int length, bool qualified) : this.con4(element, kind, MatchQuality.EXA CT, offset, length, qualified);
1855 //
1856 // SearchEngineImplTest_ExpectedMatch.con3(Element element, MatchKind kind, Mat chQuality quality, int offset, int length) : this.con4(element, kind, quality, o ffset, length, false);
1857 //
1858 // SearchEngineImplTest_ExpectedMatch.con4(this._element, this._kind, this._qua lity, int offset, int length, this._qualified) {
1859 // this._range = new SourceRange(offset, length);
1860 // }
1861 //}
1862 //
1863 //abstract class SearchEngineImplTest_SearchRunner<T> {
1864 // T run(OperationQueue queue, OperationProcessor processor, Index index, Searc hEngine engine);
1865 //}
1866 //
1867 //class SearchFilter_SearchEngineImplTest_test_searchFunctionDeclarations_useFil ter implements SearchFilter {
1868 // final SearchEngineImplTest SearchEngineImplTest_this;
1869 //
1870 // SearchFilter_SearchEngineImplTest_test_searchFunctionDeclarations_useFilter( this.SearchEngineImplTest_this);
1871 //
1872 // @override
1873 // bool passes(SearchMatch match) => identical(match.element, SearchEngineImplT est_this._elementB);
1874 //}
1875 //
1876 //class SearchFilter_SearchEngineImplTest_test_searchFunctionDeclarations_useFil ter_2 implements SearchFilter {
1877 // final SearchEngineImplTest SearchEngineImplTest_this;
1878 //
1879 // SearchFilter_SearchEngineImplTest_test_searchFunctionDeclarations_useFilter_ 2(this.SearchEngineImplTest_this);
1880 //
1881 // @override
1882 // bool passes(SearchMatch match) => identical(match.element, SearchEngineImplT est_this._elementA);
1883 //}
1884 //
1885 //class SearchListener_SearchRunner_117_run implements SearchListener {
1886 // List<SearchMatch> matches;
1887 //
1888 // CountDownLatch latch;
1889 //
1890 // SearchListener_SearchRunner_117_run(this.matches, this.latch);
1891 //
1892 // @override
1893 // void matchFound(SearchMatch match) {
1894 // matches.add(match);
1895 // }
1896 //
1897 // @override
1898 // void searchComplete() {
1899 // latch.countDown();
1900 // }
1901 //}
1902 //
1903 //class SearchRunner_SearchEngineImplTest_fail_searchAssignedTypes_assignments i mplements SearchEngineImplTest_SearchRunner {
1904 // FieldElement fieldElement;
1905 //
1906 // SearchRunner_SearchEngineImplTest_fail_searchAssignedTypes_assignments(this. fieldElement, this.fieldElement);
1907 //
1908 // @override
1909 // Set<DartType> run(OperationQueue queue, OperationProcessor processor, Index index, SearchEngine engine) => engine.searchAssignedTypes(fieldElement, new Sear chScope_SearchRunner_109_run());
1910 //}
1911 //
1912 //class SearchRunner_SearchEngineImplTest_fail_searchAssignedTypes_initializers implements SearchEngineImplTest_SearchRunner {
1913 // FieldElement fieldElement;
1914 //
1915 // SearchRunner_SearchEngineImplTest_fail_searchAssignedTypes_initializers(this .fieldElement);
1916 //
1917 // @override
1918 // Set<DartType> run(OperationQueue queue, OperationProcessor processor, Index index, SearchEngine engine) => engine.searchAssignedTypes(fieldElement, null);
1919 //}
1920 //
1921 //class SearchRunner_SearchEngineImplTest_searchDeclarationsAsync implements Sea rchEngineImplTest_SearchRunner {
1922 // final SearchEngineImplTest SearchEngineImplTest_this;
1923 //
1924 // String methodName;
1925 //
1926 // final SearchEngineImplTest SearchEngineImplTest_this;
1927 //
1928 // List<SearchMatch> matches;
1929 //
1930 // CountDownLatch latch;
1931 //
1932 // SearchRunner_SearchEngineImplTest_searchDeclarationsAsync(this.SearchEngineI mplTest_this, this.methodName, this.SearchEngineImplTest_this, this.matches, thi s.latch, this.SearchEngineImplTest_this, this.methodName, this.SearchEngineImplT est_this, this.matches, this.latch);
1933 //
1934 // @override
1935 // List<SearchMatch> run(OperationQueue queue, OperationProcessor processor, In dex index, SearchEngine engine) {
1936 // CountDownLatch latch = new CountDownLatch(1);
1937 // List<SearchMatch> matches = [];
1938 // engine.runtimeType.getMethod(methodName, [SearchScope, SearchPattern, Sear chFilter, SearchListener]).invoke(engine, [
1939 // SearchEngineImplTest_this._scope,
1940 // SearchEngineImplTest_this._pattern,
1941 // SearchEngineImplTest_this._filter,
1942 // new SearchListener_SearchRunner_117_run(matches, latch)]);
1943 // latch.await(30, TimeUnit.SECONDS);
1944 // return matches;
1945 // }
1946 //}
1947 //
1948 //class SearchRunner_SearchEngineImplTest_searchDeclarationsSync implements Sear chEngineImplTest_SearchRunner {
1949 // final SearchEngineImplTest SearchEngineImplTest_this;
1950 //
1951 // String methodName;
1952 //
1953 // SearchRunner_SearchEngineImplTest_searchDeclarationsSync(this.SearchEngineIm plTest_this, this.methodName);
1954 //
1955 // @override
1956 // List<SearchMatch> run(OperationQueue queue, OperationProcessor processor, In dex index, SearchEngine engine) => engine.runtimeType.getMethod(methodName, [Sea rchScope, SearchPattern, SearchFilter]).invoke(engine, [
1957 // SearchEngineImplTest_this._scope,
1958 // SearchEngineImplTest_this._pattern,
1959 // SearchEngineImplTest_this._filter]) as List<SearchMatch>;
1960 //}
1961 //
1962 //class SearchRunner_SearchEngineImplTest_searchReferencesSync implements Search EngineImplTest_SearchRunner {
1963 // final SearchEngineImplTest SearchEngineImplTest_this;
1964 //
1965 // String methodName;
1966 //
1967 // Type clazz;
1968 //
1969 // Object element;
1970 //
1971 // SearchRunner_SearchEngineImplTest_searchReferencesSync(this.SearchEngineImpl Test_this, this.methodName, this.clazz, this.element);
1972 //
1973 // @override
1974 // List<SearchMatch> run(OperationQueue queue, OperationProcessor processor, In dex index, SearchEngine engine) {
1975 // // pass some operation to wait if search will not call processor
1976 // queue.enqueue(mock(IndexOperation));
1977 // // run actual search
1978 // return engine.runtimeType.getMethod(methodName, [clazz, SearchScope, Searc hFilter]).invoke(engine, [
1979 // element,
1980 // SearchEngineImplTest_this._scope,
1981 // SearchEngineImplTest_this._filter]) as List<SearchMatch>;
1982 // }
1983 //}
1984 //
1985 //class SearchRunner_SearchEngineImplTest_test_searchDeclarations_String impleme nts SearchEngineImplTest_SearchRunner {
1986 // final SearchEngineImplTest SearchEngineImplTest_this;
1987 //
1988 // SearchRunner_SearchEngineImplTest_test_searchDeclarations_String(this.Search EngineImplTest_this);
1989 //
1990 // @override
1991 // List<SearchMatch> run(OperationQueue queue, OperationProcessor processor, In dex index, SearchEngine engine) => engine.searchDeclarations("test", SearchEngin eImplTest_this._scope, SearchEngineImplTest_this._filter);
1992 //}
1993 //
1994 //class SearchRunner_SearchEngineImplTest_test_searchSubtypes implements SearchE ngineImplTest_SearchRunner {
1995 // final SearchEngineImplTest SearchEngineImplTest_this;
1996 //
1997 // ClassElement referencedElement;
1998 //
1999 // SearchRunner_SearchEngineImplTest_test_searchSubtypes(this.SearchEngineImplT est_this, this.referencedElement);
2000 //
2001 // @override
2002 // List<SearchMatch> run(OperationQueue queue, OperationProcessor processor, In dex index, SearchEngine engine) => engine.searchSubtypes(referencedElement, Sear chEngineImplTest_this._scope, SearchEngineImplTest_this._filter);
2003 //}
2004 //
2005 //class SearchScope_SearchRunner_109_run implements SearchScope {
2006 // @override
2007 // bool encloses(Element element) => !identical(element, _elementC);
2008 //}
2009 //
2010 //class Thread_SearchEngineImplTest_runSearch extends Thread {
2011 // OperationProcessor processor;
2012 //
2013 // Thread_SearchEngineImplTest_runSearch(this.processor) : super();
2014 //
2015 // @override
2016 // void run() {
2017 // processor.run();
2018 // }
2019 //}
2020 //
2021 //class UniverseSearchScopeTest extends EngineTestCase {
2022 // SearchScope _scope = new UniverseSearchScope();
2023 //
2024 // Element _element = mock(Element);
2025 //
2026 // void test_anyElement() {
2027 // JUnitTestCase.assertTrue(_scope.encloses(_element));
2028 // }
2029 //
2030 // void test_nullElement() {
2031 // JUnitTestCase.assertTrue(_scope.encloses(null));
2032 // }
2033 //
2034 // static dartSuite() {
2035 // _ut.group('UniverseSearchScopeTest', () {
2036 // _ut.test('test_anyElement', () {
2037 // final __test = new UniverseSearchScopeTest();
2038 // runJUnitTest(__test, __test.test_anyElement);
2039 // });
2040 // _ut.test('test_nullElement', () {
2041 // final __test = new UniverseSearchScopeTest();
2042 // runJUnitTest(__test, __test.test_nullElement);
2043 // });
2044 // });
2045 // }
2046 //}
2047 //
2048 //class WildcardSearchPatternTest extends EngineTestCase {
2049 // Element _element = mock(Element);
2050 //
2051 // void test_caseInsensitive_false_contentMismatch() {
2052 // SearchPattern pattern = new WildcardSearchPattern("H*Map", false);
2053 // when(_element.displayName).thenReturn("Maps");
2054 // // validate
2055 // JUnitTestCase.assertSame(null, pattern.matches(_element));
2056 // }
2057 //
2058 // void test_caseInsensitive_true_caseMismatch() {
2059 // SearchPattern pattern = new WildcardSearchPattern("H*MaP", false);
2060 // when(_element.displayName).thenReturn("HashMap");
2061 // // validate
2062 // JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element));
2063 // }
2064 //
2065 // void test_caseSensitive_false_caseMismatch() {
2066 // SearchPattern pattern = new WildcardSearchPattern("H*MaP", true);
2067 // when(_element.displayName).thenReturn("HashMap");
2068 // // validate
2069 // JUnitTestCase.assertSame(null, pattern.matches(_element));
2070 // }
2071 //
2072 // void test_caseSensitive_false_contentMismatch() {
2073 // SearchPattern pattern = new WildcardSearchPattern("H*Map", false);
2074 // when(_element.displayName).thenReturn("Maps");
2075 // // validate
2076 // JUnitTestCase.assertSame(null, pattern.matches(_element));
2077 // }
2078 //
2079 // void test_caseSensitive_true() {
2080 // SearchPattern pattern = new WildcardSearchPattern("H*Ma?", false);
2081 // when(_element.displayName).thenReturn("HashMap");
2082 // // validate
2083 // JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element));
2084 // }
2085 //
2086 // void test_nullElement() {
2087 // SearchPattern pattern = new WildcardSearchPattern("H*Map", false);
2088 // // validate
2089 // JUnitTestCase.assertSame(null, pattern.matches(null));
2090 // }
2091 //
2092 // void test_nullName() {
2093 // SearchPattern pattern = new WildcardSearchPattern("H*Map", false);
2094 // when(_element.displayName).thenReturn(null);
2095 // // validate
2096 // JUnitTestCase.assertSame(null, pattern.matches(_element));
2097 // }
2098 //
2099 // static dartSuite() {
2100 // _ut.group('WildcardSearchPatternTest', () {
2101 // _ut.test('test_caseInsensitive_false_contentMismatch', () {
2102 // final __test = new WildcardSearchPatternTest();
2103 // runJUnitTest(__test, __test.test_caseInsensitive_false_contentMismatch );
2104 // });
2105 // _ut.test('test_caseInsensitive_true_caseMismatch', () {
2106 // final __test = new WildcardSearchPatternTest();
2107 // runJUnitTest(__test, __test.test_caseInsensitive_true_caseMismatch);
2108 // });
2109 // _ut.test('test_caseSensitive_false_caseMismatch', () {
2110 // final __test = new WildcardSearchPatternTest();
2111 // runJUnitTest(__test, __test.test_caseSensitive_false_caseMismatch);
2112 // });
2113 // _ut.test('test_caseSensitive_false_contentMismatch', () {
2114 // final __test = new WildcardSearchPatternTest();
2115 // runJUnitTest(__test, __test.test_caseSensitive_false_contentMismatch);
2116 // });
2117 // _ut.test('test_caseSensitive_true', () {
2118 // final __test = new WildcardSearchPatternTest();
2119 // runJUnitTest(__test, __test.test_caseSensitive_true);
2120 // });
2121 // _ut.test('test_nullElement', () {
2122 // final __test = new WildcardSearchPatternTest();
2123 // runJUnitTest(__test, __test.test_nullElement);
2124 // });
2125 // _ut.test('test_nullName', () {
2126 // final __test = new WildcardSearchPatternTest();
2127 // runJUnitTest(__test, __test.test_nullName);
2128 // });
2129 // });
2130 // }
2131 //}
2132 //
2133 //main() {
2134 // CountingSearchListenerTest.dartSuite();
2135 // FilterSearchListenerTest.dartSuite();
2136 // GatheringSearchListenerTest.dartSuite();
2137 // NameMatchingSearchListenerTest.dartSuite();
2138 // LibrarySearchScopeTest.dartSuite();
2139 // UniverseSearchScopeTest.dartSuite();
2140 // SearchEngineImplTest.dartSuite();
2141 // AndSearchPatternTest.dartSuite();
2142 // CamelCaseSearchPatternTest.dartSuite();
2143 // ExactSearchPatternTest.dartSuite();
2144 // OrSearchPatternTest.dartSuite();
2145 // PrefixSearchPatternTest.dartSuite();
2146 // RegularExpressionSearchPatternTest.dartSuite();
2147 // WildcardSearchPatternTest.dartSuite();
2148 //}
OLDNEW
« no previous file with comments | « pkg/analyzer/test/index/test_all.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698