From 47464e556c160ce705c2e3c84f501ad4e8dbb123 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 1 Dec 2020 22:46:06 +0200 Subject: Properly fill client completion resolve capabilities data --- crates/completion/src/config.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'crates/completion/src/config.rs') diff --git a/crates/completion/src/config.rs b/crates/completion/src/config.rs index 654a76f7b..736af455e 100644 --- a/crates/completion/src/config.rs +++ b/crates/completion/src/config.rs @@ -5,6 +5,7 @@ //! completions if we are allowed to. use ide_db::helpers::insert_use::MergeBehaviour; +use rustc_hash::FxHashSet; #[derive(Clone, Debug, PartialEq, Eq)] pub struct CompletionConfig { @@ -14,6 +15,14 @@ pub struct CompletionConfig { pub add_call_argument_snippets: bool, pub snippet_cap: Option, pub merge: Option, + pub resolve_capabilities: FxHashSet, +} + +#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)] +pub enum CompletionResolveCapability { + Documentation, + Detail, + AdditionalTextEdits, } impl CompletionConfig { @@ -36,6 +45,7 @@ impl Default for CompletionConfig { add_call_argument_snippets: true, snippet_cap: Some(SnippetCap { _private: () }), merge: Some(MergeBehaviour::Full), + resolve_capabilities: FxHashSet::default(), } } } -- cgit v1.2.3 From d9bd1f171dde11ff04f0619b14d8f25e5e4fc56e Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 2 Dec 2020 23:55:35 +0200 Subject: Add eager resolve capability --- crates/completion/src/config.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'crates/completion/src/config.rs') diff --git a/crates/completion/src/config.rs b/crates/completion/src/config.rs index 736af455e..e9a02aeb8 100644 --- a/crates/completion/src/config.rs +++ b/crates/completion/src/config.rs @@ -29,6 +29,10 @@ impl CompletionConfig { pub fn allow_snippets(&mut self, yes: bool) { self.snippet_cap = if yes { Some(SnippetCap { _private: () }) } else { None } } + + pub fn should_resolve_immediately(&self) -> bool { + !self.resolve_capabilities.contains(&CompletionResolveCapability::AdditionalTextEdits) + } } #[derive(Clone, Copy, Debug, PartialEq, Eq)] -- cgit v1.2.3 From 50e06ee95ab12bc204fdce557ab0fb7aa5e5ab2f Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 3 Dec 2020 00:13:32 +0200 Subject: Refactor the code --- crates/completion/src/config.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'crates/completion/src/config.rs') diff --git a/crates/completion/src/config.rs b/crates/completion/src/config.rs index e9a02aeb8..f2fa5c27b 100644 --- a/crates/completion/src/config.rs +++ b/crates/completion/src/config.rs @@ -15,9 +15,15 @@ pub struct CompletionConfig { pub add_call_argument_snippets: bool, pub snippet_cap: Option, pub merge: Option, + /// A set of capabilities, enabled on the cliend and supported on the server. pub resolve_capabilities: FxHashSet, } +/// A resolve capability, supported on a server. +/// If the client registers any of those in its completion resolve capabilities, +/// the server is able to render completion items' corresponding fields later, +/// not during an initial completion item request. +/// See https://github.com/rust-analyzer/rust-analyzer/issues/6366 for more details. #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)] pub enum CompletionResolveCapability { Documentation, @@ -30,7 +36,8 @@ impl CompletionConfig { self.snippet_cap = if yes { Some(SnippetCap { _private: () }) } else { None } } - pub fn should_resolve_immediately(&self) -> bool { + /// Whether the completions' additional edits are calculated later, during a resolve request or not. + pub fn should_resolve_additional_edits_immediately(&self) -> bool { !self.resolve_capabilities.contains(&CompletionResolveCapability::AdditionalTextEdits) } } -- cgit v1.2.3 From 68a747efe048e8e92eedafaa27b0c0d2f317f04d Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 3 Dec 2020 00:27:26 +0200 Subject: Remove redundant code --- crates/completion/src/config.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'crates/completion/src/config.rs') diff --git a/crates/completion/src/config.rs b/crates/completion/src/config.rs index f2fa5c27b..eacdd3449 100644 --- a/crates/completion/src/config.rs +++ b/crates/completion/src/config.rs @@ -15,12 +15,12 @@ pub struct CompletionConfig { pub add_call_argument_snippets: bool, pub snippet_cap: Option, pub merge: Option, - /// A set of capabilities, enabled on the cliend and supported on the server. - pub resolve_capabilities: FxHashSet, + /// A set of capabilities, enabled on the client and supported on the server. + pub active_resolve_capabilities: FxHashSet, } -/// A resolve capability, supported on a server. -/// If the client registers any of those in its completion resolve capabilities, +/// A resolve capability, supported on the server. +/// If the client registers any completion resolve capabilities, /// the server is able to render completion items' corresponding fields later, /// not during an initial completion item request. /// See https://github.com/rust-analyzer/rust-analyzer/issues/6366 for more details. @@ -37,8 +37,11 @@ impl CompletionConfig { } /// Whether the completions' additional edits are calculated later, during a resolve request or not. - pub fn should_resolve_additional_edits_immediately(&self) -> bool { - !self.resolve_capabilities.contains(&CompletionResolveCapability::AdditionalTextEdits) + /// See `CompletionResolveCapability` for the details. + pub fn resolve_edits_immediately(&self) -> bool { + !self + .active_resolve_capabilities + .contains(&CompletionResolveCapability::AdditionalTextEdits) } } @@ -56,7 +59,7 @@ impl Default for CompletionConfig { add_call_argument_snippets: true, snippet_cap: Some(SnippetCap { _private: () }), merge: Some(MergeBehaviour::Full), - resolve_capabilities: FxHashSet::default(), + active_resolve_capabilities: FxHashSet::default(), } } } -- cgit v1.2.3 From f6d2540df09bc0dcd8a748ec0ed7cb33ac76d9f2 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 3 Dec 2020 11:13:28 +0200 Subject: Simplify import edit calculation --- crates/completion/src/config.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'crates/completion/src/config.rs') diff --git a/crates/completion/src/config.rs b/crates/completion/src/config.rs index eacdd3449..487c1d0f1 100644 --- a/crates/completion/src/config.rs +++ b/crates/completion/src/config.rs @@ -36,12 +36,10 @@ impl CompletionConfig { self.snippet_cap = if yes { Some(SnippetCap { _private: () }) } else { None } } - /// Whether the completions' additional edits are calculated later, during a resolve request or not. - /// See `CompletionResolveCapability` for the details. - pub fn resolve_edits_immediately(&self) -> bool { - !self - .active_resolve_capabilities - .contains(&CompletionResolveCapability::AdditionalTextEdits) + /// Whether the completions' additional edits are calculated when sending an initional completions list + /// or later, in a separate resolve request. + pub fn resolve_additional_edits_lazily(&self) -> bool { + self.active_resolve_capabilities.contains(&CompletionResolveCapability::AdditionalTextEdits) } } -- cgit v1.2.3 From 3183ff3a7b1fbcf3cb5379cf162a3d769a21be7a Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 8 Dec 2020 00:46:56 +0200 Subject: Disable the completion for no corresponding client resolve capabilities --- crates/completion/src/config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/completion/src/config.rs') diff --git a/crates/completion/src/config.rs b/crates/completion/src/config.rs index 487c1d0f1..8082ec9cb 100644 --- a/crates/completion/src/config.rs +++ b/crates/completion/src/config.rs @@ -10,7 +10,7 @@ use rustc_hash::FxHashSet; #[derive(Clone, Debug, PartialEq, Eq)] pub struct CompletionConfig { pub enable_postfix_completions: bool, - pub enable_experimental_completions: bool, + pub disable_fuzzy_autoimports: bool, pub add_call_parenthesis: bool, pub add_call_argument_snippets: bool, pub snippet_cap: Option, @@ -52,7 +52,7 @@ impl Default for CompletionConfig { fn default() -> Self { CompletionConfig { enable_postfix_completions: true, - enable_experimental_completions: true, + disable_fuzzy_autoimports: false, add_call_parenthesis: true, add_call_argument_snippets: true, snippet_cap: Some(SnippetCap { _private: () }), -- cgit v1.2.3 From cbd3717f2c52b17aa9b15c2df4a364c62d17e4e1 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 8 Dec 2020 14:27:18 +0200 Subject: Better config name --- crates/completion/src/config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/completion/src/config.rs') diff --git a/crates/completion/src/config.rs b/crates/completion/src/config.rs index 8082ec9cb..5175b9d69 100644 --- a/crates/completion/src/config.rs +++ b/crates/completion/src/config.rs @@ -10,7 +10,7 @@ use rustc_hash::FxHashSet; #[derive(Clone, Debug, PartialEq, Eq)] pub struct CompletionConfig { pub enable_postfix_completions: bool, - pub disable_fuzzy_autoimports: bool, + pub enable_autoimport_completions: bool, pub add_call_parenthesis: bool, pub add_call_argument_snippets: bool, pub snippet_cap: Option, @@ -52,7 +52,7 @@ impl Default for CompletionConfig { fn default() -> Self { CompletionConfig { enable_postfix_completions: true, - disable_fuzzy_autoimports: false, + enable_autoimport_completions: true, add_call_parenthesis: true, add_call_argument_snippets: true, snippet_cap: Some(SnippetCap { _private: () }), -- cgit v1.2.3