diff options
Diffstat (limited to 'crates/server/src/main_loop/handlers.rs')
-rw-r--r-- | crates/server/src/main_loop/handlers.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/crates/server/src/main_loop/handlers.rs b/crates/server/src/main_loop/handlers.rs index 675f69bec..16cc92464 100644 --- a/crates/server/src/main_loop/handlers.rs +++ b/crates/server/src/main_loop/handlers.rs | |||
@@ -3,7 +3,7 @@ use std::collections::HashMap; | |||
3 | use languageserver_types::{ | 3 | use languageserver_types::{ |
4 | Diagnostic, DiagnosticSeverity, Url, DocumentSymbol, | 4 | Diagnostic, DiagnosticSeverity, Url, DocumentSymbol, |
5 | Command, TextDocumentIdentifier, WorkspaceEdit, | 5 | Command, TextDocumentIdentifier, WorkspaceEdit, |
6 | SymbolInformation, Position, | 6 | SymbolInformation, Position, Location, |
7 | }; | 7 | }; |
8 | use libanalysis::{Query}; | 8 | use libanalysis::{Query}; |
9 | use libeditor::{self, CursorPosition}; | 9 | use libeditor::{self, CursorPosition}; |
@@ -184,6 +184,23 @@ pub fn handle_goto_definition( | |||
184 | Ok(Some(req::GotoDefinitionResponse::Array(res))) | 184 | Ok(Some(req::GotoDefinitionResponse::Array(res))) |
185 | } | 185 | } |
186 | 186 | ||
187 | pub fn handle_parent_module( | ||
188 | world: ServerWorld, | ||
189 | params: TextDocumentIdentifier, | ||
190 | ) -> Result<Vec<Location>> { | ||
191 | let file_id = params.try_conv_with(&world)?; | ||
192 | let mut res = Vec::new(); | ||
193 | for (file_id, symbol) in world.analysis().parent_module(file_id) { | ||
194 | let line_index = world.analysis().file_line_index(file_id)?; | ||
195 | let location = to_location( | ||
196 | file_id, symbol.node_range, | ||
197 | &world, &line_index | ||
198 | )?; | ||
199 | res.push(location); | ||
200 | } | ||
201 | Ok(res) | ||
202 | } | ||
203 | |||
187 | pub fn handle_execute_command( | 204 | pub fn handle_execute_command( |
188 | world: ServerWorld, | 205 | world: ServerWorld, |
189 | mut params: req::ExecuteCommandParams, | 206 | mut params: req::ExecuteCommandParams, |