OLD | NEW |
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/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 /** | 43 /** |
44 * Initialize a newly created handler to handle requests for the given [server
]. | 44 * Initialize a newly created handler to handle requests for the given [server
]. |
45 */ | 45 */ |
46 SearchDomainHandler(AnalysisServer server) | 46 SearchDomainHandler(AnalysisServer server) |
47 : server = server, | 47 : server = server, |
48 index = server.index, | 48 index = server.index, |
49 searchEngine = server.searchEngine; | 49 searchEngine = server.searchEngine; |
50 | 50 |
51 Future findElementReferences(protocol.Request request) async { | 51 Future findElementReferences(protocol.Request request) async { |
| 52 if (server.options.enableNewAnalysisDriver) { |
| 53 // TODO(scheglov) implement for the new analysis driver |
| 54 String searchId = (_nextSearchId++).toString(); |
| 55 var result = new protocol.SearchFindElementReferencesResult(); |
| 56 result.id = searchId; |
| 57 _sendSearchResult(request, result); |
| 58 _sendSearchNotification(searchId, true, <protocol.SearchResult>[]); |
| 59 return; |
| 60 } |
52 var params = | 61 var params = |
53 new protocol.SearchFindElementReferencesParams.fromRequest(request); | 62 new protocol.SearchFindElementReferencesParams.fromRequest(request); |
54 await server.onAnalysisComplete; | 63 await server.onAnalysisComplete; |
55 // prepare elements | 64 // prepare elements |
56 List<Element> elements = | 65 List<Element> elements = |
57 server.getElementsAtOffset(params.file, params.offset); | 66 server.getElementsAtOffset(params.file, params.offset); |
58 elements = elements.map((Element element) { | 67 elements = elements.map((Element element) { |
59 if (element is ImportElement) { | 68 if (element is ImportElement) { |
60 return element.prefix; | 69 return element.prefix; |
61 } | 70 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 List<SearchMatch> matches = | 147 List<SearchMatch> matches = |
139 await searchEngine.searchTopLevelDeclarations(params.pattern); | 148 await searchEngine.searchTopLevelDeclarations(params.pattern); |
140 matches = SearchMatch.withNotNullElement(matches); | 149 matches = SearchMatch.withNotNullElement(matches); |
141 _sendSearchNotification(searchId, true, matches.map(toResult)); | 150 _sendSearchNotification(searchId, true, matches.map(toResult)); |
142 } | 151 } |
143 | 152 |
144 /** | 153 /** |
145 * Implement the `search.getTypeHierarchy` request. | 154 * Implement the `search.getTypeHierarchy` request. |
146 */ | 155 */ |
147 Future getTypeHierarchy(protocol.Request request) async { | 156 Future getTypeHierarchy(protocol.Request request) async { |
| 157 if (server.options.enableNewAnalysisDriver) { |
| 158 // TODO(scheglov) implement for the new analysis driver |
| 159 protocol.Response response = |
| 160 new protocol.SearchGetTypeHierarchyResult(hierarchyItems: []) |
| 161 .toResponse(request.id); |
| 162 server.sendResponse(response); |
| 163 return; |
| 164 } |
148 var params = new protocol.SearchGetTypeHierarchyParams.fromRequest(request); | 165 var params = new protocol.SearchGetTypeHierarchyParams.fromRequest(request); |
149 String file = params.file; | 166 String file = params.file; |
150 // wait for analysis | 167 // wait for analysis |
151 if (params.superOnly == true) { | 168 if (params.superOnly == true) { |
152 await server.onFileAnalysisComplete(file); | 169 await server.onFileAnalysisComplete(file); |
153 } else { | 170 } else { |
154 await server.onAnalysisComplete; | 171 await server.onAnalysisComplete; |
155 } | 172 } |
156 // prepare element | 173 // prepare element |
157 List<Element> elements = server.getElementsAtOffset(file, params.offset); | 174 List<Element> elements = server.getElementsAtOffset(file, params.offset); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 void _sendTypeHierarchyNull(protocol.Request request) { | 245 void _sendTypeHierarchyNull(protocol.Request request) { |
229 protocol.Response response = | 246 protocol.Response response = |
230 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); | 247 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); |
231 server.sendResponse(response); | 248 server.sendResponse(response); |
232 } | 249 } |
233 | 250 |
234 static protocol.SearchResult toResult(SearchMatch match) { | 251 static protocol.SearchResult toResult(SearchMatch match) { |
235 return protocol.newSearchResult_fromMatch(match); | 252 return protocol.newSearchResult_fromMatch(match); |
236 } | 253 } |
237 } | 254 } |
OLD | NEW |