Index: pkg/analysis_services/test/search/search_engine_test.dart |
diff --git a/pkg/analysis_services/test/search/search_engine_test.dart b/pkg/analysis_services/test/search/search_engine_test.dart |
index db896c97d118161b780859d9791ca5af594f4de7..f6d02de9bed39785102a35c0b386ca5ed72c477c 100644 |
--- a/pkg/analysis_services/test/search/search_engine_test.dart |
+++ b/pkg/analysis_services/test/search/search_engine_test.dart |
@@ -5,2144 +5,659 @@ |
// This code was auto-generated, is not intended to be edited, and is subject to |
// significant change. Please see the README file for more information. |
-library engine.search_engine_test; |
+library services.src.search.search_engine_test; |
+ |
+import 'dart:async'; |
+ |
+import 'package:analysis_services/index/index.dart'; |
+import 'package:analysis_services/index/local_memory_index.dart'; |
+import 'package:analysis_services/search/search_engine.dart'; |
+import 'package:analysis_services/src/search/search_engine.dart'; |
+import 'package:analysis_testing/mocks.dart'; |
+import 'package:analysis_testing/reflective_tests.dart'; |
+import 'package:analyzer/src/generated/element.dart'; |
+import 'package:analyzer/src/generated/source.dart'; |
+import 'package:typed_mock/typed_mock.dart'; |
+import 'package:unittest/unittest.dart'; |
+ |
+import '../index/abstract_single_unit.dart'; |
main() { |
+ groupSep = ' | '; |
+ group('SearchEngineImplTest', () { |
+ runReflectiveTests(SearchEngineImplTest); |
+ }); |
} |
+class ExpectedMatch { |
+ final Element element; |
+ final MatchKind kind; |
+ SourceRange range; |
+ final bool isResolved; |
+ final bool isQualified; |
-//class AndSearchPatternTest extends EngineTestCase { |
-// Element _element = mock(Element); |
-// |
-// SearchPattern _patternA = mock(SearchPattern); |
-// |
-// SearchPattern _patternB = mock(SearchPattern); |
-// |
-// AndSearchPattern _pattern = new AndSearchPattern([_patternA, _patternB]); |
-// |
-// void test_allExact() { |
-// when(_patternA.matches(_element)).thenReturn(MatchQuality.EXACT); |
-// when(_patternB.matches(_element)).thenReturn(MatchQuality.EXACT); |
-// // validate |
-// JUnitTestCase.assertSame(MatchQuality.EXACT, _pattern.matches(_element)); |
-// } |
-// |
-// void test_ExactName() { |
-// when(_patternA.matches(_element)).thenReturn(MatchQuality.EXACT); |
-// when(_patternB.matches(_element)).thenReturn(MatchQuality.NAME); |
-// // validate |
-// JUnitTestCase.assertSame(MatchQuality.EXACT, _pattern.matches(_element)); |
-// } |
-// |
-// void test_NameExact() { |
-// when(_patternA.matches(_element)).thenReturn(MatchQuality.NAME); |
-// when(_patternB.matches(_element)).thenReturn(MatchQuality.EXACT); |
-// // validate |
-// JUnitTestCase.assertSame(MatchQuality.EXACT, _pattern.matches(_element)); |
-// } |
-// |
-// void test_oneNull() { |
-// when(_patternA.matches(_element)).thenReturn(MatchQuality.EXACT); |
-// when(_patternB.matches(_element)).thenReturn(null); |
-// // validate |
-// JUnitTestCase.assertSame(null, _pattern.matches(_element)); |
-// } |
-// |
-// static dartSuite() { |
-// _ut.group('AndSearchPatternTest', () { |
-// _ut.test('test_ExactName', () { |
-// final __test = new AndSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_ExactName); |
-// }); |
-// _ut.test('test_NameExact', () { |
-// final __test = new AndSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_NameExact); |
-// }); |
-// _ut.test('test_allExact', () { |
-// final __test = new AndSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_allExact); |
-// }); |
-// _ut.test('test_oneNull', () { |
-// final __test = new AndSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_oneNull); |
-// }); |
-// }); |
-// } |
-//} |
-// |
-//class CamelCaseSearchPatternTest extends EngineTestCase { |
-// void test_matchExact_samePartCount() { |
-// Element element = mock(Element); |
-// when(element.displayName).thenReturn("HashMap"); |
-// // |
-// CamelCaseSearchPattern pattern = new CamelCaseSearchPattern("HM", true); |
-// JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(element)); |
-// } |
-// |
-// void test_matchExact_withLowerCase() { |
-// Element element = mock(Element); |
-// when(element.displayName).thenReturn("HashMap"); |
-// // |
-// CamelCaseSearchPattern pattern = new CamelCaseSearchPattern("HaMa", true); |
-// JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(element)); |
-// } |
-// |
-// void test_matchNot_nullName() { |
-// Element element = mock(Element); |
-// when(element.displayName).thenReturn(null); |
-// // |
-// CamelCaseSearchPattern pattern = new CamelCaseSearchPattern("HM", true); |
-// JUnitTestCase.assertSame(null, pattern.matches(element)); |
-// } |
-// |
-// void test_matchNot_samePartCount() { |
-// Element element = mock(Element); |
-// when(element.displayName).thenReturn("LinkedHashMap"); |
-// // |
-// CamelCaseSearchPattern pattern = new CamelCaseSearchPattern("LH", true); |
-// JUnitTestCase.assertSame(null, pattern.matches(element)); |
-// } |
-// |
-// void test_matchNot_withLowerCase() { |
-// Element element = mock(Element); |
-// when(element.displayName).thenReturn("HashMap"); |
-// // |
-// CamelCaseSearchPattern pattern = new CamelCaseSearchPattern("HaMu", true); |
-// JUnitTestCase.assertSame(null, pattern.matches(element)); |
-// } |
-// |
-// static dartSuite() { |
-// _ut.group('CamelCaseSearchPatternTest', () { |
-// _ut.test('test_matchExact_samePartCount', () { |
-// final __test = new CamelCaseSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_matchExact_samePartCount); |
-// }); |
-// _ut.test('test_matchExact_withLowerCase', () { |
-// final __test = new CamelCaseSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_matchExact_withLowerCase); |
-// }); |
-// _ut.test('test_matchNot_nullName', () { |
-// final __test = new CamelCaseSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_matchNot_nullName); |
-// }); |
-// _ut.test('test_matchNot_samePartCount', () { |
-// final __test = new CamelCaseSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_matchNot_samePartCount); |
-// }); |
-// _ut.test('test_matchNot_withLowerCase', () { |
-// final __test = new CamelCaseSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_matchNot_withLowerCase); |
-// }); |
-// }); |
-// } |
-//} |
-// |
-//class CountingSearchListenerTest extends EngineTestCase { |
-// void test_matchFound() { |
-// SearchListener listener = mock(SearchListener); |
-// SearchMatch match = mock(SearchMatch); |
-// SearchListener countingListener = new CountingSearchListener(2, listener); |
-// // "match" should be passed to "listener" |
-// countingListener.matchFound(match); |
-// verify(listener).matchFound(match); |
-// verifyNoMoreInteractions(listener); |
-// } |
-// |
-// void test_searchComplete() { |
-// SearchListener listener = mock(SearchListener); |
-// SearchListener countingListener = new CountingSearchListener(2, listener); |
-// // complete 2 -> 1 |
-// countingListener.searchComplete(); |
-// verifyZeroInteractions(listener); |
-// // complete 2 -> 0 |
-// countingListener.searchComplete(); |
-// verify(listener).searchComplete(); |
-// } |
-// |
-// void test_searchComplete_zero() { |
-// SearchListener listener = mock(SearchListener); |
-// new CountingSearchListener(0, listener); |
-// // complete at 0 |
-// verify(listener).searchComplete(); |
-// } |
-// |
-// static dartSuite() { |
-// _ut.group('CountingSearchListenerTest', () { |
-// _ut.test('test_matchFound', () { |
-// final __test = new CountingSearchListenerTest(); |
-// runJUnitTest(__test, __test.test_matchFound); |
-// }); |
-// _ut.test('test_searchComplete', () { |
-// final __test = new CountingSearchListenerTest(); |
-// runJUnitTest(__test, __test.test_searchComplete); |
-// }); |
-// _ut.test('test_searchComplete_zero', () { |
-// final __test = new CountingSearchListenerTest(); |
-// runJUnitTest(__test, __test.test_searchComplete_zero); |
-// }); |
-// }); |
-// } |
-//} |
-// |
-//class ExactSearchPatternTest extends EngineTestCase { |
-// Element _element = mock(Element); |
-// |
-// void test_caseInsensitive_false() { |
-// SearchPattern pattern = new ExactSearchPattern("HashMa", false); |
-// when(_element.displayName).thenReturn("HashMap"); |
-// // validate |
-// JUnitTestCase.assertSame(null, pattern.matches(_element)); |
-// } |
-// |
-// void test_caseInsensitive_true() { |
-// SearchPattern pattern = new ExactSearchPattern("HashMap", false); |
-// when(_element.displayName).thenReturn("HashMaP"); |
-// // validate |
-// JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element)); |
-// } |
-// |
-// void test_caseSensitive_false() { |
-// SearchPattern pattern = new ExactSearchPattern("HashMa", true); |
-// when(_element.displayName).thenReturn("HashMap"); |
-// // validate |
-// JUnitTestCase.assertSame(null, pattern.matches(_element)); |
-// } |
-// |
-// void test_caseSensitive_true() { |
-// SearchPattern pattern = new ExactSearchPattern("HashMap", true); |
-// when(_element.displayName).thenReturn("HashMap"); |
-// // validate |
-// JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element)); |
-// } |
-// |
-// void test_nullName() { |
-// SearchPattern pattern = new ExactSearchPattern("HashMap", true); |
-// when(_element.displayName).thenReturn(null); |
-// // validate |
-// JUnitTestCase.assertSame(null, pattern.matches(_element)); |
-// } |
-// |
-// static dartSuite() { |
-// _ut.group('ExactSearchPatternTest', () { |
-// _ut.test('test_caseInsensitive_false', () { |
-// final __test = new ExactSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseInsensitive_false); |
-// }); |
-// _ut.test('test_caseInsensitive_true', () { |
-// final __test = new ExactSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseInsensitive_true); |
-// }); |
-// _ut.test('test_caseSensitive_false', () { |
-// final __test = new ExactSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseSensitive_false); |
-// }); |
-// _ut.test('test_caseSensitive_true', () { |
-// final __test = new ExactSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseSensitive_true); |
-// }); |
-// _ut.test('test_nullName', () { |
-// final __test = new ExactSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_nullName); |
-// }); |
-// }); |
-// } |
-//} |
-// |
-//class FilterSearchListenerTest extends EngineTestCase { |
-// SearchListener _listener = mock(SearchListener); |
-// |
-// SearchMatch _match = mock(SearchMatch); |
-// |
-// SearchFilter _filter = mock(SearchFilter); |
-// |
-// SearchListener _filteredListener = new FilteredSearchListener(_filter, _listener); |
-// |
-// void test_matchFound_filterFalse() { |
-// when(_filter.passes(_match)).thenReturn(false); |
-// // "match" should be passed to "listener" |
-// _filteredListener.matchFound(_match); |
-// verifyNoMoreInteractions(_listener); |
-// } |
-// |
-// void test_matchFound_filterTrue() { |
-// when(_filter.passes(_match)).thenReturn(true); |
-// // "match" should be passed to "listener" |
-// _filteredListener.matchFound(_match); |
-// verify(_listener).matchFound(_match); |
-// verifyNoMoreInteractions(_listener); |
-// } |
-// |
-// void test_searchComplete() { |
-// _filteredListener.searchComplete(); |
-// verify(_listener).searchComplete(); |
-// verifyNoMoreInteractions(_listener); |
-// } |
-// |
-// static dartSuite() { |
-// _ut.group('FilterSearchListenerTest', () { |
-// _ut.test('test_matchFound_filterFalse', () { |
-// final __test = new FilterSearchListenerTest(); |
-// runJUnitTest(__test, __test.test_matchFound_filterFalse); |
-// }); |
-// _ut.test('test_matchFound_filterTrue', () { |
-// final __test = new FilterSearchListenerTest(); |
-// runJUnitTest(__test, __test.test_matchFound_filterTrue); |
-// }); |
-// _ut.test('test_searchComplete', () { |
-// final __test = new FilterSearchListenerTest(); |
-// runJUnitTest(__test, __test.test_searchComplete); |
-// }); |
-// }); |
-// } |
-//} |
-// |
-//class GatheringSearchListenerTest extends EngineTestCase { |
-// SearchMatch _matchA = mock(SearchMatch); |
-// |
-// SearchMatch _matchB = mock(SearchMatch); |
-// |
-// GatheringSearchListener _gatheringListener = new GatheringSearchListener(); |
-// |
-// void test_matchFound() { |
-// Element elementA = mock(Element); |
-// Element elementB = mock(Element); |
-// when(elementA.displayName).thenReturn("A"); |
-// when(elementB.displayName).thenReturn("B"); |
-// when(_matchA.element).thenReturn(elementA); |
-// when(_matchB.element).thenReturn(elementB); |
-// // matchB |
-// _gatheringListener.matchFound(_matchB); |
-// JUnitTestCase.assertFalse(_gatheringListener.isComplete); |
-// assertThat(_gatheringListener.matches).containsExactly(_matchB); |
-// // matchA |
-// _gatheringListener.matchFound(_matchA); |
-// JUnitTestCase.assertFalse(_gatheringListener.isComplete); |
-// assertThat(_gatheringListener.matches).containsExactly(_matchA, _matchB); |
-// } |
-// |
-// void test_searchComplete() { |
-// JUnitTestCase.assertFalse(_gatheringListener.isComplete); |
-// // complete |
-// _gatheringListener.searchComplete(); |
-// JUnitTestCase.assertTrue(_gatheringListener.isComplete); |
-// } |
-// |
-// static dartSuite() { |
-// _ut.group('GatheringSearchListenerTest', () { |
-// _ut.test('test_matchFound', () { |
-// final __test = new GatheringSearchListenerTest(); |
-// runJUnitTest(__test, __test.test_matchFound); |
-// }); |
-// _ut.test('test_searchComplete', () { |
-// final __test = new GatheringSearchListenerTest(); |
-// runJUnitTest(__test, __test.test_searchComplete); |
-// }); |
-// }); |
-// } |
-//} |
-// |
-//class LibrarySearchScopeTest extends EngineTestCase { |
-// LibraryElement _libraryA = mock(LibraryElement); |
-// |
-// LibraryElement _libraryB = mock(LibraryElement); |
-// |
-// Element _element = mock(Element); |
-// |
-// void test_arrayConstructor_inA_false() { |
-// when(_element.getAncestor((element) => element is LibraryElement)).thenReturn(_libraryB); |
-// LibrarySearchScope scope = new LibrarySearchScope.con2([_libraryA]); |
-// assertThat(scope.libraries).containsOnly(_libraryA); |
-// JUnitTestCase.assertFalse(scope.encloses(_element)); |
-// } |
-// |
-// void test_arrayConstructor_inA_true() { |
-// when(_element.getAncestor((element) => element is LibraryElement)).thenReturn(_libraryA); |
-// LibrarySearchScope scope = new LibrarySearchScope.con2([_libraryA, _libraryB]); |
-// assertThat(scope.libraries).containsOnly(_libraryA, _libraryB); |
-// JUnitTestCase.assertTrue(scope.encloses(_element)); |
-// } |
-// |
-// void test_collectionConstructor_inB() { |
-// when(_element.getAncestor((element) => element is LibraryElement)).thenReturn(_libraryB); |
-// LibrarySearchScope scope = new LibrarySearchScope.con1(ImmutableSet.of(_libraryA, _libraryB)); |
-// assertThat(scope.libraries).containsOnly(_libraryA, _libraryB); |
-// JUnitTestCase.assertTrue(scope.encloses(_element)); |
-// } |
-// |
-// static dartSuite() { |
-// _ut.group('LibrarySearchScopeTest', () { |
-// _ut.test('test_arrayConstructor_inA_false', () { |
-// final __test = new LibrarySearchScopeTest(); |
-// runJUnitTest(__test, __test.test_arrayConstructor_inA_false); |
-// }); |
-// _ut.test('test_arrayConstructor_inA_true', () { |
-// final __test = new LibrarySearchScopeTest(); |
-// runJUnitTest(__test, __test.test_arrayConstructor_inA_true); |
-// }); |
-// _ut.test('test_collectionConstructor_inB', () { |
-// final __test = new LibrarySearchScopeTest(); |
-// runJUnitTest(__test, __test.test_collectionConstructor_inB); |
-// }); |
-// }); |
-// } |
-//} |
-// |
-//class NameMatchingSearchListenerTest extends EngineTestCase { |
-// SearchListener _listener = mock(SearchListener); |
-// |
-// Element _element = mock(Element); |
-// |
-// SearchMatch _match = mock(SearchMatch); |
-// |
-// SearchPattern _pattern = mock(SearchPattern); |
-// |
-// SearchListener _nameMatchingListener = new NameMatchingSearchListener(_pattern, _listener); |
-// |
-// void test_matchFound_patternFalse() { |
-// when(_pattern.matches(_element)).thenReturn(null); |
-// // verify |
-// _nameMatchingListener.matchFound(_match); |
-// verifyNoMoreInteractions(_listener); |
-// } |
-// |
-// void test_matchFound_patternTrue() { |
-// when(_pattern.matches(_element)).thenReturn(MatchQuality.EXACT); |
-// // verify |
-// _nameMatchingListener.matchFound(_match); |
-// verify(_listener).matchFound(_match); |
-// verifyNoMoreInteractions(_listener); |
-// } |
-// |
-// @override |
-// void setUp() { |
-// super.setUp(); |
-// when(_match.element).thenReturn(_element); |
-// } |
-// |
-// static dartSuite() { |
-// _ut.group('NameMatchingSearchListenerTest', () { |
-// _ut.test('test_matchFound_patternFalse', () { |
-// final __test = new NameMatchingSearchListenerTest(); |
-// runJUnitTest(__test, __test.test_matchFound_patternFalse); |
-// }); |
-// _ut.test('test_matchFound_patternTrue', () { |
-// final __test = new NameMatchingSearchListenerTest(); |
-// runJUnitTest(__test, __test.test_matchFound_patternTrue); |
-// }); |
-// }); |
-// } |
-//} |
-// |
-//class OrSearchPatternTest extends EngineTestCase { |
-// Element _element = mock(Element); |
-// |
-// SearchPattern _patternA = mock(SearchPattern); |
-// |
-// SearchPattern _patternB = mock(SearchPattern); |
-// |
-// SearchPattern _pattern = new OrSearchPattern([_patternA, _patternB]); |
-// |
-// void test_allExact() { |
-// when(_patternA.matches(_element)).thenReturn(MatchQuality.EXACT); |
-// when(_patternB.matches(_element)).thenReturn(MatchQuality.EXACT); |
-// // validate |
-// JUnitTestCase.assertSame(MatchQuality.EXACT, _pattern.matches(_element)); |
-// } |
-// |
-// void test_ExactName() { |
-// when(_patternA.matches(_element)).thenReturn(MatchQuality.EXACT); |
-// when(_patternB.matches(_element)).thenReturn(MatchQuality.NAME); |
-// // validate |
-// JUnitTestCase.assertSame(MatchQuality.EXACT, _pattern.matches(_element)); |
-// } |
-// |
-// void test_NameExact() { |
-// when(_patternA.matches(_element)).thenReturn(MatchQuality.NAME); |
-// when(_patternB.matches(_element)).thenReturn(MatchQuality.EXACT); |
-// // validate |
-// JUnitTestCase.assertSame(MatchQuality.NAME, _pattern.matches(_element)); |
-// } |
-// |
-// void test_NullNull() { |
-// when(_patternA.matches(_element)).thenReturn(null); |
-// when(_patternB.matches(_element)).thenReturn(null); |
-// // validate |
-// JUnitTestCase.assertSame(null, _pattern.matches(_element)); |
-// } |
-// |
-// static dartSuite() { |
-// _ut.group('OrSearchPatternTest', () { |
-// _ut.test('test_ExactName', () { |
-// final __test = new OrSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_ExactName); |
-// }); |
-// _ut.test('test_NameExact', () { |
-// final __test = new OrSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_NameExact); |
-// }); |
-// _ut.test('test_NullNull', () { |
-// final __test = new OrSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_NullNull); |
-// }); |
-// _ut.test('test_allExact', () { |
-// final __test = new OrSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_allExact); |
-// }); |
-// }); |
-// } |
-//} |
-// |
-//class PrefixSearchPatternTest extends EngineTestCase { |
-// Element _element = mock(Element); |
-// |
-// void test_caseInsensitive_contentMatch_caseMatch() { |
-// SearchPattern pattern = new PrefixSearchPattern("HashMa", false); |
-// when(_element.displayName).thenReturn("HashMap"); |
-// // validate |
-// JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element)); |
-// } |
-// |
-// void test_caseInsensitive_contentMatch_caseMismatch() { |
-// SearchPattern pattern = new PrefixSearchPattern("HaSHMa", false); |
-// when(_element.displayName).thenReturn("hashMaP"); |
-// // validate |
-// JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element)); |
-// } |
-// |
-// void test_caseInsensitive_contentMismatch() { |
-// SearchPattern pattern = new PrefixSearchPattern("HashMa", false); |
-// when(_element.displayName).thenReturn("HashTable"); |
-// // validate |
-// JUnitTestCase.assertSame(null, pattern.matches(_element)); |
-// } |
-// |
-// void test_caseSensitive_contentMatch() { |
-// SearchPattern pattern = new PrefixSearchPattern("HashMa", true); |
-// when(_element.displayName).thenReturn("HashMap"); |
-// // validate |
-// JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element)); |
-// } |
-// |
-// void test_caseSensitive_contentMismatch() { |
-// SearchPattern pattern = new PrefixSearchPattern("HashMa", true); |
-// when(_element.displayName).thenReturn("HashTable"); |
-// // validate |
-// JUnitTestCase.assertSame(null, pattern.matches(_element)); |
-// } |
-// |
-// void test_nullElement() { |
-// SearchPattern pattern = new PrefixSearchPattern("HashMa", false); |
-// // validate |
-// JUnitTestCase.assertSame(null, pattern.matches(null)); |
-// } |
-// |
-// void test_nullName() { |
-// SearchPattern pattern = new PrefixSearchPattern("HashMa", false); |
-// when(_element.displayName).thenReturn(null); |
-// // validate |
-// JUnitTestCase.assertSame(null, pattern.matches(_element)); |
-// } |
-// |
-// static dartSuite() { |
-// _ut.group('PrefixSearchPatternTest', () { |
-// _ut.test('test_caseInsensitive_contentMatch_caseMatch', () { |
-// final __test = new PrefixSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseInsensitive_contentMatch_caseMatch); |
-// }); |
-// _ut.test('test_caseInsensitive_contentMatch_caseMismatch', () { |
-// final __test = new PrefixSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseInsensitive_contentMatch_caseMismatch); |
-// }); |
-// _ut.test('test_caseInsensitive_contentMismatch', () { |
-// final __test = new PrefixSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseInsensitive_contentMismatch); |
-// }); |
-// _ut.test('test_caseSensitive_contentMatch', () { |
-// final __test = new PrefixSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseSensitive_contentMatch); |
-// }); |
-// _ut.test('test_caseSensitive_contentMismatch', () { |
-// final __test = new PrefixSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseSensitive_contentMismatch); |
-// }); |
-// _ut.test('test_nullElement', () { |
-// final __test = new PrefixSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_nullElement); |
-// }); |
-// _ut.test('test_nullName', () { |
-// final __test = new PrefixSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_nullName); |
-// }); |
-// }); |
-// } |
-//} |
-// |
-//class RegularExpressionSearchPatternTest extends EngineTestCase { |
-// Element _element = mock(Element); |
-// |
-// void test_caseInsensitive_false_contentMismatch() { |
-// SearchPattern pattern = new RegularExpressionSearchPattern("H[a-z]*Map", false); |
-// when(_element.displayName).thenReturn("Maps"); |
-// // validate |
-// JUnitTestCase.assertSame(null, pattern.matches(_element)); |
-// } |
-// |
-// void test_caseInsensitive_true_caseMismatch() { |
-// SearchPattern pattern = new RegularExpressionSearchPattern("H[a-z]*MaP", false); |
-// when(_element.displayName).thenReturn("HashMap"); |
-// // validate |
-// JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element)); |
-// } |
-// |
-// void test_caseSensitive_false_caseMismatch() { |
-// SearchPattern pattern = new RegularExpressionSearchPattern("H[a-z]*MaP", true); |
-// when(_element.displayName).thenReturn("HashMap"); |
-// // validate |
-// JUnitTestCase.assertSame(null, pattern.matches(_element)); |
-// } |
-// |
-// void test_caseSensitive_false_contentMismatch() { |
-// SearchPattern pattern = new RegularExpressionSearchPattern("H[a-z]*Map", true); |
-// when(_element.displayName).thenReturn("Maps"); |
-// // validate |
-// JUnitTestCase.assertSame(null, pattern.matches(_element)); |
-// } |
-// |
-// void test_caseSensitive_true() { |
-// SearchPattern pattern = new RegularExpressionSearchPattern("H.*Map", true); |
-// when(_element.displayName).thenReturn("HashMap"); |
-// // validate |
-// JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element)); |
-// } |
-// |
-// void test_nullElement() { |
-// SearchPattern pattern = new RegularExpressionSearchPattern("H.*Map", true); |
-// // validate |
-// JUnitTestCase.assertSame(null, pattern.matches(null)); |
-// } |
-// |
-// void test_nullName() { |
-// SearchPattern pattern = new RegularExpressionSearchPattern("H.*Map", true); |
-// when(_element.displayName).thenReturn(null); |
-// // validate |
-// JUnitTestCase.assertSame(null, pattern.matches(_element)); |
-// } |
-// |
-// static dartSuite() { |
-// _ut.group('RegularExpressionSearchPatternTest', () { |
-// _ut.test('test_caseInsensitive_false_contentMismatch', () { |
-// final __test = new RegularExpressionSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseInsensitive_false_contentMismatch); |
-// }); |
-// _ut.test('test_caseInsensitive_true_caseMismatch', () { |
-// final __test = new RegularExpressionSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseInsensitive_true_caseMismatch); |
-// }); |
-// _ut.test('test_caseSensitive_false_caseMismatch', () { |
-// final __test = new RegularExpressionSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseSensitive_false_caseMismatch); |
-// }); |
-// _ut.test('test_caseSensitive_false_contentMismatch', () { |
-// final __test = new RegularExpressionSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseSensitive_false_contentMismatch); |
-// }); |
-// _ut.test('test_caseSensitive_true', () { |
-// final __test = new RegularExpressionSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseSensitive_true); |
-// }); |
-// _ut.test('test_nullElement', () { |
-// final __test = new RegularExpressionSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_nullElement); |
-// }); |
-// _ut.test('test_nullName', () { |
-// final __test = new RegularExpressionSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_nullName); |
-// }); |
-// }); |
-// } |
-//} |
-// |
-//class SearchEngineImplTest extends EngineTestCase { |
-// static void _assertMatches(List<SearchMatch> matches, List<SearchEngineImplTest_ExpectedMatch> expectedMatches) { |
-// assertThat(matches).hasSize(expectedMatches.length); |
-// for (SearchMatch match in matches) { |
-// bool found = false; |
-// String msg = match.toString(); |
-// for (SearchEngineImplTest_ExpectedMatch expectedMatch in expectedMatches) { |
-// if (match.element == expectedMatch._element && match.kind == expectedMatch._kind && match.quality == expectedMatch._quality && match.sourceRange == expectedMatch._range && match.isQualified == expectedMatch._qualified) { |
-// found = true; |
-// break; |
-// } |
-// } |
-// if (!found) { |
-// JUnitTestCase.fail("Not found: ${msg}"); |
-// } |
-// } |
-// } |
-// |
-// IndexStore _indexStore = IndexFactory.newSplitIndexStore(new MemoryNodeManager()); |
-// |
-// static AnalysisContext _CONTEXT = mock(AnalysisContext); |
-// |
-// int _nextLocationId = 0; |
-// |
-// SearchScope _scope; |
-// |
-// SearchPattern _pattern = null; |
-// |
-// SearchFilter _filter = null; |
-// |
-// Source _source = mock(Source); |
-// |
-// CompilationUnitElement _unitElement = mock(CompilationUnitElement); |
-// |
-// LibraryElement _libraryElement = mock(LibraryElement); |
-// |
-// Element _elementA = _mockElement(Element, ElementKind.CLASS); |
-// |
-// Element _elementB = _mockElement(Element, ElementKind.CLASS); |
-// |
-// Element _elementC = _mockElement(Element, ElementKind.CLASS); |
-// |
-// Element _elementD = _mockElement(Element, ElementKind.CLASS); |
-// |
-// Element _elementE = _mockElement(Element, ElementKind.CLASS); |
-// |
-// void fail_searchAssignedTypes_assignments() { |
-// // TODO(scheglov) does not work - new split index store cannot store types (yet?) |
-// PropertyAccessorElement setterElement = _mockElement(PropertyAccessorElement, ElementKind.SETTER); |
-// FieldElement fieldElement = _mockElement(FieldElement, ElementKind.FIELD); |
-// when(fieldElement.setter).thenReturn(setterElement); |
-// DartType typeA = mock(DartType); |
-// DartType typeB = mock(DartType); |
-// DartType typeC = mock(DartType); |
-// _indexStore.aboutToIndexDart(_CONTEXT, _unitElement); |
-// { |
-// Location location = new Location(_elementA, 1, 10); |
-// location = new LocationWithData<DartType>.con1(location, typeA); |
-// _indexStore.recordRelationship(setterElement, IndexConstants.IS_REFERENCED_BY_QUALIFIED, location); |
-// } |
-// { |
-// Location location = new Location(_elementB, 2, 20); |
-// location = new LocationWithData<DartType>.con1(location, typeB); |
-// _indexStore.recordRelationship(setterElement, IndexConstants.IS_REFERENCED_BY_UNQUALIFIED, location); |
-// } |
-// // will be filtered by scope |
-// { |
-// Location location = new Location(_elementC, 3, 30); |
-// location = new LocationWithData<DartType>.con1(location, typeC); |
-// _indexStore.recordRelationship(setterElement, IndexConstants.IS_REFERENCED_BY_QUALIFIED, location); |
-// } |
-// // not LocationWithData |
-// { |
-// Location location = new Location(_elementD, 4, 40); |
-// _indexStore.recordRelationship(setterElement, IndexConstants.IS_REFERENCED_BY_QUALIFIED, location); |
-// } |
-// _indexStore.doneIndex(); |
-// // ask types |
-// Set<DartType> types = _runSearch(new SearchRunner_SearchEngineImplTest_fail_searchAssignedTypes_assignments(fieldElement)); |
-// assertThat(types).containsOnly(typeA, typeB); |
-// } |
-// |
-// void fail_searchAssignedTypes_initializers() { |
-// // TODO(scheglov) does not work - new split index store cannot store types (yet?) |
-// FieldElement fieldElement = _mockElement(FieldElement, ElementKind.FIELD); |
-// DartType typeA = mock(DartType); |
-// DartType typeB = mock(DartType); |
-// { |
-// Location location = new Location(_elementA, 10, 1); |
-// location = new LocationWithData<DartType>.con1(location, typeA); |
-// _indexStore.recordRelationship(fieldElement, IndexConstants.IS_DEFINED_BY, location); |
-// } |
-// { |
-// Location location = new Location(_elementB, 20, 1); |
-// location = new LocationWithData<DartType>.con1(location, typeB); |
-// _indexStore.recordRelationship(fieldElement, IndexConstants.IS_REFERENCED_BY, location); |
-// } |
-// _indexStore.doneIndex(); |
-// // ask types |
-// Set<DartType> types = _runSearch(new SearchRunner_SearchEngineImplTest_fail_searchAssignedTypes_initializers(fieldElement)); |
-// assertThat(types).containsOnly(typeA, typeB); |
-// } |
-// |
-// void test_searchDeclarations_String() { |
-// Element referencedElement = new NameElementImpl("test"); |
-// { |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_DEFINED_BY, locationA); |
-// } |
-// { |
-// Location locationB = new Location(_elementB, 10, 20); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_DEFINED_BY, locationB); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _runSearch(new SearchRunner_SearchEngineImplTest_test_searchDeclarations_String(this)); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.NAME_DECLARATION, 1, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.NAME_DECLARATION, 10, 20)]); |
-// } |
-// |
-// void test_searchFunctionDeclarations() { |
-// LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY); |
-// _defineFunctionsAB(library); |
-// _scope = new LibrarySearchScope.con2([library]); |
-// // search matches |
-// List<SearchMatch> matches = _searchFunctionDeclarationsSync(); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.FUNCTION_DECLARATION, 1, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.FUNCTION_DECLARATION, 10, 20)]); |
-// } |
-// |
-// void test_searchFunctionDeclarations_async() { |
-// LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY); |
-// _defineFunctionsAB(library); |
-// _scope = new LibrarySearchScope.con2([library]); |
-// // search matches |
-// List<SearchMatch> matches = _searchFunctionDeclarationsAsync(); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.FUNCTION_DECLARATION, 1, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.FUNCTION_DECLARATION, 10, 20)]); |
-// } |
-// |
-// void test_searchFunctionDeclarations_inUniverse() { |
-// { |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(IndexConstants.UNIVERSE, IndexConstants.DEFINES_FUNCTION, locationA); |
-// } |
-// { |
-// Location locationB = new Location(_elementB, 10, 20); |
-// _indexStore.recordRelationship(IndexConstants.UNIVERSE, IndexConstants.DEFINES_FUNCTION, locationB); |
-// } |
-// _indexStore.doneIndex(); |
-// _scope = SearchScopeFactory.createUniverseScope(); |
-// // search matches |
-// List<SearchMatch> matches = _searchFunctionDeclarationsSync(); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.FUNCTION_DECLARATION, 1, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.FUNCTION_DECLARATION, 10, 20)]); |
-// } |
-// |
-// void test_searchFunctionDeclarations_useFilter() { |
-// LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY); |
-// _defineFunctionsAB(library); |
-// _scope = new LibrarySearchScope.con2([library]); |
-// // search "elementA" |
-// { |
-// _filter = new SearchFilter_SearchEngineImplTest_test_searchFunctionDeclarations_useFilter_2(this); |
-// List<SearchMatch> matches = _searchFunctionDeclarationsSync(); |
-// _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.FUNCTION_DECLARATION, 1, 2)]); |
-// } |
-// // search "elementB" |
-// { |
-// _filter = new SearchFilter_SearchEngineImplTest_test_searchFunctionDeclarations_useFilter(this); |
-// List<SearchMatch> matches = _searchFunctionDeclarationsSync(); |
-// _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.FUNCTION_DECLARATION, 10, 20)]); |
-// } |
-// } |
-// |
-// void test_searchFunctionDeclarations_usePattern() { |
-// LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY); |
-// _defineFunctionsAB(library); |
-// _scope = new LibrarySearchScope.con2([library]); |
-// // search "A" |
-// { |
-// _pattern = SearchPatternFactory.createExactPattern("A", true); |
-// List<SearchMatch> matches = _searchFunctionDeclarationsSync(); |
-// _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.FUNCTION_DECLARATION, 1, 2)]); |
-// } |
-// // search "B" |
-// { |
-// _pattern = SearchPatternFactory.createExactPattern("B", true); |
-// List<SearchMatch> matches = _searchFunctionDeclarationsSync(); |
-// _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.FUNCTION_DECLARATION, 10, 20)]); |
-// } |
-// } |
-// |
-// void test_searchReferences_AngularComponentElement() { |
-// AngularComponentElement referencedElement = _mockElement(AngularComponentElement, ElementKind.ANGULAR_COMPONENT); |
-// { |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR_REFERENCE, locationA); |
-// } |
-// { |
-// Location locationB = new Location(_elementB, 10, 20); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR_CLOSING_TAG_REFERENCE, locationB); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.ANGULAR_REFERENCE, 1, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.ANGULAR_CLOSING_TAG_REFERENCE, 10, 20)]); |
-// } |
-// |
-// void test_searchReferences_AngularControllerElement() { |
-// AngularControllerElement referencedElement = _mockElement(AngularControllerElement, ElementKind.ANGULAR_CONTROLLER); |
-// { |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR_REFERENCE, locationA); |
-// } |
-// { |
-// Location locationB = new Location(_elementB, 10, 20); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR_REFERENCE, locationB); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.ANGULAR_REFERENCE, 1, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.ANGULAR_REFERENCE, 10, 20)]); |
-// } |
-// |
-// void test_searchReferences_AngularFilterElement() { |
-// AngularFormatterElement referencedElement = _mockElement(AngularFormatterElement, ElementKind.ANGULAR_FORMATTER); |
-// { |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR_REFERENCE, locationA); |
-// } |
-// { |
-// Location locationB = new Location(_elementB, 10, 20); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR_REFERENCE, locationB); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.ANGULAR_REFERENCE, 1, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.ANGULAR_REFERENCE, 10, 20)]); |
-// } |
-// |
-// void test_searchReferences_AngularPropertyElement() { |
-// AngularPropertyElement referencedElement = _mockElement(AngularPropertyElement, ElementKind.ANGULAR_PROPERTY); |
-// { |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR_REFERENCE, locationA); |
-// } |
-// { |
-// Location locationB = new Location(_elementB, 10, 20); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR_REFERENCE, locationB); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.ANGULAR_REFERENCE, 1, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.ANGULAR_REFERENCE, 10, 20)]); |
-// } |
-// |
-// void test_searchReferences_AngularScopePropertyElement() { |
-// AngularScopePropertyElement referencedElement = _mockElement(AngularScopePropertyElement, ElementKind.ANGULAR_SCOPE_PROPERTY); |
-// { |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR_REFERENCE, locationA); |
-// } |
-// { |
-// Location locationB = new Location(_elementB, 10, 20); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR_REFERENCE, locationB); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.ANGULAR_REFERENCE, 1, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.ANGULAR_REFERENCE, 10, 20)]); |
-// } |
-// |
-// void test_searchReferences_AngularSelectorElement() { |
-// AngularSelectorElement referencedElement = _mockElement(AngularSelectorElement, ElementKind.ANGULAR_SELECTOR); |
-// { |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR_REFERENCE, locationA); |
-// } |
-// { |
-// Location locationB = new Location(_elementB, 10, 20); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.ANGULAR_REFERENCE, locationB); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.ANGULAR_REFERENCE, 1, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.ANGULAR_REFERENCE, 10, 20)]); |
-// } |
-// |
-// void test_searchReferences_ClassElement() { |
-// ClassElement referencedElement = _mockElement(ClassElement, ElementKind.CLASS); |
-// { |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY, locationA); |
-// } |
-// { |
-// Location locationB = new Location(_elementB, 10, 20); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY, locationB); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.TYPE_REFERENCE, 1, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.TYPE_REFERENCE, 10, 20)]); |
-// } |
-// |
-// void test_searchReferences_ClassElement_useScope() { |
-// LibraryElement libraryA = _mockElement(LibraryElement, ElementKind.LIBRARY); |
-// LibraryElement libraryB = _mockElement(LibraryElement, ElementKind.LIBRARY); |
-// ClassElement referencedElement = _mockElement(ClassElement, ElementKind.CLASS); |
-// { |
-// when(_elementA.getAncestor((element) => element is LibraryElement)).thenReturn(libraryA); |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY, locationA); |
-// } |
-// { |
-// when(_elementB.getAncestor((element) => element is LibraryElement)).thenReturn(libraryB); |
-// Location locationB = new Location(_elementB, 10, 20); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY, locationB); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches, in "libraryA" |
-// _scope = SearchScopeFactory.createLibraryScope3(libraryA); |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// // verify |
-// _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.TYPE_REFERENCE, 1, 2)]); |
-// } |
-// |
-// void test_searchReferences_CompilationUnitElement() { |
-// CompilationUnitElement referencedElement = _mockElement(CompilationUnitElement, ElementKind.COMPILATION_UNIT); |
-// { |
-// Location location = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY, location); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// // verify |
-// _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.UNIT_REFERENCE, 1, 2)]); |
-// } |
-// |
-// void test_searchReferences_ConstructorElement() { |
-// ConstructorElement referencedElement = _mockElement(ConstructorElement, ElementKind.CONSTRUCTOR); |
-// { |
-// Location location = new Location(_elementA, 10, 1); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_DEFINED_BY, location); |
-// } |
-// { |
-// Location location = new Location(_elementB, 20, 2); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY, location); |
-// } |
-// { |
-// Location location = new Location(_elementC, 30, 3); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY, location); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.CONSTRUCTOR_DECLARATION, 10, 1), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.CONSTRUCTOR_REFERENCE, 20, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementC, MatchKind.CONSTRUCTOR_REFERENCE, 30, 3)]); |
-// } |
-// |
-// void test_searchReferences_Element_unknown() { |
-// List<SearchMatch> matches = _searchReferencesSync(Element, null); |
-// assertThat(matches).isEmpty(); |
-// } |
-// |
-// void test_searchReferences_FieldElement() { |
-// PropertyAccessorElement getterElement = _mockElement(PropertyAccessorElement, ElementKind.GETTER); |
-// PropertyAccessorElement setterElement = _mockElement(PropertyAccessorElement, ElementKind.SETTER); |
-// FieldElement fieldElement = _mockElement(FieldElement, ElementKind.FIELD); |
-// when(fieldElement.getter).thenReturn(getterElement); |
-// when(fieldElement.setter).thenReturn(setterElement); |
-// { |
-// Location location = new Location(_elementA, 1, 10); |
-// _indexStore.recordRelationship(getterElement, IndexConstants.IS_REFERENCED_BY_UNQUALIFIED, location); |
-// } |
-// { |
-// Location location = new Location(_elementB, 2, 20); |
-// _indexStore.recordRelationship(getterElement, IndexConstants.IS_REFERENCED_BY_QUALIFIED, location); |
-// } |
-// { |
-// Location location = new Location(_elementC, 3, 30); |
-// _indexStore.recordRelationship(setterElement, IndexConstants.IS_REFERENCED_BY_UNQUALIFIED, location); |
-// } |
-// { |
-// Location location = new Location(_elementD, 4, 40); |
-// _indexStore.recordRelationship(setterElement, IndexConstants.IS_REFERENCED_BY_QUALIFIED, location); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, fieldElement); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementA, MatchKind.FIELD_READ, 1, 10, false), |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementB, MatchKind.FIELD_READ, 2, 20, true), |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementC, MatchKind.FIELD_WRITE, 3, 30, false), |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementD, MatchKind.FIELD_WRITE, 4, 40, true)]); |
-// } |
-// |
-// void test_searchReferences_FieldElement_invocation() { |
-// PropertyAccessorElement getterElement = _mockElement(PropertyAccessorElement, ElementKind.GETTER); |
-// FieldElement fieldElement = _mockElement(FieldElement, ElementKind.FIELD); |
-// when(fieldElement.getter).thenReturn(getterElement); |
-// { |
-// Location location = new Location(_elementA, 1, 10); |
-// _indexStore.recordRelationship(getterElement, IndexConstants.IS_INVOKED_BY_QUALIFIED, location); |
-// } |
-// { |
-// Location location = new Location(_elementB, 2, 20); |
-// _indexStore.recordRelationship(getterElement, IndexConstants.IS_INVOKED_BY_UNQUALIFIED, location); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, fieldElement); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementA, MatchKind.FIELD_INVOCATION, 1, 10, true), |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementB, MatchKind.FIELD_INVOCATION, 2, 20, false)]); |
-// } |
-// |
-// void test_searchReferences_FieldElement2() { |
-// FieldElement fieldElement = _mockElement(FieldElement, ElementKind.FIELD); |
-// { |
-// Location location = new Location(_elementA, 1, 10); |
-// _indexStore.recordRelationship(fieldElement, IndexConstants.IS_REFERENCED_BY, location); |
-// } |
-// { |
-// Location location = new Location(_elementB, 2, 20); |
-// _indexStore.recordRelationship(fieldElement, IndexConstants.IS_REFERENCED_BY_QUALIFIED, location); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, fieldElement); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementA, MatchKind.FIELD_REFERENCE, 1, 10, false), |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementB, MatchKind.FIELD_REFERENCE, 2, 20, true)]); |
-// } |
-// |
-// void test_searchReferences_FunctionElement() { |
-// FunctionElement referencedElement = _mockElement(FunctionElement, ElementKind.FUNCTION); |
-// { |
-// Location location = new Location(_elementA, 1, 10); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_INVOKED_BY, location); |
-// } |
-// { |
-// Location location = new Location(_elementB, 2, 20); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY, location); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.FUNCTION_EXECUTION, 1, 10), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.FUNCTION_REFERENCE, 2, 20)]); |
-// } |
-// |
-// void test_searchReferences_ImportElement() { |
-// ImportElement referencedElement = _mockElement(ImportElement, ElementKind.IMPORT); |
-// { |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY, locationA); |
-// } |
-// { |
-// Location locationB = new Location(_elementB, 10, 0); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY, locationB); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.IMPORT_REFERENCE, 1, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.IMPORT_REFERENCE, 10, 0)]); |
-// } |
-// |
-// void test_searchReferences_LibraryElement() { |
-// LibraryElement referencedElement = _mockElement(LibraryElement, ElementKind.LIBRARY); |
-// { |
-// Location location = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY, location); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// // verify |
-// _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.LIBRARY_REFERENCE, 1, 2)]); |
-// } |
-// |
-// void test_searchReferences_MethodElement() { |
-// MethodElement referencedElement = _mockElement(MethodElement, ElementKind.METHOD); |
-// { |
-// Location location = new Location(_elementA, 1, 10); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_INVOKED_BY_UNQUALIFIED, location); |
-// } |
-// { |
-// Location location = new Location(_elementB, 2, 20); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_INVOKED_BY_QUALIFIED, location); |
-// } |
-// { |
-// Location location = new Location(_elementC, 3, 30); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY_UNQUALIFIED, location); |
-// } |
-// { |
-// Location location = new Location(_elementD, 4, 40); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY_QUALIFIED, location); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementA, MatchKind.METHOD_INVOCATION, 1, 10, false), |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementB, MatchKind.METHOD_INVOCATION, 2, 20, true), |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementC, MatchKind.METHOD_REFERENCE, 3, 30, false), |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementD, MatchKind.METHOD_REFERENCE, 4, 40, true)]); |
-// } |
-// |
-// void test_searchReferences_MethodMember() { |
-// MethodElement referencedElement = _mockElement(MethodElement, ElementKind.METHOD); |
-// { |
-// Location location = new Location(_elementA, 1, 10); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_INVOKED_BY_UNQUALIFIED, location); |
-// } |
-// { |
-// Location location = new Location(_elementB, 2, 20); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_INVOKED_BY_QUALIFIED, location); |
-// } |
-// { |
-// Location location = new Location(_elementC, 3, 30); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY_UNQUALIFIED, location); |
-// } |
-// { |
-// Location location = new Location(_elementD, 4, 40); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY_QUALIFIED, location); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// MethodMember referencedMember = new MethodMember(referencedElement, null); |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedMember); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementA, MatchKind.METHOD_INVOCATION, 1, 10, false), |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementB, MatchKind.METHOD_INVOCATION, 2, 20, true), |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementC, MatchKind.METHOD_REFERENCE, 3, 30, false), |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementD, MatchKind.METHOD_REFERENCE, 4, 40, true)]); |
-// } |
-// |
-// void test_searchReferences_notSupported() { |
-// Element referencedElement = _mockElement(Element, ElementKind.UNIVERSE); |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// assertThat(matches).isEmpty(); |
-// } |
-// |
-// void test_searchReferences_ParameterElement() { |
-// ParameterElement referencedElement = _mockElement(ParameterElement, ElementKind.PARAMETER); |
-// { |
-// Location location = new Location(_elementA, 1, 10); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_READ_BY, location); |
-// } |
-// { |
-// Location location = new Location(_elementB, 2, 20); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_WRITTEN_BY, location); |
-// } |
-// { |
-// Location location = new Location(_elementC, 3, 30); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_READ_WRITTEN_BY, location); |
-// } |
-// { |
-// Location location = new Location(_elementD, 4, 40); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY, location); |
-// } |
-// { |
-// Location location = new Location(_elementD, 5, 50); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_INVOKED_BY, location); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// // verify |
-// // TODO(scheglov) why no MatchKind.FIELD_READ_WRITE ? |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.VARIABLE_READ, 1, 10), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.VARIABLE_WRITE, 2, 20), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementC, MatchKind.VARIABLE_READ_WRITE, 3, 30), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementD, MatchKind.NAMED_PARAMETER_REFERENCE, 4, 40), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementD, MatchKind.FUNCTION_EXECUTION, 5, 50)]); |
-// } |
-// |
-// void test_searchReferences_PropertyAccessorElement_getter() { |
-// PropertyAccessorElement accessor = _mockElement(PropertyAccessorElement, ElementKind.GETTER); |
-// { |
-// Location location = new Location(_elementA, 1, 10); |
-// _indexStore.recordRelationship(accessor, IndexConstants.IS_REFERENCED_BY_UNQUALIFIED, location); |
-// } |
-// { |
-// Location location = new Location(_elementB, 2, 20); |
-// _indexStore.recordRelationship(accessor, IndexConstants.IS_REFERENCED_BY_QUALIFIED, location); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, accessor); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementA, MatchKind.PROPERTY_ACCESSOR_REFERENCE, 1, 10, false), |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementB, MatchKind.PROPERTY_ACCESSOR_REFERENCE, 2, 20, true)]); |
-// } |
-// |
-// void test_searchReferences_PropertyAccessorElement_setter() { |
-// PropertyAccessorElement accessor = _mockElement(PropertyAccessorElement, ElementKind.SETTER); |
-// { |
-// Location location = new Location(_elementA, 1, 10); |
-// _indexStore.recordRelationship(accessor, IndexConstants.IS_REFERENCED_BY_UNQUALIFIED, location); |
-// } |
-// { |
-// Location location = new Location(_elementB, 2, 20); |
-// _indexStore.recordRelationship(accessor, IndexConstants.IS_REFERENCED_BY_QUALIFIED, location); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, accessor); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementA, MatchKind.PROPERTY_ACCESSOR_REFERENCE, 1, 10, false), |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementB, MatchKind.PROPERTY_ACCESSOR_REFERENCE, 2, 20, true)]); |
-// } |
-// |
-// void test_searchReferences_TopLevelVariableElement() { |
-// PropertyAccessorElement getterElement = _mockElement(PropertyAccessorElement, ElementKind.GETTER); |
-// PropertyAccessorElement setterElement = _mockElement(PropertyAccessorElement, ElementKind.SETTER); |
-// TopLevelVariableElement topVariableElement = _mockElement(TopLevelVariableElement, ElementKind.TOP_LEVEL_VARIABLE); |
-// when(topVariableElement.getter).thenReturn(getterElement); |
-// when(topVariableElement.setter).thenReturn(setterElement); |
-// { |
-// Location location = new Location(_elementA, 1, 10); |
-// _indexStore.recordRelationship(getterElement, IndexConstants.IS_REFERENCED_BY_UNQUALIFIED, location); |
-// } |
-// { |
-// Location location = new Location(_elementC, 2, 20); |
-// _indexStore.recordRelationship(setterElement, IndexConstants.IS_REFERENCED_BY_UNQUALIFIED, location); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, topVariableElement); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementA, MatchKind.FIELD_READ, 1, 10, false), |
-// new SearchEngineImplTest_ExpectedMatch.con2(_elementC, MatchKind.FIELD_WRITE, 2, 20, false)]); |
-// } |
-// |
-// void test_searchReferences_TypeAliasElement() { |
-// FunctionTypeAliasElement referencedElement = _mockElement(FunctionTypeAliasElement, ElementKind.FUNCTION_TYPE_ALIAS); |
-// { |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY, locationA); |
-// } |
-// { |
-// Location locationB = new Location(_elementB, 10, 20); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY, locationB); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.FUNCTION_TYPE_REFERENCE, 1, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.FUNCTION_TYPE_REFERENCE, 10, 20)]); |
-// } |
-// |
-// void test_searchReferences_TypeParameterElement() { |
-// TypeParameterElement referencedElement = _mockElement(TypeParameterElement, ElementKind.TYPE_PARAMETER); |
-// { |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY, locationA); |
-// } |
-// { |
-// Location locationB = new Location(_elementB, 10, 20); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY, locationB); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.TYPE_PARAMETER_REFERENCE, 1, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.TYPE_PARAMETER_REFERENCE, 10, 20)]); |
-// } |
-// |
-// void test_searchReferences_VariableElement() { |
-// LocalVariableElement referencedElement = _mockElement(LocalVariableElement, ElementKind.LOCAL_VARIABLE); |
-// { |
-// Location location = new Location(_elementA, 1, 10); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_READ_BY, location); |
-// } |
-// { |
-// Location location = new Location(_elementB, 2, 20); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_WRITTEN_BY, location); |
-// } |
-// { |
-// Location location = new Location(_elementC, 3, 30); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_READ_WRITTEN_BY, location); |
-// } |
-// { |
-// Location location = new Location(_elementD, 4, 40); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_INVOKED_BY, location); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync(Element, referencedElement); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.VARIABLE_READ, 1, 10), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.VARIABLE_WRITE, 2, 20), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementC, MatchKind.VARIABLE_READ_WRITE, 3, 30), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementD, MatchKind.FUNCTION_EXECUTION, 4, 40)]); |
-// } |
-// |
-// void test_searchSubtypes() { |
-// ClassElement referencedElement = _mockElement(ClassElement, ElementKind.CLASS); |
-// { |
-// Location locationA = new Location(_elementA, 10, 1); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_EXTENDED_BY, locationA); |
-// } |
-// { |
-// Location locationB = new Location(_elementB, 20, 2); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_MIXED_IN_BY, locationB); |
-// } |
-// { |
-// Location locationC = new Location(_elementC, 30, 3); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_IMPLEMENTED_BY, locationC); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _runSearch(new SearchRunner_SearchEngineImplTest_test_searchSubtypes(this, referencedElement)); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.EXTENDS_REFERENCE, 10, 1), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.WITH_REFERENCE, 20, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementC, MatchKind.IMPLEMENTS_REFERENCE, 30, 3)]); |
-// } |
-// |
-// void test_searchTypeDeclarations_async() { |
-// LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY); |
-// { |
-// when(_elementA.getAncestor((element) => element is LibraryElement)).thenReturn(library); |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(library, IndexConstants.DEFINES_CLASS, locationA); |
-// } |
-// _indexStore.doneIndex(); |
-// _scope = new LibrarySearchScope.con2([library]); |
-// // search matches |
-// List<SearchMatch> matches = _searchTypeDeclarationsAsync(); |
-// // verify |
-// _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.CLASS_DECLARATION, 1, 2)]); |
-// } |
-// |
-// void test_searchTypeDeclarations_class() { |
-// LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY); |
-// { |
-// when(_elementA.getAncestor((element) => element is LibraryElement)).thenReturn(library); |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(library, IndexConstants.DEFINES_CLASS, locationA); |
-// } |
-// _indexStore.doneIndex(); |
-// _scope = new LibrarySearchScope.con2([library]); |
-// // search matches |
-// List<SearchMatch> matches = _searchTypeDeclarationsSync(); |
-// // verify |
-// _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.CLASS_DECLARATION, 1, 2)]); |
-// } |
-// |
-// void test_searchTypeDeclarations_classAlias() { |
-// LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY); |
-// { |
-// when(_elementA.getAncestor((element) => element is LibraryElement)).thenReturn(library); |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(library, IndexConstants.DEFINES_CLASS_ALIAS, locationA); |
-// } |
-// _indexStore.doneIndex(); |
-// _scope = new LibrarySearchScope.con2([library]); |
-// // search matches |
-// List<SearchMatch> matches = _searchTypeDeclarationsSync(); |
-// // verify |
-// _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.CLASS_ALIAS_DECLARATION, 1, 2)]); |
-// } |
-// |
-// void test_searchTypeDeclarations_functionType() { |
-// LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY); |
-// { |
-// when(_elementA.getAncestor((element) => element is LibraryElement)).thenReturn(library); |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(library, IndexConstants.DEFINES_FUNCTION_TYPE, locationA); |
-// } |
-// _indexStore.doneIndex(); |
-// _scope = new LibrarySearchScope.con2([library]); |
-// // search matches |
-// List<SearchMatch> matches = _searchTypeDeclarationsSync(); |
-// // verify |
-// _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.FUNCTION_TYPE_DECLARATION, 1, 2)]); |
-// } |
-// |
-// void test_searchUnresolvedQualifiedReferences() { |
-// Element referencedElement = new NameElementImpl("test"); |
-// { |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY_QUALIFIED_RESOLVED, locationA); |
-// } |
-// { |
-// Location locationB = new Location(_elementB, 10, 20); |
-// _indexStore.recordRelationship(referencedElement, IndexConstants.IS_REFERENCED_BY_QUALIFIED_UNRESOLVED, locationB); |
-// } |
-// _indexStore.doneIndex(); |
-// // search matches |
-// List<SearchMatch> matches = _searchReferencesSync2("searchQualifiedMemberReferences", String, "test"); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.NAME_REFERENCE_RESOLVED, 1, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.NAME_REFERENCE_UNRESOLVED, 10, 20)]); |
-// } |
-// |
-// void test_searchVariableDeclarations() { |
-// LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY); |
-// _defineVariablesAB(library); |
-// _scope = new LibrarySearchScope.con2([library]); |
-// // search matches |
-// List<SearchMatch> matches = _searchVariableDeclarationsSync(); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.VARIABLE_DECLARATION, 1, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.VARIABLE_DECLARATION, 10, 20)]); |
-// } |
-// |
-// void test_searchVariableDeclarations_async() { |
-// LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY); |
-// _defineVariablesAB(library); |
-// _scope = new LibrarySearchScope.con2([library]); |
-// // search matches |
-// List<SearchMatch> matches = _searchVariableDeclarationsAsync(); |
-// // verify |
-// _assertMatches(matches, [ |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.VARIABLE_DECLARATION, 1, 2), |
-// new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.VARIABLE_DECLARATION, 10, 20)]); |
-// } |
-// |
-// void test_searchVariableDeclarations_usePattern() { |
-// LibraryElement library = _mockElement(LibraryElement, ElementKind.LIBRARY); |
-// _defineVariablesAB(library); |
-// _scope = new LibrarySearchScope.con2([library]); |
-// // search "A" |
-// { |
-// _pattern = SearchPatternFactory.createExactPattern("A", true); |
-// List<SearchMatch> matches = _searchVariableDeclarationsSync(); |
-// _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elementA, MatchKind.VARIABLE_DECLARATION, 1, 2)]); |
-// } |
-// // search "B" |
-// { |
-// _pattern = SearchPatternFactory.createExactPattern("B", true); |
-// List<SearchMatch> matches = _searchVariableDeclarationsSync(); |
-// _assertMatches(matches, [new SearchEngineImplTest_ExpectedMatch.con1(_elementB, MatchKind.VARIABLE_DECLARATION, 10, 20)]); |
-// } |
-// } |
-// |
-// @override |
-// void setUp() { |
-// super.setUp(); |
-// // library |
-// when(_unitElement.library).thenReturn(_libraryElement); |
-// when(_libraryElement.definingCompilationUnit).thenReturn(_unitElement); |
-// when(_unitElement.source).thenReturn(_source); |
-// when(_libraryElement.source).thenReturn(_source); |
-// when(_libraryElement.parts).thenReturn(new List<CompilationUnitElement>(0)); |
-// // elements |
-// when(_elementA.toString()).thenReturn("A"); |
-// when(_elementB.toString()).thenReturn("B"); |
-// when(_elementC.toString()).thenReturn("C"); |
-// when(_elementD.toString()).thenReturn("D"); |
-// when(_elementE.toString()).thenReturn("E"); |
-// when(_elementA.displayName).thenReturn("A"); |
-// when(_elementB.displayName).thenReturn("B"); |
-// when(_elementC.displayName).thenReturn("C"); |
-// when(_elementD.displayName).thenReturn("D"); |
-// when(_elementE.displayName).thenReturn("E"); |
-// when(_elementA.source).thenReturn(_source); |
-// when(_elementB.source).thenReturn(_source); |
-// when(_elementC.source).thenReturn(_source); |
-// when(_elementD.source).thenReturn(_source); |
-// when(_elementE.source).thenReturn(_source); |
-// when(_elementA.context).thenReturn(_CONTEXT); |
-// when(_elementB.context).thenReturn(_CONTEXT); |
-// when(_elementC.context).thenReturn(_CONTEXT); |
-// when(_elementD.context).thenReturn(_CONTEXT); |
-// when(_elementE.context).thenReturn(_CONTEXT); |
-// when(_CONTEXT.getElement(_elementA.location)).thenReturn(_elementA); |
-// when(_CONTEXT.getElement(_elementB.location)).thenReturn(_elementB); |
-// when(_CONTEXT.getElement(_elementC.location)).thenReturn(_elementC); |
-// when(_CONTEXT.getElement(_elementD.location)).thenReturn(_elementD); |
-// when(_CONTEXT.getElement(_elementE.location)).thenReturn(_elementE); |
-// // start indexing |
-// JUnitTestCase.assertTrue(_indexStore.aboutToIndexDart(_CONTEXT, _unitElement)); |
-// } |
-// |
-// void _defineFunctionsAB(LibraryElement library) { |
-// { |
-// when(_elementA.getAncestor((element) => element is LibraryElement)).thenReturn(library); |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(library, IndexConstants.DEFINES_FUNCTION, locationA); |
-// } |
-// { |
-// when(_elementB.getAncestor((element) => element is LibraryElement)).thenReturn(library); |
-// Location locationB = new Location(_elementB, 10, 20); |
-// _indexStore.recordRelationship(library, IndexConstants.DEFINES_FUNCTION, locationB); |
-// } |
-// _indexStore.doneIndex(); |
-// } |
-// |
-// void _defineVariablesAB(LibraryElement library) { |
-// { |
-// when(_elementA.getAncestor((element) => element is LibraryElement)).thenReturn(library); |
-// Location locationA = new Location(_elementA, 1, 2); |
-// _indexStore.recordRelationship(library, IndexConstants.DEFINES_VARIABLE, locationA); |
-// } |
-// { |
-// when(_elementB.getAncestor((element) => element is LibraryElement)).thenReturn(library); |
-// Location locationB = new Location(_elementB, 10, 20); |
-// _indexStore.recordRelationship(library, IndexConstants.DEFINES_VARIABLE, locationB); |
-// } |
-// _indexStore.doneIndex(); |
-// } |
-// |
-// Element _mockElement(Type clazz, ElementKind kind) { |
-// Element element = mock(clazz); |
-// when(element.context).thenReturn(_CONTEXT); |
-// when(element.source).thenReturn(_source); |
-// when(element.kind).thenReturn(kind); |
-// ElementLocation elementLocation = new ElementLocationImpl.con2("mockLocation${_nextLocationId++}"); |
-// when(element.location).thenReturn(elementLocation); |
-// when(_CONTEXT.getElement(element.location)).thenReturn(element); |
-// return element; |
-// } |
-// |
-// Object _runSearch(SearchEngineImplTest_SearchRunner runner) { |
-// OperationQueue queue = new OperationQueue(); |
-// OperationProcessor processor = new OperationProcessor(queue); |
-// Index index = new IndexImpl(_indexStore, queue, processor); |
-// SearchEngine engine = SearchEngineFactory.createSearchEngine(index); |
-// try { |
-// new Thread_SearchEngineImplTest_runSearch(processor).start(); |
-// processor.waitForRunning(); |
-// return runner.run(queue, processor, index, engine); |
-// } finally { |
-// processor.stop(false); |
-// } |
-// } |
-// |
-// List<SearchMatch> _searchDeclarationsAsync(String methodName) => _runSearch(new SearchRunner_SearchEngineImplTest_searchDeclarationsAsync(this, methodName, this, matches, latch)); |
-// |
-// List<SearchMatch> _searchDeclarationsSync(String methodName) => _runSearch(new SearchRunner_SearchEngineImplTest_searchDeclarationsSync(this, methodName)); |
-// |
-// List<SearchMatch> _searchFunctionDeclarationsAsync() => _searchDeclarationsAsync("searchFunctionDeclarations"); |
-// |
-// List<SearchMatch> _searchFunctionDeclarationsSync() => _searchDeclarationsSync("searchFunctionDeclarations"); |
-// |
-// List<SearchMatch> _searchReferencesSync(Type clazz, Object element) => _searchReferencesSync2("searchReferences", clazz, element); |
-// |
-// List<SearchMatch> _searchReferencesSync2(String methodName, Type clazz, Object element) => _runSearch(new SearchRunner_SearchEngineImplTest_searchReferencesSync(this, methodName, clazz, element)); |
-// |
-// List<SearchMatch> _searchTypeDeclarationsAsync() => _searchDeclarationsAsync("searchTypeDeclarations"); |
-// |
-// List<SearchMatch> _searchTypeDeclarationsSync() => _searchDeclarationsSync("searchTypeDeclarations"); |
-// |
-// List<SearchMatch> _searchVariableDeclarationsAsync() => _searchDeclarationsAsync("searchVariableDeclarations"); |
-// |
-// List<SearchMatch> _searchVariableDeclarationsSync() => _searchDeclarationsSync("searchVariableDeclarations"); |
-// |
-// static dartSuite() { |
-// _ut.group('SearchEngineImplTest', () { |
-// _ut.test('test_searchDeclarations_String', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchDeclarations_String); |
-// }); |
-// _ut.test('test_searchFunctionDeclarations', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchFunctionDeclarations); |
-// }); |
-// _ut.test('test_searchFunctionDeclarations_async', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchFunctionDeclarations_async); |
-// }); |
-// _ut.test('test_searchFunctionDeclarations_inUniverse', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchFunctionDeclarations_inUniverse); |
-// }); |
-// _ut.test('test_searchFunctionDeclarations_useFilter', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchFunctionDeclarations_useFilter); |
-// }); |
-// _ut.test('test_searchFunctionDeclarations_usePattern', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchFunctionDeclarations_usePattern); |
-// }); |
-// _ut.test('test_searchReferences_AngularComponentElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_AngularComponentElement); |
-// }); |
-// _ut.test('test_searchReferences_AngularControllerElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_AngularControllerElement); |
-// }); |
-// _ut.test('test_searchReferences_AngularFilterElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_AngularFilterElement); |
-// }); |
-// _ut.test('test_searchReferences_AngularPropertyElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_AngularPropertyElement); |
-// }); |
-// _ut.test('test_searchReferences_AngularScopePropertyElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_AngularScopePropertyElement); |
-// }); |
-// _ut.test('test_searchReferences_AngularSelectorElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_AngularSelectorElement); |
-// }); |
-// _ut.test('test_searchReferences_ClassElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_ClassElement); |
-// }); |
-// _ut.test('test_searchReferences_ClassElement_useScope', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_ClassElement_useScope); |
-// }); |
-// _ut.test('test_searchReferences_CompilationUnitElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_CompilationUnitElement); |
-// }); |
-// _ut.test('test_searchReferences_ConstructorElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_ConstructorElement); |
-// }); |
-// _ut.test('test_searchReferences_Element_unknown', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_Element_unknown); |
-// }); |
-// _ut.test('test_searchReferences_FieldElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_FieldElement); |
-// }); |
-// _ut.test('test_searchReferences_FieldElement2', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_FieldElement2); |
-// }); |
-// _ut.test('test_searchReferences_FieldElement_invocation', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_FieldElement_invocation); |
-// }); |
-// _ut.test('test_searchReferences_FunctionElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_FunctionElement); |
-// }); |
-// _ut.test('test_searchReferences_ImportElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_ImportElement); |
-// }); |
-// _ut.test('test_searchReferences_LibraryElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_LibraryElement); |
-// }); |
-// _ut.test('test_searchReferences_MethodElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_MethodElement); |
-// }); |
-// _ut.test('test_searchReferences_MethodMember', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_MethodMember); |
-// }); |
-// _ut.test('test_searchReferences_ParameterElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_ParameterElement); |
-// }); |
-// _ut.test('test_searchReferences_PropertyAccessorElement_getter', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_PropertyAccessorElement_getter); |
-// }); |
-// _ut.test('test_searchReferences_PropertyAccessorElement_setter', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_PropertyAccessorElement_setter); |
-// }); |
-// _ut.test('test_searchReferences_TopLevelVariableElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_TopLevelVariableElement); |
-// }); |
-// _ut.test('test_searchReferences_TypeAliasElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_TypeAliasElement); |
-// }); |
-// _ut.test('test_searchReferences_TypeParameterElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_TypeParameterElement); |
-// }); |
-// _ut.test('test_searchReferences_VariableElement', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_VariableElement); |
-// }); |
-// _ut.test('test_searchReferences_notSupported', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchReferences_notSupported); |
-// }); |
-// _ut.test('test_searchSubtypes', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchSubtypes); |
-// }); |
-// _ut.test('test_searchTypeDeclarations_async', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchTypeDeclarations_async); |
-// }); |
-// _ut.test('test_searchTypeDeclarations_class', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchTypeDeclarations_class); |
-// }); |
-// _ut.test('test_searchTypeDeclarations_classAlias', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchTypeDeclarations_classAlias); |
-// }); |
-// _ut.test('test_searchTypeDeclarations_functionType', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchTypeDeclarations_functionType); |
-// }); |
-// _ut.test('test_searchUnresolvedQualifiedReferences', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchUnresolvedQualifiedReferences); |
-// }); |
-// _ut.test('test_searchVariableDeclarations', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchVariableDeclarations); |
-// }); |
-// _ut.test('test_searchVariableDeclarations_async', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchVariableDeclarations_async); |
-// }); |
-// _ut.test('test_searchVariableDeclarations_usePattern', () { |
-// final __test = new SearchEngineImplTest(); |
-// runJUnitTest(__test, __test.test_searchVariableDeclarations_usePattern); |
-// }); |
-// }); |
-// } |
-//} |
-// |
-//class SearchEngineImplTest_ExpectedMatch { |
-// final Element _element; |
-// |
-// final MatchKind _kind; |
-// |
-// final MatchQuality _quality; |
-// |
-// SourceRange _range; |
-// |
-// final bool _qualified; |
-// |
-// SearchEngineImplTest_ExpectedMatch.con1(Element element, MatchKind kind, int offset, int length) : this.con3(element, kind, MatchQuality.EXACT, offset, length); |
-// |
-// SearchEngineImplTest_ExpectedMatch.con2(Element element, MatchKind kind, int offset, int length, bool qualified) : this.con4(element, kind, MatchQuality.EXACT, offset, length, qualified); |
-// |
-// SearchEngineImplTest_ExpectedMatch.con3(Element element, MatchKind kind, MatchQuality quality, int offset, int length) : this.con4(element, kind, quality, offset, length, false); |
-// |
-// SearchEngineImplTest_ExpectedMatch.con4(this._element, this._kind, this._quality, int offset, int length, this._qualified) { |
-// this._range = new SourceRange(offset, length); |
-// } |
-//} |
-// |
-//abstract class SearchEngineImplTest_SearchRunner<T> { |
-// T run(OperationQueue queue, OperationProcessor processor, Index index, SearchEngine engine); |
-//} |
-// |
-//class SearchFilter_SearchEngineImplTest_test_searchFunctionDeclarations_useFilter implements SearchFilter { |
-// final SearchEngineImplTest SearchEngineImplTest_this; |
-// |
-// SearchFilter_SearchEngineImplTest_test_searchFunctionDeclarations_useFilter(this.SearchEngineImplTest_this); |
-// |
-// @override |
-// bool passes(SearchMatch match) => identical(match.element, SearchEngineImplTest_this._elementB); |
-//} |
-// |
-//class SearchFilter_SearchEngineImplTest_test_searchFunctionDeclarations_useFilter_2 implements SearchFilter { |
-// final SearchEngineImplTest SearchEngineImplTest_this; |
-// |
-// SearchFilter_SearchEngineImplTest_test_searchFunctionDeclarations_useFilter_2(this.SearchEngineImplTest_this); |
-// |
-// @override |
-// bool passes(SearchMatch match) => identical(match.element, SearchEngineImplTest_this._elementA); |
-//} |
-// |
-//class SearchListener_SearchRunner_117_run implements SearchListener { |
-// List<SearchMatch> matches; |
-// |
-// CountDownLatch latch; |
-// |
-// SearchListener_SearchRunner_117_run(this.matches, this.latch); |
-// |
-// @override |
-// void matchFound(SearchMatch match) { |
-// matches.add(match); |
-// } |
-// |
-// @override |
-// void searchComplete() { |
-// latch.countDown(); |
-// } |
-//} |
-// |
-//class SearchRunner_SearchEngineImplTest_fail_searchAssignedTypes_assignments implements SearchEngineImplTest_SearchRunner { |
-// FieldElement fieldElement; |
-// |
-// SearchRunner_SearchEngineImplTest_fail_searchAssignedTypes_assignments(this.fieldElement, this.fieldElement); |
-// |
-// @override |
-// Set<DartType> run(OperationQueue queue, OperationProcessor processor, Index index, SearchEngine engine) => engine.searchAssignedTypes(fieldElement, new SearchScope_SearchRunner_109_run()); |
-//} |
-// |
-//class SearchRunner_SearchEngineImplTest_fail_searchAssignedTypes_initializers implements SearchEngineImplTest_SearchRunner { |
-// FieldElement fieldElement; |
-// |
-// SearchRunner_SearchEngineImplTest_fail_searchAssignedTypes_initializers(this.fieldElement); |
-// |
-// @override |
-// Set<DartType> run(OperationQueue queue, OperationProcessor processor, Index index, SearchEngine engine) => engine.searchAssignedTypes(fieldElement, null); |
-//} |
-// |
-//class SearchRunner_SearchEngineImplTest_searchDeclarationsAsync implements SearchEngineImplTest_SearchRunner { |
-// final SearchEngineImplTest SearchEngineImplTest_this; |
-// |
-// String methodName; |
-// |
-// final SearchEngineImplTest SearchEngineImplTest_this; |
-// |
-// List<SearchMatch> matches; |
-// |
-// CountDownLatch latch; |
-// |
-// SearchRunner_SearchEngineImplTest_searchDeclarationsAsync(this.SearchEngineImplTest_this, this.methodName, this.SearchEngineImplTest_this, this.matches, this.latch, this.SearchEngineImplTest_this, this.methodName, this.SearchEngineImplTest_this, this.matches, this.latch); |
-// |
-// @override |
-// List<SearchMatch> run(OperationQueue queue, OperationProcessor processor, Index index, SearchEngine engine) { |
-// CountDownLatch latch = new CountDownLatch(1); |
-// List<SearchMatch> matches = []; |
-// engine.runtimeType.getMethod(methodName, [SearchScope, SearchPattern, SearchFilter, SearchListener]).invoke(engine, [ |
-// SearchEngineImplTest_this._scope, |
-// SearchEngineImplTest_this._pattern, |
-// SearchEngineImplTest_this._filter, |
-// new SearchListener_SearchRunner_117_run(matches, latch)]); |
-// latch.await(30, TimeUnit.SECONDS); |
-// return matches; |
-// } |
-//} |
-// |
-//class SearchRunner_SearchEngineImplTest_searchDeclarationsSync implements SearchEngineImplTest_SearchRunner { |
-// final SearchEngineImplTest SearchEngineImplTest_this; |
-// |
-// String methodName; |
-// |
-// SearchRunner_SearchEngineImplTest_searchDeclarationsSync(this.SearchEngineImplTest_this, this.methodName); |
-// |
-// @override |
-// List<SearchMatch> run(OperationQueue queue, OperationProcessor processor, Index index, SearchEngine engine) => engine.runtimeType.getMethod(methodName, [SearchScope, SearchPattern, SearchFilter]).invoke(engine, [ |
-// SearchEngineImplTest_this._scope, |
-// SearchEngineImplTest_this._pattern, |
-// SearchEngineImplTest_this._filter]) as List<SearchMatch>; |
-//} |
-// |
-//class SearchRunner_SearchEngineImplTest_searchReferencesSync implements SearchEngineImplTest_SearchRunner { |
-// final SearchEngineImplTest SearchEngineImplTest_this; |
-// |
-// String methodName; |
-// |
-// Type clazz; |
-// |
-// Object element; |
-// |
-// SearchRunner_SearchEngineImplTest_searchReferencesSync(this.SearchEngineImplTest_this, this.methodName, this.clazz, this.element); |
-// |
-// @override |
-// List<SearchMatch> run(OperationQueue queue, OperationProcessor processor, Index index, SearchEngine engine) { |
-// // pass some operation to wait if search will not call processor |
-// queue.enqueue(mock(IndexOperation)); |
-// // run actual search |
-// return engine.runtimeType.getMethod(methodName, [clazz, SearchScope, SearchFilter]).invoke(engine, [ |
-// element, |
-// SearchEngineImplTest_this._scope, |
-// SearchEngineImplTest_this._filter]) as List<SearchMatch>; |
-// } |
-//} |
-// |
-//class SearchRunner_SearchEngineImplTest_test_searchDeclarations_String implements SearchEngineImplTest_SearchRunner { |
-// final SearchEngineImplTest SearchEngineImplTest_this; |
-// |
-// SearchRunner_SearchEngineImplTest_test_searchDeclarations_String(this.SearchEngineImplTest_this); |
-// |
-// @override |
-// List<SearchMatch> run(OperationQueue queue, OperationProcessor processor, Index index, SearchEngine engine) => engine.searchDeclarations("test", SearchEngineImplTest_this._scope, SearchEngineImplTest_this._filter); |
-//} |
-// |
-//class SearchRunner_SearchEngineImplTest_test_searchSubtypes implements SearchEngineImplTest_SearchRunner { |
-// final SearchEngineImplTest SearchEngineImplTest_this; |
-// |
-// ClassElement referencedElement; |
-// |
-// SearchRunner_SearchEngineImplTest_test_searchSubtypes(this.SearchEngineImplTest_this, this.referencedElement); |
-// |
-// @override |
-// List<SearchMatch> run(OperationQueue queue, OperationProcessor processor, Index index, SearchEngine engine) => engine.searchSubtypes(referencedElement, SearchEngineImplTest_this._scope, SearchEngineImplTest_this._filter); |
-//} |
-// |
-//class SearchScope_SearchRunner_109_run implements SearchScope { |
-// @override |
-// bool encloses(Element element) => !identical(element, _elementC); |
-//} |
-// |
-//class Thread_SearchEngineImplTest_runSearch extends Thread { |
-// OperationProcessor processor; |
-// |
-// Thread_SearchEngineImplTest_runSearch(this.processor) : super(); |
-// |
-// @override |
-// void run() { |
-// processor.run(); |
-// } |
-//} |
-// |
-//class UniverseSearchScopeTest extends EngineTestCase { |
-// SearchScope _scope = new UniverseSearchScope(); |
-// |
-// Element _element = mock(Element); |
-// |
-// void test_anyElement() { |
-// JUnitTestCase.assertTrue(_scope.encloses(_element)); |
-// } |
-// |
-// void test_nullElement() { |
-// JUnitTestCase.assertTrue(_scope.encloses(null)); |
-// } |
-// |
-// static dartSuite() { |
-// _ut.group('UniverseSearchScopeTest', () { |
-// _ut.test('test_anyElement', () { |
-// final __test = new UniverseSearchScopeTest(); |
-// runJUnitTest(__test, __test.test_anyElement); |
-// }); |
-// _ut.test('test_nullElement', () { |
-// final __test = new UniverseSearchScopeTest(); |
-// runJUnitTest(__test, __test.test_nullElement); |
-// }); |
-// }); |
-// } |
-//} |
-// |
-//class WildcardSearchPatternTest extends EngineTestCase { |
-// Element _element = mock(Element); |
-// |
-// void test_caseInsensitive_false_contentMismatch() { |
-// SearchPattern pattern = new WildcardSearchPattern("H*Map", false); |
-// when(_element.displayName).thenReturn("Maps"); |
-// // validate |
-// JUnitTestCase.assertSame(null, pattern.matches(_element)); |
-// } |
-// |
-// void test_caseInsensitive_true_caseMismatch() { |
-// SearchPattern pattern = new WildcardSearchPattern("H*MaP", false); |
-// when(_element.displayName).thenReturn("HashMap"); |
-// // validate |
-// JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element)); |
-// } |
-// |
-// void test_caseSensitive_false_caseMismatch() { |
-// SearchPattern pattern = new WildcardSearchPattern("H*MaP", true); |
-// when(_element.displayName).thenReturn("HashMap"); |
-// // validate |
-// JUnitTestCase.assertSame(null, pattern.matches(_element)); |
-// } |
-// |
-// void test_caseSensitive_false_contentMismatch() { |
-// SearchPattern pattern = new WildcardSearchPattern("H*Map", false); |
-// when(_element.displayName).thenReturn("Maps"); |
-// // validate |
-// JUnitTestCase.assertSame(null, pattern.matches(_element)); |
-// } |
-// |
-// void test_caseSensitive_true() { |
-// SearchPattern pattern = new WildcardSearchPattern("H*Ma?", false); |
-// when(_element.displayName).thenReturn("HashMap"); |
-// // validate |
-// JUnitTestCase.assertSame(MatchQuality.EXACT, pattern.matches(_element)); |
-// } |
-// |
-// void test_nullElement() { |
-// SearchPattern pattern = new WildcardSearchPattern("H*Map", false); |
-// // validate |
-// JUnitTestCase.assertSame(null, pattern.matches(null)); |
-// } |
-// |
-// void test_nullName() { |
-// SearchPattern pattern = new WildcardSearchPattern("H*Map", false); |
-// when(_element.displayName).thenReturn(null); |
-// // validate |
-// JUnitTestCase.assertSame(null, pattern.matches(_element)); |
+ ExpectedMatch(this.element, this.kind, int offset, int length, |
+ {this.isResolved: true, this.isQualified: false}) { |
+ this.range = new SourceRange(offset, length); |
+ } |
+ |
+ bool operator ==(SearchMatch match) { |
+ return match.element == this.element && |
+ match.kind == this.kind && |
+ match.isResolved == this.isResolved && |
+ match.isQualified == this.isQualified && |
+ match.sourceRange == this.range; |
+ } |
+ |
+ @override |
+ String toString() { |
+ StringBuffer buffer = new StringBuffer(); |
+ buffer.write("ExpectedMatch(kind="); |
+ buffer.write(kind); |
+ buffer.write(", element="); |
+ buffer.write(element != null ? element.displayName : 'null'); |
+ buffer.write(", range="); |
+ buffer.write(range); |
+ buffer.write(", isResolved="); |
+ buffer.write(isResolved); |
+ buffer.write(", isQualified="); |
+ buffer.write(isQualified); |
+ buffer.write(")"); |
+ return buffer.toString(); |
+ } |
+} |
+ |
+ |
+class MockAngularComponentElement extends TypedMock implements |
+ AngularComponentElement { |
+ final kind = ElementKind.ANGULAR_COMPONENT; |
+ noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
+} |
+ |
+ |
+class MockAngularControllerElement extends TypedMock implements |
+ AngularControllerElement { |
+ final kind = ElementKind.ANGULAR_CONTROLLER; |
+ noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
+} |
+ |
+ |
+class MockAngularFormatterElement extends TypedMock implements |
+ AngularFormatterElement { |
+ final kind = ElementKind.ANGULAR_FORMATTER; |
+ noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
+} |
+ |
+ |
+class MockIndex extends TypedMock implements Index { |
+ noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
+} |
+ |
+ |
+@ReflectiveTestCase() |
+class SearchEngineImplTest extends AbstractSingleUnitTest { |
+ Index index; |
+ SearchEngineImpl searchEngine; |
+ |
+// void mockLocation(Element element, Relationship relationship, |
+// Location location) { |
+// mockLocations(element, relationship, [location]); |
// } |
// |
-// static dartSuite() { |
-// _ut.group('WildcardSearchPatternTest', () { |
-// _ut.test('test_caseInsensitive_false_contentMismatch', () { |
-// final __test = new WildcardSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseInsensitive_false_contentMismatch); |
-// }); |
-// _ut.test('test_caseInsensitive_true_caseMismatch', () { |
-// final __test = new WildcardSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseInsensitive_true_caseMismatch); |
-// }); |
-// _ut.test('test_caseSensitive_false_caseMismatch', () { |
-// final __test = new WildcardSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseSensitive_false_caseMismatch); |
-// }); |
-// _ut.test('test_caseSensitive_false_contentMismatch', () { |
-// final __test = new WildcardSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseSensitive_false_contentMismatch); |
-// }); |
-// _ut.test('test_caseSensitive_true', () { |
-// final __test = new WildcardSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_caseSensitive_true); |
-// }); |
-// _ut.test('test_nullElement', () { |
-// final __test = new WildcardSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_nullElement); |
-// }); |
-// _ut.test('test_nullName', () { |
-// final __test = new WildcardSearchPatternTest(); |
-// runJUnitTest(__test, __test.test_nullName); |
-// }); |
-// }); |
+// void mockLocations(Element element, Relationship relationship, |
+// List<Location> locations) { |
+// index.getRelationships(element, relationship); |
+// when(null).thenReturn(new Future.value(locations)); |
// } |
-//} |
-// |
-//main() { |
-// CountingSearchListenerTest.dartSuite(); |
-// FilterSearchListenerTest.dartSuite(); |
-// GatheringSearchListenerTest.dartSuite(); |
-// NameMatchingSearchListenerTest.dartSuite(); |
-// LibrarySearchScopeTest.dartSuite(); |
-// UniverseSearchScopeTest.dartSuite(); |
-// SearchEngineImplTest.dartSuite(); |
-// AndSearchPatternTest.dartSuite(); |
-// CamelCaseSearchPatternTest.dartSuite(); |
-// ExactSearchPatternTest.dartSuite(); |
-// OrSearchPatternTest.dartSuite(); |
-// PrefixSearchPatternTest.dartSuite(); |
-// RegularExpressionSearchPatternTest.dartSuite(); |
-// WildcardSearchPatternTest.dartSuite(); |
-//} |
+ |
+ void setUp() { |
+ super.setUp(); |
+ index = createLocalMemoryIndex(); |
+ searchEngine = new SearchEngineImpl(index); |
+ } |
+ |
+ Future test_searchMemberDeclarations() { |
+ _indexTestUnit(''' |
+class A { |
+ test() {} |
+} |
+class B { |
+ int test = 42; |
+} |
+'''); |
+ NameElement element = new NameElement('test'); |
+ ClassElement elementA = findElement('A'); |
+ ClassElement elementB = findElement('B'); |
+ var expected = [ |
+ _expectId(elementA.methods[0], MatchKind.NAME_DECLARATION, 'test() {}'), |
+ _expectId(elementB.fields[0], MatchKind.NAME_DECLARATION, 'test = 42;')]; |
+ return searchEngine.searchMemberDeclarations('test').then((matches) { |
+ _assertMatches(matches, expected); |
+ }); |
+ } |
+ |
+ Future test_searchReferences_AngularComponentElement() { |
+ // use mocks |
+ index = new MockIndex(); |
+ searchEngine = new SearchEngineImpl(index); |
+ Element elementA = new MockElement('A'); |
+ Element elementB = new MockElement('B'); |
+ // fill mocks |
+ AngularComponentElement element = new MockAngularComponentElement(); |
+ void mockLocation(Element element, Relationship relationship, |
+ Location location) { |
+ index.getRelationships(element, relationship); |
+ when(null).thenReturn(new Future.value([location])); |
+ } |
+ mockLocation( |
+ element, |
+ IndexConstants.ANGULAR_REFERENCE, |
+ new Location(elementA, 1, 10)); |
+ mockLocation( |
+ element, |
+ IndexConstants.ANGULAR_CLOSING_TAG_REFERENCE, |
+ new Location(elementB, 2, 20)); |
+ var expected = [ |
+ new ExpectedMatch(elementA, MatchKind.ANGULAR_REFERENCE, 1, 10), |
+ new ExpectedMatch(elementB, MatchKind.ANGULAR_CLOSING_TAG_REFERENCE, 2, 20)]; |
+ return _verifyReferences(element, expected); |
+ } |
+ |
+ Future test_searchReferences_ClassElement() { |
+ _indexTestUnit(''' |
+class A {} |
+main(A p) { |
+ A v; |
+} |
+'''); |
+ ClassElement element = findElement('A'); |
+ Element pElement = findElement('p'); |
+ Element vElement = findElement('v'); |
+ var expected = [ |
+ _expectId(pElement, MatchKind.TYPE_REFERENCE, 'A p'), |
+ _expectId(vElement, MatchKind.TYPE_REFERENCE, 'A v')]; |
+ return _verifyReferences(element, expected); |
+ } |
+ |
+ Future test_searchReferences_CompilationUnitElement() { |
+ addSource('/my_part.dart', ''' |
+part of lib; |
+'''); |
+ _indexTestUnit(''' |
+library lib; |
+part 'my_part.dart'; |
+'''); |
+ CompilationUnitElement element = testLibraryElement.parts[0]; |
+ var expected = [ |
+ _expectId( |
+ testUnitElement, |
+ MatchKind.UNIT_REFERENCE, |
+ "'my_part.dart'", |
+ length: "'my_part.dart'".length)]; |
+ return _verifyReferences(element, expected); |
+ } |
+ |
+ Future test_searchReferences_ConstructorElement() { |
+ _indexTestUnit(''' |
+class A { |
+ A.named() {} |
+} |
+main() { |
+ new A.named(); |
+} |
+'''); |
+ ConstructorElement element = findElement('named'); |
+ ClassElement elementA = findElement('A'); |
+ Element mainElement = findElement('main'); |
+ var expected = [ |
+ _expectId( |
+ elementA, |
+ MatchKind.CONSTRUCTOR_DECLARATION, |
+ '.named() {}', |
+ length: 6), |
+ _expectId( |
+ mainElement, |
+ MatchKind.CONSTRUCTOR_REFERENCE, |
+ '.named();', |
+ length: 6)]; |
+ return _verifyReferences(element, expected); |
+ } |
+ |
+ Future test_searchReferences_Element_unknown() { |
+ return _verifyReferences(UniverseElement.INSTANCE, []); |
+ } |
+ |
+ Future test_searchReferences_FieldElement() { |
+ _indexTestUnit(''' |
+class A { |
+ var field; |
+ A({this.field}); |
+ main() { |
+ new A(field: 1); |
+ // getter |
+ print(field); // ref-nq |
+ print(this.field); // ref-q |
+ field(); // inv-nq |
+ this.field(); // inv-q |
+ // setter |
+ field = 2; // ref-nq; |
+ this.field = 3; // ref-q; |
+ } |
+} |
+'''); |
+ FieldElement element = findElement('field'); |
+ Element main = findElement('main'); |
+ Element fieldParameter = findElement('field', ElementKind.PARAMETER); |
+ var expected = [ |
+ _expectIdQ(fieldParameter, MatchKind.FIELD_REFERENCE, 'field}'), |
+ _expectIdQ(main, MatchKind.FIELD_REFERENCE, 'field: 1'), |
+ _expectId(main, MatchKind.FIELD_READ, 'field); // ref-nq'), |
+ _expectIdQ(main, MatchKind.FIELD_READ, 'field); // ref-q'), |
+ _expectId(main, MatchKind.FIELD_INVOCATION, 'field(); // inv-nq'), |
+ _expectIdQ(main, MatchKind.FIELD_INVOCATION, 'field(); // inv-q'), |
+ _expectId(main, MatchKind.FIELD_WRITE, 'field = 2; // ref-nq'), |
+ _expectIdQ(main, MatchKind.FIELD_WRITE, 'field = 3; // ref-q')]; |
+ return _verifyReferences(element, expected); |
+ } |
+ |
+ Future test_searchReferences_FunctionElement() { |
+ _indexTestUnit(''' |
+test() {} |
+main() { |
+ test(); |
+ print(test); |
+} |
+'''); |
+ FunctionElement element = findElement('test'); |
+ Element mainElement = findElement('main'); |
+ var expected = [ |
+ _expectId(mainElement, MatchKind.FUNCTION_EXECUTION, 'test();'), |
+ _expectId(mainElement, MatchKind.FUNCTION_REFERENCE, 'test);')]; |
+ return _verifyReferences(element, expected); |
+ } |
+ |
+ Future test_searchReferences_FunctionTypeAliasElement() { |
+ _indexTestUnit(''' |
+typedef Test(); |
+main() { |
+ Test a; |
+ Test b; |
+} |
+'''); |
+ FunctionTypeAliasElement element = findElement('Test'); |
+ Element aElement = findElement('a'); |
+ Element bElement = findElement('b'); |
+ var expected = [ |
+ _expectId(aElement, MatchKind.FUNCTION_TYPE_REFERENCE, 'Test a;'), |
+ _expectId(bElement, MatchKind.FUNCTION_TYPE_REFERENCE, 'Test b;')]; |
+ return _verifyReferences(element, expected); |
+ } |
+ |
+ Future test_searchReferences_ImportElement_noPrefix() { |
+ _indexTestUnit(''' |
+import 'dart:math'; |
+main() { |
+ print(E); |
+} |
+'''); |
+ ImportElement element = testLibraryElement.imports[0]; |
+ Element mainElement = findElement('main'); |
+ var kind = MatchKind.IMPORT_REFERENCE; |
+ var expected = [_expectId(mainElement, kind, 'E);', length: 0)]; |
+ return _verifyReferences(element, expected); |
+ } |
+ |
+ Future test_searchReferences_ImportElement_withPrefix() { |
+ _indexTestUnit(''' |
+import 'dart:math' as math; |
+main() { |
+ print(math.PI); |
+} |
+'''); |
+ ImportElement element = testLibraryElement.imports[0]; |
+ Element mainElement = findElement('main'); |
+ var kind = MatchKind.IMPORT_REFERENCE; |
+ var expected = [ |
+ _expectId(mainElement, kind, 'math.PI);', length: 'math.'.length)]; |
+ return _verifyReferences(element, expected); |
+ } |
+ |
+ Future test_searchReferences_LibraryElement() { |
+ var codeA = 'part of lib; // A'; |
+ var codeB = 'part of lib; // B'; |
+ var sourceA = addSource('/unitA.dart', codeA); |
+ var sourceB = addSource('/unitB.dart', codeB); |
+ _indexTestUnit(''' |
+library lib; |
+part 'unitA.dart'; |
+part 'unitB.dart'; |
+'''); |
+ LibraryElement element = testLibraryElement; |
+ CompilationUnitElement elementA = element.parts[0]; |
+ CompilationUnitElement elementB = element.parts[1]; |
+ index.indexUnit(context, elementA.node); |
+ index.indexUnit(context, elementB.node); |
+ Element mainElement = findElement('main'); |
+ var expected = [ |
+ new ExpectedMatch( |
+ elementA, |
+ MatchKind.LIBRARY_REFERENCE, |
+ codeA.indexOf('lib; // A'), |
+ 'lib'.length), |
+ new ExpectedMatch( |
+ elementB, |
+ MatchKind.LIBRARY_REFERENCE, |
+ codeB.indexOf('lib; // B'), |
+ 'lib'.length),]; |
+ return _verifyReferences(element, expected); |
+ } |
+ |
+ Future test_searchReferences_LocalVariableElement() { |
+ _indexTestUnit(''' |
+main() { |
+ var v; |
+ v = 1; |
+ v += 2; |
+ print(v); |
+ v(); |
+} |
+'''); |
+ LocalVariableElement element = findElement('v'); |
+ Element mainElement = findElement('main'); |
+ var expected = [ |
+ _expectId(mainElement, MatchKind.VARIABLE_WRITE, 'v = 1;'), |
+ _expectId(mainElement, MatchKind.VARIABLE_READ_WRITE, 'v += 2;'), |
+ _expectId(mainElement, MatchKind.VARIABLE_READ, 'v);'), |
+ _expectId(mainElement, MatchKind.FUNCTION_EXECUTION, 'v();')]; |
+ return _verifyReferences(element, expected); |
+ } |
+ |
+ Future test_searchReferences_MethodElement() { |
+ _indexTestUnit(''' |
+class A { |
+ m() {} |
+ main() { |
+ m(); // 1 |
+ this.m(); // 2 |
+ print(m); // 3 |
+ print(this.m); // 4 |
+ } |
+} |
+'''); |
+ MethodElement method = findElement('m'); |
+ Element mainElement = findElement('main'); |
+ var expected = [ |
+ _expectId(mainElement, MatchKind.METHOD_INVOCATION, 'm(); // 1'), |
+ _expectIdQ(mainElement, MatchKind.METHOD_INVOCATION, 'm(); // 2'), |
+ _expectId(mainElement, MatchKind.METHOD_REFERENCE, 'm); // 3'), |
+ _expectIdQ(mainElement, MatchKind.METHOD_REFERENCE, 'm); // 4')]; |
+ return _verifyReferences(method, expected); |
+ } |
+ |
+ Future test_searchReferences_MethodMember() { |
+ _indexTestUnit(''' |
+class A<T> { |
+ T m() => null; |
+} |
+main(A<int> a) { |
+ a.m(); // ref |
+} |
+'''); |
+ MethodMember method = findNodeElementAtString('m(); // ref'); |
+ Element mainElement = findElement('main'); |
+ var expected = [ |
+ _expectIdQ(mainElement, MatchKind.METHOD_INVOCATION, 'm(); // ref')]; |
+ return _verifyReferences(method, expected); |
+ } |
+ |
+ Future test_searchReferences_ParameterElement() { |
+ _indexTestUnit(''' |
+foo({p}) { |
+ p = 1; |
+ p += 2; |
+ print(p); |
+ p(); |
+} |
+main() { |
+ foo(p: 42); |
+} |
+'''); |
+ ParameterElement element = findElement('p'); |
+ Element fooElement = findElement('foo'); |
+ Element mainElement = findElement('main'); |
+ var expected = [ |
+ _expectId(fooElement, MatchKind.VARIABLE_WRITE, 'p = 1;'), |
+ _expectId(fooElement, MatchKind.VARIABLE_READ_WRITE, 'p += 2;'), |
+ _expectId(fooElement, MatchKind.VARIABLE_READ, 'p);'), |
+ _expectId(fooElement, MatchKind.FUNCTION_EXECUTION, 'p();'), |
+ _expectId(mainElement, MatchKind.NAMED_PARAMETER_REFERENCE, 'p: 42')]; |
+ return _verifyReferences(element, expected); |
+ } |
+ |
+ Future test_searchReferences_PropertyAccessorElement_getter() { |
+ _indexTestUnit(''' |
+class A { |
+ get g => null; |
+ main() { |
+ g; // 1 |
+ this.g; // 2 |
+ } |
+} |
+'''); |
+ PropertyAccessorElement element = findElement('g', ElementKind.GETTER); |
+ Element mainElement = findElement('main'); |
+ var expected = [ |
+ _expectId(mainElement, MatchKind.PROPERTY_ACCESSOR_REFERENCE, 'g; // 1'), |
+ _expectIdQ(mainElement, MatchKind.PROPERTY_ACCESSOR_REFERENCE, 'g; // 2')]; |
+ return _verifyReferences(element, expected); |
+ } |
+ |
+ Future test_searchReferences_PropertyAccessorElement_setter() { |
+ _indexTestUnit(''' |
+class A { |
+ set s(x) {} |
+ main() { |
+ s = 1; |
+ this.s = 2; |
+ } |
+} |
+'''); |
+ PropertyAccessorElement element = findElement('s='); |
+ Element mainElement = findElement('main'); |
+ var expected = [ |
+ _expectId(mainElement, MatchKind.PROPERTY_ACCESSOR_REFERENCE, 's = 1'), |
+ _expectIdQ(mainElement, MatchKind.PROPERTY_ACCESSOR_REFERENCE, 's = 2')]; |
+ return _verifyReferences(element, expected); |
+ } |
+ |
+ Future test_searchReferences_TopLevelVariableElement() { |
+ addSource('/lib.dart', ''' |
+library lib; |
+var V; |
+'''); |
+ _indexTestUnit(''' |
+import 'lib.dart' show V; // imp |
+import 'lib.dart' as pref; |
+main() { |
+ V = 1; |
+ print(V); |
+ V(); |
+} |
+mainQ() { |
+ pref.V = 1; // Q |
+ print(pref.V); // Q |
+ pref.V(); // Q |
+} |
+'''); |
+ ImportElement importElement = testLibraryElement.imports[0]; |
+ CompilationUnitElement impUnit = |
+ importElement.importedLibrary.definingCompilationUnit; |
+ TopLevelVariableElement variable = impUnit.topLevelVariables[0]; |
+ Element main = findElement('main'); |
+ Element mainQ = findElement('mainQ'); |
+ var expected = [ |
+ _expectIdQ(testUnitElement, MatchKind.FIELD_REFERENCE, 'V; // imp'), |
+ _expectId(main, MatchKind.FIELD_WRITE, 'V = 1;'), |
+ _expectId(main, MatchKind.FIELD_READ, 'V);'), |
+ _expectId(main, MatchKind.FIELD_INVOCATION, 'V();'), |
+ _expectIdQ(mainQ, MatchKind.FIELD_WRITE, 'V = 1; // Q'), |
+ _expectIdQ(mainQ, MatchKind.FIELD_READ, 'V); // Q'), |
+ _expectIdQ(mainQ, MatchKind.FIELD_INVOCATION, 'V(); // Q')]; |
+ return _verifyReferences(variable, expected); |
+ } |
+ |
+ Future test_searchReferences_TypeParameterElement() { |
+ _indexTestUnit(''' |
+class A<T> { |
+ main(T a, T b) {} |
+} |
+'''); |
+ TypeParameterElement element = findElement('T'); |
+ Element aElement = findElement('a'); |
+ Element bElement = findElement('b'); |
+ var expected = [ |
+ _expectId(aElement, MatchKind.TYPE_PARAMETER_REFERENCE, 'T a'), |
+ _expectId(bElement, MatchKind.TYPE_PARAMETER_REFERENCE, 'T b')]; |
+ return _verifyReferences(element, expected); |
+ } |
+ |
+ Future test_searchSubtypes() { |
+ _indexTestUnit(''' |
+class T {} |
+class A extends T {} // A |
+class B = Object with T; // B |
+class C implements T {} // C |
+'''); |
+ ClassElement element = findElement('T'); |
+ ClassElement elementA = findElement('A'); |
+ ClassElement elementB = findElement('B'); |
+ ClassElement elementC = findElement('C'); |
+ var expected = [ |
+ _expectId(elementA, MatchKind.EXTENDS_REFERENCE, 'T {} // A'), |
+ _expectId(elementB, MatchKind.WITH_REFERENCE, 'T; // B'), |
+ _expectId(elementC, MatchKind.IMPLEMENTS_REFERENCE, 'T {} // C')]; |
+ return searchEngine.searchSubtypes(element).then((matches) { |
+ _assertMatches(matches, expected); |
+ }); |
+ } |
+ |
+ Future test_searchMemberReferences() { |
+ _indexTestUnit(''' |
+class A { |
+ var test; // A |
+ mainA() { |
+ test(); // a-inv-r-nq |
+ test = 1; // a-write-r-nq |
+ test += 2; // a-read-write-r-nq |
+ print(test); // a-read-r-nq |
+ } |
+} |
+main(A a, p) { |
+ a.test(); // a-inv-r-q |
+ a.test = 1; // a-write-r-q |
+ a.test += 2; // a-read-write-r-q |
+ print(a.test); // a-read-r-q |
+ p.test(); // p-inv-ur-q |
+ p.test = 1; // p-write-ur-q |
+ p.test += 2; // p-read-write-ur-q |
+ print(p.test); // p-read-ur-q |
+} |
+'''); |
+ ClassElement elementA = findElement('A'); |
+ ClassElement elementB = findElement('B'); |
+ Element mainA = findElement('mainA'); |
+ Element main = findElement('main'); |
+ var expected = [ |
+ _expectId(mainA, MatchKind.NAME_INVOCATION_RESOLVED, 'test(); // a-inv-r-nq'), |
+ _expectId(mainA, MatchKind.NAME_WRITE_RESOLVED, 'test = 1; // a-write-r-nq'), |
+ _expectId(mainA, MatchKind.NAME_READ_WRITE_RESOLVED, 'test += 2; // a-read-write-r-nq'), |
+ _expectId(mainA, MatchKind.NAME_READ_RESOLVED, 'test); // a-read-r-nq'), |
+ _expectId(main, MatchKind.NAME_INVOCATION_RESOLVED, 'test(); // a-inv-r-q'), |
+ _expectId(main, MatchKind.NAME_WRITE_RESOLVED, 'test = 1; // a-write-r-q'), |
+ _expectId(main, MatchKind.NAME_READ_WRITE_RESOLVED, 'test += 2; // a-read-write-r-q'), |
+ _expectId(main, MatchKind.NAME_READ_RESOLVED, 'test); // a-read-r-q'), |
+ _expectIdU(main, MatchKind.NAME_INVOCATION_UNRESOLVED, 'test(); // p-inv-ur-q'), |
+ _expectIdU(main, MatchKind.NAME_WRITE_UNRESOLVED, 'test = 1; // p-write-ur-q'), |
+ _expectIdU(main, MatchKind.NAME_READ_WRITE_UNRESOLVED, 'test += 2; // p-read-write-ur-q'), |
+ _expectIdU(main, MatchKind.NAME_READ_UNRESOLVED, 'test); // p-read-ur-q'), |
+ ]; |
+ return searchEngine.searchMemberReferences('test').then((matches) { |
+ _assertMatches(matches, expected); |
+ }); |
+ } |
+ |
+ Future test_searchTopLevelDeclarations() { |
+ _indexTestUnit(''' |
+class A {} // A |
+class B = Object with A; |
+typedef C(); |
+D() {} |
+var E = null; |
+class NoMatchABCDE {} |
+'''); |
+ NameElement element = new NameElement('test'); |
+ Element topA = findElement('A'); |
+ Element topB = findElement('B'); |
+ Element topC = findElement('C'); |
+ Element topD = findElement('D'); |
+ Element topE = findElement('E'); |
+ Element topNoMatch = new MockElement('NoMatchABCDE'); |
+ var expected = [ |
+ _expectId(topA, MatchKind.CLASS_DECLARATION, 'A {} // A'), |
+ _expectId(topB, MatchKind.CLASS_ALIAS_DECLARATION, 'B ='), |
+ _expectId(topC, MatchKind.FUNCTION_TYPE_DECLARATION, 'C()'), |
+ _expectId(topD, MatchKind.FUNCTION_DECLARATION, 'D() {}'), |
+ _expectId(topE, MatchKind.VARIABLE_DECLARATION, 'E = null')]; |
+ return _verifyTopLevelDeclarations('^[A-E]\$', expected); |
+ } |
+ |
+ ExpectedMatch _expectId(Element element, MatchKind kind, String search, |
+ {int length, bool isResolved: true, bool isQualified: false}) { |
+ int offset = findOffset(search); |
+ if (length == null) { |
+ length = getLeadingIdentifierLength(search); |
+ } |
+ return new ExpectedMatch( |
+ element, |
+ kind, |
+ offset, |
+ length, |
+ isResolved: isResolved, |
+ isQualified: isQualified); |
+ } |
+ |
+ ExpectedMatch _expectIdQ(Element element, MatchKind kind, String search) { |
+ return _expectId(element, kind, search, isQualified: true); |
+ } |
+ |
+ ExpectedMatch _expectIdU(Element element, MatchKind kind, String search) { |
+ return _expectId(element, kind, search, isResolved: false); |
+ } |
+ |
+ void _indexTestUnit(String code) { |
+ resolveTestUnit(code); |
+ index.indexUnit(context, testUnit); |
+ } |
+ |
+ Future _verifyReferences(Element element, |
+ List<ExpectedMatch> expectedMatches) { |
+ return searchEngine.searchReferences( |
+ element).then((List<SearchMatch> matches) { |
+ _assertMatches(matches, expectedMatches); |
+ }); |
+ } |
+ |
+ Future _verifyTopLevelDeclarations(String pattern, |
+ List<ExpectedMatch> expectedMatches) { |
+ return searchEngine.searchTopLevelDeclarations( |
+ pattern).then((List<SearchMatch> matches) { |
+ _assertMatches(matches, expectedMatches); |
+ }); |
+ } |
+ |
+ static void _assertMatches(List<SearchMatch> matches, |
+ List<ExpectedMatch> expectedMatches) { |
+ expect(matches, unorderedEquals(expectedMatches)); |
+ } |
+} |