aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop/handlers.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-02 14:09:39 +0000
committerAleksey Kladov <[email protected]>2019-01-02 14:09:39 +0000
commit830abe0c1b9fdbc20a78771d0b3df37d9eabdc3e (patch)
treef111e68f8f05274baaa2310a60dda34f6d1b6fa0 /crates/ra_lsp_server/src/main_loop/handlers.rs
parentd25c89f7608cb15e8c5ae08a92b6a7a6d6f308b8 (diff)
use navigation target in API
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop/handlers.rs')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs33
1 files changed, 15 insertions, 18 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 5ff6219f9..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 nav in rr.resolves_to { 215 .resolves_to
217 let line_index = world.analysis().file_line_index(nav.file_id()); 216 .into_iter()
218 let location = to_location(nav.file_id(), nav.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
238pub fn handle_runnables( 235pub fn handle_runnables(