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

Unified Diff: pkg/analysis_server/test/services/search/search_engine2_test.dart

Issue 1770953002: Implement searchMemberDeclarations() / searchTopLevelDeclarations(). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/test/services/index2/index2_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/services/search/search_engine2_test.dart
diff --git a/pkg/analysis_server/test/services/search/search_engine2_test.dart b/pkg/analysis_server/test/services/search/search_engine2_test.dart
index 230c0d7d51aff09c47c11bff12182830817c079e..3fdf6718fbdf73e0c766f48f148b6a594042cc7f 100644
--- a/pkg/analysis_server/test/services/search/search_engine2_test.dart
+++ b/pkg/analysis_server/test/services/search/search_engine2_test.dart
@@ -93,30 +93,30 @@ class SearchEngineImpl2Test extends AbstractSingleUnitTest {
// _assertMatches(matches, expected);
// });
// }
-//
-// Future test_searchMemberDeclarations() {
-// _indexTestUnit('''
-//class A {
-// test() {}
-//}
-//class B {
-// int test = 1;
-// main() {
-// int test = 2;
-// }
-//}
-//''');
-// ClassElement elementA = findElement('A');
-// ClassElement elementB = findElement('B');
-// var expected = [
-// _expectId(elementA.methods[0], MatchKind.DECLARATION, 'test() {}'),
-// _expectId(elementB.fields[0], MatchKind.DECLARATION, 'test = 1;')
-// ];
-// return searchEngine.searchMemberDeclarations('test').then((matches) {
-// _assertMatches(matches, expected);
-// });
-// }
-//
+
+ test_searchMemberDeclarations() async {
+ _indexTestUnit('''
+class A {
+ test() {}
+}
+class B {
+ int test = 1;
+ main() {
+ int test = 2;
+ }
+}
+''');
+ ClassElement elementA = findElement('A');
+ ClassElement elementB = findElement('B');
+ var expected = [
+ _expectId(elementA.methods[0], MatchKind.DECLARATION, 'test() {}'),
+ _expectId(elementB.fields[0], MatchKind.DECLARATION, 'test = 1;')
+ ];
+ List<SearchMatch> matches =
+ await searchEngine.searchMemberDeclarations('test');
+ _assertMatches(matches, expected);
+ }
+
// Future test_searchMemberReferences() {
// _indexTestUnit('''
//class A {
@@ -660,30 +660,32 @@ class A<T> {
// _assertMatches(matches, expected);
// });
// }
-//
-// Future test_searchTopLevelDeclarations() {
-// _indexTestUnit('''
-//class A {} // A
-//class B = Object with A;
-//typedef C();
-//D() {}
-//var E = null;
-//class NoMatchABCDE {}
-//''');
-// Element topA = findElement('A');
-// Element topB = findElement('B');
-// Element topC = findElement('C');
-// Element topD = findElement('D');
-// Element topE = findElement('E');
-// var expected = [
-// _expectId(topA, MatchKind.DECLARATION, 'A {} // A'),
-// _expectId(topB, MatchKind.DECLARATION, 'B ='),
-// _expectId(topC, MatchKind.DECLARATION, 'C()'),
-// _expectId(topD, MatchKind.DECLARATION, 'D() {}'),
-// _expectId(topE, MatchKind.DECLARATION, 'E = null')
-// ];
-// return _verifyTopLevelDeclarations('^[A-E]\$', expected);
-// }
+
+ test_searchTopLevelDeclarations() async {
+ _indexTestUnit('''
+class A {} // A
+class B = Object with A;
+typedef C();
+D() {}
+var E = null;
+class NoMatchABCDE {}
+''');
+ Element topA = findElement('A');
+ Element topB = findElement('B');
+ Element topC = findElement('C');
+ Element topD = findElement('D');
+ Element topE = findElement('E');
+ var expected = [
+ _expectId(topA, MatchKind.DECLARATION, 'A {} // A'),
+ _expectId(topB, MatchKind.DECLARATION, 'B ='),
+ _expectId(topC, MatchKind.DECLARATION, 'C()'),
+ _expectId(topD, MatchKind.DECLARATION, 'D() {}'),
+ _expectId(topE, MatchKind.DECLARATION, 'E = null')
+ ];
+ List<SearchMatch> matches =
+ await searchEngine.searchTopLevelDeclarations(r'^[A-E]$');
+ _assertMatches(matches, expected);
+ }
ExpectedMatch _expectId(Element element, MatchKind kind, String search,
{int length, bool isResolved: true, bool isQualified: false}) {
@@ -716,15 +718,6 @@ class A<T> {
_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));
« no previous file with comments | « pkg/analysis_server/test/services/index2/index2_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698