diff options
author | Aleksey Kladov <[email protected]> | 2020-12-26 11:11:42 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-12-26 11:11:42 +0000 |
commit | 2f2267553769bd7c63ab49c85e4c67a7339355c3 (patch) | |
tree | 107c3baf8ac0d8b386f7b1441544011e23caf70b /crates/rust-analyzer/src/to_proto.rs | |
parent | 44893bbcc58abc630e5263d3261236ca1cc21041 (diff) |
Simplify assists resolution API
Assist vs UnresolvedAssist split doesn't really pull its weight. This
is especially bad if we want to include `Assist` as a field of
diagnostics, where we'd have to make the thing generic.
Diffstat (limited to 'crates/rust-analyzer/src/to_proto.rs')
-rw-r--r-- | crates/rust-analyzer/src/to_proto.rs | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 753aad628..1a38e79f0 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs | |||
@@ -8,8 +8,8 @@ use ide::{ | |||
8 | Assist, AssistKind, CallInfo, CompletionItem, CompletionItemKind, Documentation, FileId, | 8 | Assist, AssistKind, CallInfo, CompletionItem, CompletionItemKind, Documentation, FileId, |
9 | FileRange, FileSystemEdit, Fold, FoldKind, Highlight, HighlightModifier, HighlightTag, | 9 | FileRange, FileSystemEdit, Fold, FoldKind, Highlight, HighlightModifier, HighlightTag, |
10 | HighlightedRange, Indel, InlayHint, InlayKind, InsertTextFormat, LineIndex, Markup, | 10 | HighlightedRange, Indel, InlayHint, InlayKind, InsertTextFormat, LineIndex, Markup, |
11 | NavigationTarget, ReferenceAccess, ResolvedAssist, Runnable, Severity, SourceChange, | 11 | NavigationTarget, ReferenceAccess, Runnable, Severity, SourceChange, SourceFileEdit, |
12 | SourceFileEdit, SymbolKind, TextEdit, TextRange, TextSize, | 12 | SymbolKind, TextEdit, TextRange, TextSize, |
13 | }; | 13 | }; |
14 | use itertools::Itertools; | 14 | use itertools::Itertools; |
15 | 15 | ||
@@ -780,6 +780,7 @@ pub(crate) fn unresolved_code_action( | |||
780 | assist: Assist, | 780 | assist: Assist, |
781 | index: usize, | 781 | index: usize, |
782 | ) -> Result<lsp_ext::CodeAction> { | 782 | ) -> Result<lsp_ext::CodeAction> { |
783 | assert!(assist.source_change.is_none()); | ||
783 | let res = lsp_ext::CodeAction { | 784 | let res = lsp_ext::CodeAction { |
784 | title: assist.label.to_string(), | 785 | title: assist.label.to_string(), |
785 | group: assist.group.filter(|_| snap.config.client_caps.code_action_group).map(|gr| gr.0), | 786 | group: assist.group.filter(|_| snap.config.client_caps.code_action_group).map(|gr| gr.0), |
@@ -796,18 +797,14 @@ pub(crate) fn unresolved_code_action( | |||
796 | 797 | ||
797 | pub(crate) fn resolved_code_action( | 798 | pub(crate) fn resolved_code_action( |
798 | snap: &GlobalStateSnapshot, | 799 | snap: &GlobalStateSnapshot, |
799 | assist: ResolvedAssist, | 800 | assist: Assist, |
800 | ) -> Result<lsp_ext::CodeAction> { | 801 | ) -> Result<lsp_ext::CodeAction> { |
801 | let change = assist.source_change; | 802 | let change = assist.source_change.unwrap(); |
802 | let res = lsp_ext::CodeAction { | 803 | let res = lsp_ext::CodeAction { |
803 | edit: Some(snippet_workspace_edit(snap, change)?), | 804 | edit: Some(snippet_workspace_edit(snap, change)?), |
804 | title: assist.assist.label.to_string(), | 805 | title: assist.label.to_string(), |
805 | group: assist | 806 | group: assist.group.filter(|_| snap.config.client_caps.code_action_group).map(|gr| gr.0), |
806 | .assist | 807 | kind: Some(code_action_kind(assist.id.1)), |
807 | .group | ||
808 | .filter(|_| snap.config.client_caps.code_action_group) | ||
809 | .map(|gr| gr.0), | ||
810 | kind: Some(code_action_kind(assist.assist.id.1)), | ||
811 | is_preferred: None, | 808 | is_preferred: None, |
812 | data: None, | 809 | data: None, |
813 | }; | 810 | }; |