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 } | |
61 var params = | 52 var params = |
62 new protocol.SearchFindElementReferencesParams.fromRequest(request); | 53 new protocol.SearchFindElementReferencesParams.fromRequest(request); |
63 String file = params.file; | 54 String file = params.file; |
64 await server.onAnalysisComplete; | |
65 // prepare element | 55 // prepare element |
| 56 if (!server.options.enableNewAnalysisDriver) { |
| 57 await server.onAnalysisComplete; |
| 58 } |
66 Element element = await server.getElementAtOffset(file, params.offset); | 59 Element element = await server.getElementAtOffset(file, params.offset); |
67 if (element is ImportElement) { | 60 if (element is ImportElement) { |
68 element = (element as ImportElement).prefix; | 61 element = (element as ImportElement).prefix; |
69 } | 62 } |
70 if (element is FieldFormalParameterElement) { | 63 if (element is FieldFormalParameterElement) { |
71 element = (element as FieldFormalParameterElement).field; | 64 element = (element as FieldFormalParameterElement).field; |
72 } | 65 } |
73 if (element is PropertyAccessorElement) { | 66 if (element is PropertyAccessorElement) { |
74 element = (element as PropertyAccessorElement).variable; | 67 element = (element as PropertyAccessorElement).variable; |
75 } | 68 } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 void _sendTypeHierarchyNull(protocol.Request request) { | 229 void _sendTypeHierarchyNull(protocol.Request request) { |
237 protocol.Response response = | 230 protocol.Response response = |
238 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); | 231 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); |
239 server.sendResponse(response); | 232 server.sendResponse(response); |
240 } | 233 } |
241 | 234 |
242 static protocol.SearchResult toResult(SearchMatch match) { | 235 static protocol.SearchResult toResult(SearchMatch match) { |
243 return protocol.newSearchResult_fromMatch(match); | 236 return protocol.newSearchResult_fromMatch(match); |
244 } | 237 } |
245 } | 238 } |
OLD | NEW |