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 | |
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')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 14 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/mod.rs | 1 |
2 files changed, 15 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, |
diff --git a/crates/ra_lsp_server/src/main_loop/mod.rs b/crates/ra_lsp_server/src/main_loop/mod.rs index 47a9b202e..53c6f1dff 100644 --- a/crates/ra_lsp_server/src/main_loop/mod.rs +++ b/crates/ra_lsp_server/src/main_loop/mod.rs | |||
@@ -244,6 +244,7 @@ fn on_request( | |||
244 | .on::<req::ExtendSelection>(handlers::handle_extend_selection)? | 244 | .on::<req::ExtendSelection>(handlers::handle_extend_selection)? |
245 | .on::<req::FindMatchingBrace>(handlers::handle_find_matching_brace)? | 245 | .on::<req::FindMatchingBrace>(handlers::handle_find_matching_brace)? |
246 | .on::<req::JoinLines>(handlers::handle_join_lines)? | 246 | .on::<req::JoinLines>(handlers::handle_join_lines)? |
247 | .on::<req::OnEnter>(handlers::handle_on_enter)? | ||
247 | .on::<req::OnTypeFormatting>(handlers::handle_on_type_formatting)? | 248 | .on::<req::OnTypeFormatting>(handlers::handle_on_type_formatting)? |
248 | .on::<req::DocumentSymbolRequest>(handlers::handle_document_symbol)? | 249 | .on::<req::DocumentSymbolRequest>(handlers::handle_document_symbol)? |
249 | .on::<req::WorkspaceSymbol>(handlers::handle_workspace_symbol)? | 250 | .on::<req::WorkspaceSymbol>(handlers::handle_workspace_symbol)? |