| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/analysis_server.dart'; | 7 import 'package:analysis_server/src/analysis_server.dart'; |
| 8 import 'package:analysis_server/src/constants.dart'; | 8 import 'package:analysis_server/src/constants.dart'; |
| 9 import 'package:analysis_server/src/protocol_server.dart' as protocol; | 9 import 'package:analysis_server/src/protocol_server.dart' as protocol; |
| 10 import 'package:analysis_server/src/search/element_references.dart'; | 10 import 'package:analysis_server/src/search/element_references.dart'; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 SearchDomainHandler(AnalysisServer server) | 44 SearchDomainHandler(AnalysisServer server) |
| 45 : server = server, | 45 : server = server, |
| 46 index = server.index, | 46 index = server.index, |
| 47 searchEngine = server.searchEngine; | 47 searchEngine = server.searchEngine; |
| 48 | 48 |
| 49 Future findElementReferences(protocol.Request request) async { | 49 Future findElementReferences(protocol.Request request) async { |
| 50 var params = | 50 var params = |
| 51 new protocol.SearchFindElementReferencesParams.fromRequest(request); | 51 new protocol.SearchFindElementReferencesParams.fromRequest(request); |
| 52 String file = params.file; | 52 String file = params.file; |
| 53 // prepare element | 53 // prepare element |
| 54 if (!server.options.enableNewAnalysisDriver) { | |
| 55 await server.onAnalysisComplete; | |
| 56 } | |
| 57 Element element = await server.getElementAtOffset(file, params.offset); | 54 Element element = await server.getElementAtOffset(file, params.offset); |
| 58 if (element is ImportElement) { | 55 if (element is ImportElement) { |
| 59 element = (element as ImportElement).prefix; | 56 element = (element as ImportElement).prefix; |
| 60 } | 57 } |
| 61 if (element is FieldFormalParameterElement) { | 58 if (element is FieldFormalParameterElement) { |
| 62 element = (element as FieldFormalParameterElement).field; | 59 element = (element as FieldFormalParameterElement).field; |
| 63 } | 60 } |
| 64 if (element is PropertyAccessorElement) { | 61 if (element is PropertyAccessorElement) { |
| 65 element = (element as PropertyAccessorElement).variable; | 62 element = (element as PropertyAccessorElement).variable; |
| 66 } | 63 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 matches = SearchMatch.withNotNullElement(matches); | 131 matches = SearchMatch.withNotNullElement(matches); |
| 135 _sendSearchNotification(searchId, true, matches.map(toResult)); | 132 _sendSearchNotification(searchId, true, matches.map(toResult)); |
| 136 } | 133 } |
| 137 | 134 |
| 138 /** | 135 /** |
| 139 * Implement the `search.getTypeHierarchy` request. | 136 * Implement the `search.getTypeHierarchy` request. |
| 140 */ | 137 */ |
| 141 Future getTypeHierarchy(protocol.Request request) async { | 138 Future getTypeHierarchy(protocol.Request request) async { |
| 142 var params = new protocol.SearchGetTypeHierarchyParams.fromRequest(request); | 139 var params = new protocol.SearchGetTypeHierarchyParams.fromRequest(request); |
| 143 String file = params.file; | 140 String file = params.file; |
| 144 // wait for analysis | |
| 145 if (!server.options.enableNewAnalysisDriver) { | |
| 146 if (params.superOnly == true) { | |
| 147 await server.onFileAnalysisComplete(file); | |
| 148 } else { | |
| 149 await server.onAnalysisComplete; | |
| 150 } | |
| 151 } | |
| 152 // prepare element | 141 // prepare element |
| 153 Element element = await server.getElementAtOffset(file, params.offset); | 142 Element element = await server.getElementAtOffset(file, params.offset); |
| 154 if (element == null) { | 143 if (element == null) { |
| 155 _sendTypeHierarchyNull(request); | 144 _sendTypeHierarchyNull(request); |
| 156 return; | 145 return; |
| 157 } | 146 } |
| 158 // maybe supertype hierarchy only | 147 // maybe supertype hierarchy only |
| 159 if (params.superOnly == true) { | 148 if (params.superOnly == true) { |
| 160 TypeHierarchyComputer computer = | 149 TypeHierarchyComputer computer = |
| 161 new TypeHierarchyComputer(searchEngine, element); | 150 new TypeHierarchyComputer(searchEngine, element); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 void _sendTypeHierarchyNull(protocol.Request request) { | 209 void _sendTypeHierarchyNull(protocol.Request request) { |
| 221 protocol.Response response = | 210 protocol.Response response = |
| 222 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); | 211 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); |
| 223 server.sendResponse(response); | 212 server.sendResponse(response); |
| 224 } | 213 } |
| 225 | 214 |
| 226 static protocol.SearchResult toResult(SearchMatch match) { | 215 static protocol.SearchResult toResult(SearchMatch match) { |
| 227 return protocol.newSearchResult_fromMatch(match); | 216 return protocol.newSearchResult_fromMatch(match); |
| 228 } | 217 } |
| 229 } | 218 } |
| OLD | NEW |