diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-10-09 17:52:48 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-10-09 17:52:48 +0100 |
commit | 31c8ebb743572ef07ac4ca77ddd17eddbcf4b24c (patch) | |
tree | 7a817485cf24ffe6e2acbec607115569bf3d8ac8 /crates/ra_lsp_server/src/main_loop/handlers.rs | |
parent | 14baf11bd41eb17cfee79fd7f9d068c4e785aa71 (diff) | |
parent | 2b956fd3a83313cee37ff179eae843bc88dd572a (diff) |
Merge #106
106: Add on-enter handler r=matklad a=matklad
Now, typing doc comments is much more pleasant
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop/handlers.rs')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 79a54183e..725036cc7 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -77,6 +77,20 @@ pub fn handle_join_lines( | |||
77 | .try_conv_with(&world) | 77 | .try_conv_with(&world) |
78 | } | 78 | } |
79 | 79 | ||
80 | pub fn handle_on_enter( | ||
81 | world: ServerWorld, | ||
82 | params: req::TextDocumentPositionParams, | ||
83 | _token: JobToken, | ||
84 | ) -> Result<Option<req::SourceChange>> { | ||
85 | let file_id = params.text_document.try_conv_with(&world)?; | ||
86 | let line_index = world.analysis().file_line_index(file_id); | ||
87 | let offset = params.position.conv_with(&line_index); | ||
88 | match world.analysis().on_enter(file_id, offset) { | ||
89 | None => Ok(None), | ||
90 | Some(edit) => Ok(Some(edit.try_conv_with(&world)?)) | ||
91 | } | ||
92 | } | ||
93 | |||
80 | pub fn handle_on_type_formatting( | 94 | pub fn handle_on_type_formatting( |
81 | world: ServerWorld, | 95 | world: ServerWorld, |
82 | params: req::DocumentOnTypeFormattingParams, | 96 | params: req::DocumentOnTypeFormattingParams, |