| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // TODO(scheglov) implement for the new analysis driver | 53 // TODO(scheglov) implement for the new analysis driver |
| 54 String searchId = (_nextSearchId++).toString(); | 54 String searchId = (_nextSearchId++).toString(); |
| 55 var result = new protocol.SearchFindElementReferencesResult(); | 55 var result = new protocol.SearchFindElementReferencesResult(); |
| 56 result.id = searchId; | 56 result.id = searchId; |
| 57 _sendSearchResult(request, result); | 57 _sendSearchResult(request, result); |
| 58 _sendSearchNotification(searchId, true, <protocol.SearchResult>[]); | 58 _sendSearchNotification(searchId, true, <protocol.SearchResult>[]); |
| 59 return; | 59 return; |
| 60 } | 60 } |
| 61 var params = | 61 var params = |
| 62 new protocol.SearchFindElementReferencesParams.fromRequest(request); | 62 new protocol.SearchFindElementReferencesParams.fromRequest(request); |
| 63 String file = params.file; |
| 63 await server.onAnalysisComplete; | 64 await server.onAnalysisComplete; |
| 64 // prepare element | 65 // prepare element |
| 65 Element element = server.getElementAtOffset(params.file, params.offset); | 66 Element element = await server.getElementAtOffset(file, params.offset); |
| 66 if (element is ImportElement) { | 67 if (element is ImportElement) { |
| 67 element = (element as ImportElement).prefix; | 68 element = (element as ImportElement).prefix; |
| 68 } | 69 } |
| 69 if (element is FieldFormalParameterElement) { | 70 if (element is FieldFormalParameterElement) { |
| 70 element = (element as FieldFormalParameterElement).field; | 71 element = (element as FieldFormalParameterElement).field; |
| 71 } | 72 } |
| 72 if (element is PropertyAccessorElement) { | 73 if (element is PropertyAccessorElement) { |
| 73 element = (element as PropertyAccessorElement).variable; | 74 element = (element as PropertyAccessorElement).variable; |
| 74 } | 75 } |
| 75 // respond | 76 // respond |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 } | 156 } |
| 156 var params = new protocol.SearchGetTypeHierarchyParams.fromRequest(request); | 157 var params = new protocol.SearchGetTypeHierarchyParams.fromRequest(request); |
| 157 String file = params.file; | 158 String file = params.file; |
| 158 // wait for analysis | 159 // wait for analysis |
| 159 if (params.superOnly == true) { | 160 if (params.superOnly == true) { |
| 160 await server.onFileAnalysisComplete(file); | 161 await server.onFileAnalysisComplete(file); |
| 161 } else { | 162 } else { |
| 162 await server.onAnalysisComplete; | 163 await server.onAnalysisComplete; |
| 163 } | 164 } |
| 164 // prepare element | 165 // prepare element |
| 165 Element element = server.getElementAtOffset(file, params.offset); | 166 Element element = await server.getElementAtOffset(file, params.offset); |
| 166 if (element == null) { | 167 if (element == null) { |
| 167 _sendTypeHierarchyNull(request); | 168 _sendTypeHierarchyNull(request); |
| 168 return; | 169 return; |
| 169 } | 170 } |
| 170 // maybe supertype hierarchy only | 171 // maybe supertype hierarchy only |
| 171 if (params.superOnly == true) { | 172 if (params.superOnly == true) { |
| 172 TypeHierarchyComputer computer = | 173 TypeHierarchyComputer computer = |
| 173 new TypeHierarchyComputer(searchEngine, element); | 174 new TypeHierarchyComputer(searchEngine, element); |
| 174 List<protocol.TypeHierarchyItem> items = computer.computeSuper(); | 175 List<protocol.TypeHierarchyItem> items = computer.computeSuper(); |
| 175 protocol.Response response = | 176 protocol.Response response = |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 void _sendTypeHierarchyNull(protocol.Request request) { | 236 void _sendTypeHierarchyNull(protocol.Request request) { |
| 236 protocol.Response response = | 237 protocol.Response response = |
| 237 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); | 238 new protocol.SearchGetTypeHierarchyResult().toResponse(request.id); |
| 238 server.sendResponse(response); | 239 server.sendResponse(response); |
| 239 } | 240 } |
| 240 | 241 |
| 241 static protocol.SearchResult toResult(SearchMatch match) { | 242 static protocol.SearchResult toResult(SearchMatch match) { |
| 242 return protocol.newSearchResult_fromMatch(match); | 243 return protocol.newSearchResult_fromMatch(match); |
| 243 } | 244 } |
| 244 } | 245 } |
| OLD | NEW |