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

Side by Side Diff: pkg/analysis_server/lib/src/search/search_domain.dart

Issue 399483002: Implementation for 'search.findTopLevelDeclarations' 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/search/top_level_declarations.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library search.domain; 5 library search.domain;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/search/element_references.dart'; 10 import 'package:analysis_server/src/search/element_references.dart';
11 import 'package:analysis_server/src/search/search_result.dart'; 11 import 'package:analysis_server/src/search/search_result.dart';
12 import 'package:analysis_server/src/constants.dart'; 12 import 'package:analysis_server/src/constants.dart';
13 import 'package:analysis_server/src/protocol.dart'; 13 import 'package:analysis_server/src/protocol.dart';
14 import 'package:analysis_services/search/search_engine.dart'; 14 import 'package:analysis_services/search/search_engine.dart';
15 import 'package:analyzer/src/generated/element.dart'; 15 import 'package:analyzer/src/generated/element.dart';
16 import 'package:analysis_server/src/search/top_level_declarations.dart';
16 17
17 /** 18 /**
18 * Instances of the class [SearchDomainHandler] implement a [RequestHandler] 19 * Instances of the class [SearchDomainHandler] implement a [RequestHandler]
19 * that handles requests in the search domain. 20 * that handles requests in the search domain.
20 */ 21 */
21 class SearchDomainHandler implements RequestHandler { 22 class SearchDomainHandler implements RequestHandler {
22 /** 23 /**
23 * The analysis server that is using this handler to process requests. 24 * The analysis server that is using this handler to process requests.
24 */ 25 */
25 final AnalysisServer server; 26 final AnalysisServer server;
(...skipping 19 matching lines...) Expand all
45 String file = request.getRequiredParameter(FILE).asString(); 46 String file = request.getRequiredParameter(FILE).asString();
46 int offset = request.getRequiredParameter(OFFSET).asInt(); 47 int offset = request.getRequiredParameter(OFFSET).asInt();
47 bool includePotential = 48 bool includePotential =
48 request.getRequiredParameter(INCLUDE_POTENTIAL).asBool(); 49 request.getRequiredParameter(INCLUDE_POTENTIAL).asBool();
49 // schedule search 50 // schedule search
50 String searchId = (_nextSearchId++).toString(); 51 String searchId = (_nextSearchId++).toString();
51 List<Element> elements = server.getElementsAtOffset(file, offset); 52 List<Element> elements = server.getElementsAtOffset(file, offset);
52 elements.forEach((Element element) { 53 elements.forEach((Element element) {
53 var computer = new ElementReferencesComputer(searchEngine); 54 var computer = new ElementReferencesComputer(searchEngine);
54 var future = computer.compute(element, includePotential); 55 var future = computer.compute(element, includePotential);
55 return future.then((List<SearchResult> results) { 56 future.then((List<SearchResult> results) {
56 bool isLast = identical(element, elements.last); 57 bool isLast = identical(element, elements.last);
57 _sendSearchNotification(searchId, isLast, results); 58 _sendSearchNotification(searchId, isLast, results);
58 }); 59 });
59 }); 60 });
60 if (elements.isEmpty) { 61 if (elements.isEmpty) {
61 new Future.microtask(() { 62 new Future.microtask(() {
62 _sendSearchNotification(searchId, true, []); 63 _sendSearchNotification(searchId, true, []);
63 }); 64 });
64 } 65 }
65 // respond 66 // respond
(...skipping 10 matching lines...) Expand all
76 77
77 Response findMemberReferences(Request request) { 78 Response findMemberReferences(Request request) {
78 // name 79 // name
79 RequestDatum nameDatum = request.getRequiredParameter(FILE); 80 RequestDatum nameDatum = request.getRequiredParameter(FILE);
80 String name = nameDatum.asString(); 81 String name = nameDatum.asString();
81 // TODO(brianwilkerson) implement 82 // TODO(brianwilkerson) implement
82 return null; 83 return null;
83 } 84 }
84 85
85 Response findTopLevelDeclarations(Request request) { 86 Response findTopLevelDeclarations(Request request) {
86 // pattern 87 String pattern = request.getRequiredParameter(PATTERN).asString();
87 RequestDatum patternDatum = request.getRequiredParameter(FILE); 88 // schedule search
88 String pattern = patternDatum.asString(); 89 String searchId = (_nextSearchId++).toString();
89 // TODO(brianwilkerson) implement 90 new Future.microtask(() {
90 return null; 91 var computer = new TopLevelDeclarationsComputer(searchEngine);
92 var future = computer.compute(pattern);
93 future.then((List<SearchResult> results) {
94 _sendSearchNotification(searchId, true, results);
95 });
96 });
97 // respond
98 return new Response(request.id)..setResult(ID, searchId);
91 } 99 }
92 100
93 @override 101 @override
94 Response handleRequest(Request request) { 102 Response handleRequest(Request request) {
95 try { 103 try {
96 String requestName = request.method; 104 String requestName = request.method;
97 if (requestName == SEARCH_FIND_ELEMENT_REFERENCES) { 105 if (requestName == SEARCH_FIND_ELEMENT_REFERENCES) {
98 return findElementReferences(request); 106 return findElementReferences(request);
99 } else if (requestName == SEARCH_FIND_MEMBER_DECLARATIONS) { 107 } else if (requestName == SEARCH_FIND_MEMBER_DECLARATIONS) {
100 return findMemberDeclarations(request); 108 return findMemberDeclarations(request);
(...skipping 10 matching lines...) Expand all
111 119
112 void _sendSearchNotification(String searchId, bool isLast, 120 void _sendSearchNotification(String searchId, bool isLast,
113 List<SearchResult> results) { 121 List<SearchResult> results) {
114 Notification notification = new Notification(SEARCH_RESULTS); 122 Notification notification = new Notification(SEARCH_RESULTS);
115 notification.setParameter(ID, searchId); 123 notification.setParameter(ID, searchId);
116 notification.setParameter(LAST, isLast); 124 notification.setParameter(LAST, isLast);
117 notification.setParameter(RESULTS, results); 125 notification.setParameter(RESULTS, results);
118 server.sendNotification(notification); 126 server.sendNotification(notification);
119 } 127 }
120 } 128 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/search/top_level_declarations.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698