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'; |
11 import 'package:analysis_server/src/protocol_server.dart' as protocol; | 11 import 'package:analysis_server/src/protocol_server.dart' as protocol; |
12 import 'package:analysis_server/src/provisional/index/index_core.dart'; | 12 import 'package:analysis_server/src/provisional/index/index_core.dart'; |
13 import 'package:analysis_server/src/search/element_references.dart'; | 13 import 'package:analysis_server/src/search/element_references.dart'; |
14 import 'package:analysis_server/src/search/type_hierarchy.dart'; | 14 import 'package:analysis_server/src/search/type_hierarchy.dart'; |
15 import 'package:analysis_server/src/services/index/index.dart'; | 15 import 'package:analysis_server/src/services/index/index.dart'; |
16 import 'package:analysis_server/src/services/index/indexable_file.dart'; | 16 import 'package:analysis_server/src/services/index/indexable_file.dart'; |
17 import 'package:analysis_server/src/services/search/search_engine.dart'; | 17 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 18 import 'package:analyzer/dart/element/element.dart'; |
18 import 'package:analyzer/src/generated/ast.dart'; | 19 import 'package:analyzer/src/generated/ast.dart'; |
19 import 'package:analyzer/src/generated/element.dart'; | |
20 | 20 |
21 /** | 21 /** |
22 * Instances of the class [SearchDomainHandler] implement a [RequestHandler] | 22 * Instances of the class [SearchDomainHandler] implement a [RequestHandler] |
23 * that handles requests in the search domain. | 23 * that handles requests in the search domain. |
24 */ | 24 */ |
25 class SearchDomainHandler implements protocol.RequestHandler { | 25 class SearchDomainHandler implements protocol.RequestHandler { |
26 /** | 26 /** |
27 * The analysis server that is using this handler to process requests. | 27 * The analysis server that is using this handler to process requests. |
28 */ | 28 */ |
29 final AnalysisServer server; | 29 final AnalysisServer server; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 if (elements.isEmpty) { | 171 if (elements.isEmpty) { |
172 _sendTypeHierarchyNull(request); | 172 _sendTypeHierarchyNull(request); |
173 return; | 173 return; |
174 } | 174 } |
175 Element element = elements.first; | 175 Element element = elements.first; |
176 // maybe supertype hierarchy only | 176 // maybe supertype hierarchy only |
177 if (params.superOnly == true) { | 177 if (params.superOnly == true) { |
178 TypeHierarchyComputer computer = | 178 TypeHierarchyComputer computer = |
179 new TypeHierarchyComputer(searchEngine, element); | 179 new TypeHierarchyComputer(searchEngine, element); |
180 List<protocol.TypeHierarchyItem> items = computer.computeSuper(); | 180 List<protocol.TypeHierarchyItem> items = computer.computeSuper(); |
181 protocol.Response response = new protocol.SearchGetTypeHierarchyResult( | 181 protocol.Response response = |
182 hierarchyItems: items).toResponse(request.id); | 182 new protocol.SearchGetTypeHierarchyResult(hierarchyItems: items) |
| 183 .toResponse(request.id); |
183 server.sendResponse(response); | 184 server.sendResponse(response); |
184 return; | 185 return; |
185 } | 186 } |
186 // prepare type hierarchy | 187 // prepare type hierarchy |
187 TypeHierarchyComputer computer = | 188 TypeHierarchyComputer computer = |
188 new TypeHierarchyComputer(searchEngine, element); | 189 new TypeHierarchyComputer(searchEngine, element); |
189 List<protocol.TypeHierarchyItem> items = await computer.compute(); | 190 List<protocol.TypeHierarchyItem> items = await computer.compute(); |
190 protocol.Response response = new protocol.SearchGetTypeHierarchyResult( | 191 protocol.Response response = |
191 hierarchyItems: items).toResponse(request.id); | 192 new protocol.SearchGetTypeHierarchyResult(hierarchyItems: items) |
| 193 .toResponse(request.id); |
192 server.sendResponse(response); | 194 server.sendResponse(response); |
193 } | 195 } |
194 | 196 |
195 @override | 197 @override |
196 protocol.Response handleRequest(protocol.Request request) { | 198 protocol.Response handleRequest(protocol.Request request) { |
197 if (searchEngine == null) { | 199 if (searchEngine == null) { |
198 return new protocol.Response.noIndexGenerated(request); | 200 return new protocol.Response.noIndexGenerated(request); |
199 } | 201 } |
200 try { | 202 try { |
201 String requestName = request.method; | 203 String requestName = request.method; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 void _sendTypeHierarchyNull(protocol.Request request) { | 266 void _sendTypeHierarchyNull(protocol.Request request) { |
265 protocol.Response response = | 267 protocol.Response response = |
266 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); | 268 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); |
267 server.sendResponse(response); | 269 server.sendResponse(response); |
268 } | 270 } |
269 | 271 |
270 static protocol.SearchResult toResult(SearchMatch match) { | 272 static protocol.SearchResult toResult(SearchMatch match) { |
271 return protocol.newSearchResult_fromMatch(match); | 273 return protocol.newSearchResult_fromMatch(match); |
272 } | 274 } |
273 } | 275 } |
OLD | NEW |