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

Unified Diff: pkg/analysis_server/lib/src/search/search_domain.dart

Issue 396883002: Implementation for the 'search.findMemberReferences' API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/search/search_domain.dart
diff --git a/pkg/analysis_server/lib/src/search/search_domain.dart b/pkg/analysis_server/lib/src/search/search_domain.dart
index ec9124290e55695b028f09367f186648987511ae..3aa57f0e63b98a45553cc114fa9a47c1b2d9de97 100644
--- a/pkg/analysis_server/lib/src/search/search_domain.dart
+++ b/pkg/analysis_server/lib/src/search/search_domain.dart
@@ -14,7 +14,6 @@ import 'package:analysis_server/src/constants.dart';
import 'package:analysis_server/src/protocol.dart';
import 'package:analysis_services/search/search_engine.dart';
import 'package:analyzer/src/generated/element.dart';
-import 'package:analysis_server/src/search/top_level_declarations.dart';
/**
* Instances of the class [SearchDomainHandler] implement a [RequestHandler]
@@ -93,24 +92,29 @@ class SearchDomainHandler implements RequestHandler {
}
Response findMemberReferences(Request request) {
- // name
- RequestDatum nameDatum = request.getRequiredParameter(FILE);
- String name = nameDatum.asString();
- // TODO(brianwilkerson) implement
- return null;
+ String name = request.getRequiredParameter(NAME).asString();
+ // schedule search
+ String searchId = (_nextSearchId++).toString();
+ {
+ var matchesFuture = searchEngine.searchMemberReferences(name);
+ matchesFuture.then((List<SearchMatch> matches) {
+ _sendSearchNotification(searchId, true, matches.map(toResult));
+ });
+ }
+ // respond
+ return new Response(request.id)..setResult(ID, searchId);
}
Response findTopLevelDeclarations(Request request) {
String pattern = request.getRequiredParameter(PATTERN).asString();
// schedule search
String searchId = (_nextSearchId++).toString();
- new Future.microtask(() {
- var computer = new TopLevelDeclarationsComputer(searchEngine);
- var future = computer.compute(pattern);
- future.then((List<SearchResult> results) {
- _sendSearchNotification(searchId, true, results);
+ {
+ var matchesFuture = searchEngine.searchTopLevelDeclarations(pattern);
+ matchesFuture.then((List<SearchMatch> matches) {
+ _sendSearchNotification(searchId, true, matches.map(toResult));
});
- });
+ }
// respond
return new Response(request.id)..setResult(ID, searchId);
}
@@ -135,11 +139,15 @@ class SearchDomainHandler implements RequestHandler {
}
void _sendSearchNotification(String searchId, bool isLast,
- List<SearchResult> results) {
+ Iterable<SearchResult> results) {
Notification notification = new Notification(SEARCH_RESULTS);
notification.setParameter(ID, searchId);
notification.setParameter(LAST, isLast);
notification.setParameter(RESULTS, results);
server.sendNotification(notification);
}
+
+ static SearchResult toResult(SearchMatch match) {
+ return new SearchResult.fromMatch(match);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698