aboutsummaryrefslogtreecommitdiff
path: root/crates/server/src/main_loop
diff options
context:
space:
mode:
Diffstat (limited to 'crates/server/src/main_loop')
-rw-r--r--crates/server/src/main_loop/handlers.rs21
-rw-r--r--crates/server/src/main_loop/mod.rs4
2 files changed, 24 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,
diff --git a/crates/server/src/main_loop/mod.rs b/crates/server/src/main_loop/mod.rs
index 2a31297be..4d5dfb437 100644
--- a/crates/server/src/main_loop/mod.rs
+++ b/crates/server/src/main_loop/mod.rs
@@ -26,6 +26,7 @@ use {
26 handle_execute_command, 26 handle_execute_command,
27 handle_workspace_symbol, 27 handle_workspace_symbol,
28 handle_goto_definition, 28 handle_goto_definition,
29 handle_find_matching_brace,
29 }, 30 },
30}; 31};
31 32
@@ -148,6 +149,9 @@ fn on_request(
148 handle_request_on_threadpool::<req::ExtendSelection>( 149 handle_request_on_threadpool::<req::ExtendSelection>(
149 &mut req, pool, path_map, world, sender, handle_extend_selection, 150 &mut req, pool, path_map, world, sender, handle_extend_selection,
150 )?; 151 )?;
152 handle_request_on_threadpool::<req::FindMatchingBrace>(
153 &mut req, pool, path_map, world, sender, handle_find_matching_brace,
154 )?;
151 handle_request_on_threadpool::<req::DocumentSymbolRequest>( 155 handle_request_on_threadpool::<req::DocumentSymbolRequest>(
152 &mut req, pool, path_map, world, sender, handle_document_symbol, 156 &mut req, pool, path_map, world, sender, handle_document_symbol,
153 )?; 157 )?;