| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 await searchEngine.searchTopLevelDeclarations(params.pattern); | 124 await searchEngine.searchTopLevelDeclarations(params.pattern); |
| 125 _sendSearchNotification(searchId, true, matches.map(toResult)); | 125 _sendSearchNotification(searchId, true, matches.map(toResult)); |
| 126 } | 126 } |
| 127 | 127 |
| 128 /** | 128 /** |
| 129 * Implement the `search.getTypeHierarchy` request. | 129 * Implement the `search.getTypeHierarchy` request. |
| 130 */ | 130 */ |
| 131 Future getTypeHierarchy(protocol.Request request) async { | 131 Future getTypeHierarchy(protocol.Request request) async { |
| 132 var params = new protocol.SearchGetTypeHierarchyParams.fromRequest(request); | 132 var params = new protocol.SearchGetTypeHierarchyParams.fromRequest(request); |
| 133 await server.onAnalysisComplete; | 133 await server.onAnalysisComplete; |
| 134 // prepare parameters | 134 // prepare element |
| 135 List<Element> elements = | 135 List<Element> elements = |
| 136 server.getElementsAtOffset(params.file, params.offset); | 136 server.getElementsAtOffset(params.file, params.offset); |
| 137 if (elements.isEmpty) { | 137 if (elements.isEmpty) { |
| 138 protocol.Response response = | 138 protocol.Response response = |
| 139 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); | 139 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); |
| 140 server.sendResponse(response); | 140 server.sendResponse(response); |
| 141 return; |
| 141 } | 142 } |
| 142 Element element = elements.first; | 143 Element element = elements.first; |
| 143 // prepare type hierarchy | 144 // prepare type hierarchy |
| 144 TypeHierarchyComputer computer = new TypeHierarchyComputer(searchEngine); | 145 TypeHierarchyComputer computer = new TypeHierarchyComputer(searchEngine); |
| 145 List<protocol.TypeHierarchyItem> items = await computer.compute(element); | 146 List<protocol.TypeHierarchyItem> items = await computer.compute(element); |
| 146 protocol.Response response = new protocol.SearchGetTypeHierarchyResult( | 147 protocol.Response response = new protocol.SearchGetTypeHierarchyResult( |
| 147 hierarchyItems: items).toResponse(request.id); | 148 hierarchyItems: items).toResponse(request.id); |
| 148 server.sendResponse(response); | 149 server.sendResponse(response); |
| 149 } | 150 } |
| 150 | 151 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 */ | 189 */ |
| 189 void _sendSearchResult(protocol.Request request, result) { | 190 void _sendSearchResult(protocol.Request request, result) { |
| 190 protocol.Response response = result.toResponse(request.id); | 191 protocol.Response response = result.toResponse(request.id); |
| 191 server.sendResponse(response); | 192 server.sendResponse(response); |
| 192 } | 193 } |
| 193 | 194 |
| 194 static protocol.SearchResult toResult(SearchMatch match) { | 195 static protocol.SearchResult toResult(SearchMatch match) { |
| 195 return protocol.newSearchResult_fromMatch(match); | 196 return protocol.newSearchResult_fromMatch(match); |
| 196 } | 197 } |
| 197 } | 198 } |
| OLD | NEW |