aboutsummaryrefslogtreecommitdiff
path: root/crates/server/src/main_loop/handlers.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/server/src/main_loop/handlers.rs')
-rw-r--r--crates/server/src/main_loop/handlers.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/crates/server/src/main_loop/handlers.rs b/crates/server/src/main_loop/handlers.rs
index 078abfbfa..d7b78b4fa 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;
3use languageserver_types::{ 3use languageserver_types::{
4 Diagnostic, DiagnosticSeverity, Url, DocumentSymbol, 4 Diagnostic, DiagnosticSeverity, Url, DocumentSymbol,
5 Command, TextDocumentIdentifier, WorkspaceEdit, 5 Command, TextDocumentIdentifier, WorkspaceEdit,
6 SymbolInformation, 6 SymbolInformation, Position,
7}; 7};
8use libanalysis::{World, Query}; 8use libanalysis::{World, Query};
9use libeditor; 9use libeditor;
@@ -42,6 +42,25 @@ pub fn handle_extend_selection(
42 Ok(req::ExtendSelectionResult { selections }) 42 Ok(req::ExtendSelectionResult { selections })
43} 43}
44 44
45pub fn handle_find_matching_brace(
46 world: World,
47 path_map: PathMap,
48 params: req::FindMatchingBraceParams,
49) -> Result<Vec<Position>> {
50 let file_id = params.text_document.try_conv_with(&path_map)?;
51 let file = world.file_syntax(file_id)?;
52 let line_index = world.file_line_index(file_id)?;
53 let res = params.offsets
54 .into_iter()
55 .map_conv_with(&line_index)
56 .map(|offset| {
57 libeditor::matching_brace(&file, offset).unwrap_or(offset)
58 })
59 .map_conv_with(&line_index)
60 .collect();
61 Ok(res)
62}
63
45pub fn handle_document_symbol( 64pub fn handle_document_symbol(
46 world: World, 65 world: World,
47 path_map: PathMap, 66 path_map: PathMap,