diff options
author | Aleksey Kladov <[email protected]> | 2018-08-15 22:23:22 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-15 22:23:22 +0100 |
commit | c631b585a7358d1569a051f2529ecaae222e95cd (patch) | |
tree | 2e8332d166900c29cf485297b8510451b97accd0 /crates/server/src/main_loop/handlers.rs | |
parent | aa0d344581dcfd7f18c595688a4b2709b0f2421e (diff) |
matching brace
Diffstat (limited to 'crates/server/src/main_loop/handlers.rs')
-rw-r--r-- | crates/server/src/main_loop/handlers.rs | 21 |
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; | |||
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, | 6 | SymbolInformation, Position, |
7 | }; | 7 | }; |
8 | use libanalysis::{World, Query}; | 8 | use libanalysis::{World, Query}; |
9 | use libeditor; | 9 | use libeditor; |
@@ -42,6 +42,25 @@ pub fn handle_extend_selection( | |||
42 | Ok(req::ExtendSelectionResult { selections }) | 42 | Ok(req::ExtendSelectionResult { selections }) |
43 | } | 43 | } |
44 | 44 | ||
45 | pub 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 | |||
45 | pub fn handle_document_symbol( | 64 | pub fn handle_document_symbol( |
46 | world: World, | 65 | world: World, |
47 | path_map: PathMap, | 66 | path_map: PathMap, |