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

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

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

Powered by Google App Engine
This is Rietveld 408576698