diff options
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 11825d74e..26b6c7d8a 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -188,12 +188,11 @@ pub fn handle_workspace_symbol( | |||
188 | 188 | ||
189 | fn exec_query(world: &ServerWorld, query: Query) -> Result<Vec<SymbolInformation>> { | 189 | fn exec_query(world: &ServerWorld, query: Query) -> Result<Vec<SymbolInformation>> { |
190 | let mut res = Vec::new(); | 190 | let mut res = Vec::new(); |
191 | for (file_id, symbol) in world.analysis().symbol_search(query)? { | 191 | for nav in world.analysis().symbol_search(query)? { |
192 | let line_index = world.analysis().file_line_index(file_id); | ||
193 | let info = SymbolInformation { | 192 | let info = SymbolInformation { |
194 | name: symbol.name.to_string(), | 193 | name: nav.name().into(), |
195 | kind: symbol.kind.conv(), | 194 | kind: nav.kind().conv(), |
196 | location: to_location(file_id, symbol.node_range, world, &line_index)?, | 195 | location: nav.try_conv_with(world)?, |
197 | container_name: None, | 196 | container_name: None, |
198 | deprecated: None, | 197 | deprecated: None, |
199 | }; | 198 | }; |
@@ -212,12 +211,11 @@ pub fn handle_goto_definition( | |||
212 | None => return Ok(None), | 211 | None => return Ok(None), |
213 | Some(it) => it, | 212 | Some(it) => it, |
214 | }; | 213 | }; |
215 | let mut res = Vec::new(); | 214 | let res = rr |
216 | for (file_id, symbol) in rr.resolves_to { | 215 | .resolves_to |
217 | let line_index = world.analysis().file_line_index(file_id); | 216 | .into_iter() |
218 | let location = to_location(file_id, symbol.node_range, &world, &line_index)?; | 217 | .map(|nav| nav.try_conv_with(&world)) |
219 | res.push(location) | 218 | .collect::<Result<Vec<_>>>()?; |
220 | } | ||
221 | Ok(Some(req::GotoDefinitionResponse::Array(res))) | 219 | Ok(Some(req::GotoDefinitionResponse::Array(res))) |
222 | } | 220 | } |
223 | 221 | ||
@@ -226,13 +224,12 @@ pub fn handle_parent_module( | |||
226 | params: req::TextDocumentPositionParams, | 224 | params: req::TextDocumentPositionParams, |
227 | ) -> Result<Vec<Location>> { | 225 | ) -> Result<Vec<Location>> { |
228 | let position = params.try_conv_with(&world)?; | 226 | let position = params.try_conv_with(&world)?; |
229 | let mut res = Vec::new(); | 227 | world |
230 | for (file_id, symbol) in world.analysis().parent_module(position)? { | 228 | .analysis() |
231 | let line_index = world.analysis().file_line_index(file_id); | 229 | .parent_module(position)? |
232 | let location = to_location(file_id, symbol.node_range, &world, &line_index)?; | 230 | .into_iter() |
233 | res.push(location); | 231 | .map(|nav| nav.try_conv_with(&world)) |
234 | } | 232 | .collect::<Result<Vec<_>>>() |
235 | Ok(res) | ||
236 | } | 233 | } |
237 | 234 | ||
238 | pub fn handle_runnables( | 235 | pub fn handle_runnables( |
@@ -517,8 +514,8 @@ pub fn handle_hover( | |||
517 | Some(it) => it, | 514 | Some(it) => it, |
518 | }; | 515 | }; |
519 | let mut result = Vec::new(); | 516 | let mut result = Vec::new(); |
520 | for (file_id, symbol) in rr.resolves_to { | 517 | for nav in rr.resolves_to { |
521 | if let Some(docs) = world.analysis().doc_text_for(file_id, symbol)? { | 518 | if let Some(docs) = world.analysis().doc_text_for(nav)? { |
522 | result.push(docs); | 519 | result.push(docs); |
523 | } | 520 | } |
524 | } | 521 | } |