diff options
author | Aleksey Kladov <[email protected]> | 2021-01-05 13:57:05 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-01-05 14:46:57 +0000 |
commit | 624eb1ee54e759c03d07c06e5e68dec7f36cb519 (patch) | |
tree | e7ee04b6a3cb030e4db0c3d118d723b8cf3704e0 /crates/rust-analyzer/src/handlers.rs | |
parent | c8d3d5694be065ffb1d52bc33e098ff610693097 (diff) |
More maintainable caps config
The idea here is that we preserve client's config as is, without
changes. This gets rid of state!
Diffstat (limited to 'crates/rust-analyzer/src/handlers.rs')
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index c21ca044a..c13cdc4e3 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -320,7 +320,7 @@ pub(crate) fn handle_document_symbol( | |||
320 | acc | 320 | acc |
321 | }; | 321 | }; |
322 | 322 | ||
323 | let res = if snap.config.client_caps.hierarchical_symbols { | 323 | let res = if snap.config.hierarchical_symbols() { |
324 | document_symbols.into() | 324 | document_symbols.into() |
325 | } else { | 325 | } else { |
326 | let url = to_proto::url(&snap, file_id); | 326 | let url = to_proto::url(&snap, file_id); |
@@ -727,7 +727,7 @@ pub(crate) fn handle_folding_range( | |||
727 | let folds = snap.analysis.folding_ranges(file_id)?; | 727 | let folds = snap.analysis.folding_ranges(file_id)?; |
728 | let text = snap.analysis.file_text(file_id)?; | 728 | let text = snap.analysis.file_text(file_id)?; |
729 | let line_index = snap.analysis.file_line_index(file_id)?; | 729 | let line_index = snap.analysis.file_line_index(file_id)?; |
730 | let line_folding_only = snap.config.client_caps.line_folding_only; | 730 | let line_folding_only = snap.config.line_folding_only(); |
731 | let res = folds | 731 | let res = folds |
732 | .into_iter() | 732 | .into_iter() |
733 | .map(|it| to_proto::folding_range(&*text, &line_index, line_folding_only, it)) | 733 | .map(|it| to_proto::folding_range(&*text, &line_index, line_folding_only, it)) |
@@ -746,11 +746,8 @@ pub(crate) fn handle_signature_help( | |||
746 | None => return Ok(None), | 746 | None => return Ok(None), |
747 | }; | 747 | }; |
748 | let concise = !snap.config.call_info_full; | 748 | let concise = !snap.config.call_info_full; |
749 | let res = to_proto::signature_help( | 749 | let res = |
750 | call_info, | 750 | to_proto::signature_help(call_info, concise, snap.config.signature_help_label_offsets()); |
751 | concise, | ||
752 | snap.config.client_caps.signature_help_label_offsets, | ||
753 | ); | ||
754 | Ok(Some(res)) | 751 | Ok(Some(res)) |
755 | } | 752 | } |
756 | 753 | ||
@@ -929,7 +926,7 @@ pub(crate) fn handle_code_action( | |||
929 | // We intentionally don't support command-based actions, as those either | 926 | // We intentionally don't support command-based actions, as those either |
930 | // requires custom client-code anyway, or requires server-initiated edits. | 927 | // requires custom client-code anyway, or requires server-initiated edits. |
931 | // Server initiated edits break causality, so we avoid those as well. | 928 | // Server initiated edits break causality, so we avoid those as well. |
932 | if !snap.config.client_caps.code_action_literals { | 929 | if !snap.config.code_action_literals() { |
933 | return Ok(None); | 930 | return Ok(None); |
934 | } | 931 | } |
935 | 932 | ||
@@ -959,7 +956,7 @@ pub(crate) fn handle_code_action( | |||
959 | add_quick_fixes(&snap, frange, &line_index, &mut res)?; | 956 | add_quick_fixes(&snap, frange, &line_index, &mut res)?; |
960 | } | 957 | } |
961 | 958 | ||
962 | if snap.config.client_caps.code_action_resolve { | 959 | if snap.config.code_action_resolve() { |
963 | for (index, assist) in | 960 | for (index, assist) in |
964 | snap.analysis.assists(&assists_config, false, frange)?.into_iter().enumerate() | 961 | snap.analysis.assists(&assists_config, false, frange)?.into_iter().enumerate() |
965 | { | 962 | { |
@@ -1542,7 +1539,7 @@ fn debug_single_command(runnable: &lsp_ext::Runnable) -> Command { | |||
1542 | } | 1539 | } |
1543 | 1540 | ||
1544 | fn goto_location_command(snap: &GlobalStateSnapshot, nav: &NavigationTarget) -> Option<Command> { | 1541 | fn goto_location_command(snap: &GlobalStateSnapshot, nav: &NavigationTarget) -> Option<Command> { |
1545 | let value = if snap.config.client_caps.location_link { | 1542 | let value = if snap.config.location_link() { |
1546 | let link = to_proto::location_link(snap, None, nav.clone()).ok()?; | 1543 | let link = to_proto::location_link(snap, None, nav.clone()).ok()?; |
1547 | to_value(link).ok()? | 1544 | to_value(link).ok()? |
1548 | } else { | 1545 | } else { |
@@ -1641,7 +1638,7 @@ fn prepare_hover_actions( | |||
1641 | file_id: FileId, | 1638 | file_id: FileId, |
1642 | actions: &[HoverAction], | 1639 | actions: &[HoverAction], |
1643 | ) -> Vec<lsp_ext::CommandLinkGroup> { | 1640 | ) -> Vec<lsp_ext::CommandLinkGroup> { |
1644 | if snap.config.hover.none() || !snap.config.client_caps.hover_actions { | 1641 | if snap.config.hover.none() || !snap.config.hover_actions() { |
1645 | return Vec::new(); | 1642 | return Vec::new(); |
1646 | } | 1643 | } |
1647 | 1644 | ||