From 6e87828756d970e9c25635aa9f71f0a90cc8ff65 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 6 Jan 2021 20:23:53 +0300 Subject: YAGNI active_resolve_capabilities This leaks a lot of LSP details into ide layer, which we want to avoid: https://github.com/rust-analyzer/rust-analyzer/tree/c9cec381bcfd97e5f3536e31a9c546ab5c0665e6/docs/dev#lsp-independence Additionally, all what this infra does is providing a toggle for auto-import completion, but we already have one! --- .../completion/src/completions/unqualified_path.rs | 8 ++------ crates/completion/src/config.rs | 22 ---------------------- crates/completion/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 29 deletions(-) (limited to 'crates/completion/src') diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs index 2f41a3f96..896f167ff 100644 --- a/crates/completion/src/completions/unqualified_path.rs +++ b/crates/completion/src/completions/unqualified_path.rs @@ -46,7 +46,7 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC acc.add_resolution(ctx, name.to_string(), &res) }); - if ctx.config.enable_autoimport_completions && ctx.config.resolve_additional_edits_lazily() { + if ctx.config.enable_autoimport_completions { fuzzy_completion(acc, ctx); } } @@ -206,11 +206,7 @@ mod tests { } fn fuzzy_completion_config() -> CompletionConfig { - let mut completion_config = CompletionConfig::default(); - completion_config - .active_resolve_capabilities - .insert(crate::CompletionResolveCapability::AdditionalTextEdits); - completion_config + CompletionConfig::default() } #[test] diff --git a/crates/completion/src/config.rs b/crates/completion/src/config.rs index 30577dc11..9f82b0346 100644 --- a/crates/completion/src/config.rs +++ b/crates/completion/src/config.rs @@ -5,7 +5,6 @@ //! completions if we are allowed to. use ide_db::helpers::insert_use::MergeBehavior; -use rustc_hash::FxHashSet; #[derive(Clone, Debug, PartialEq, Eq)] pub struct CompletionConfig { @@ -15,32 +14,12 @@ pub struct CompletionConfig { pub add_call_argument_snippets: bool, pub snippet_cap: Option, pub merge: Option, - /// A set of capabilities, enabled on the client and supported on the server. - pub active_resolve_capabilities: FxHashSet, -} - -/// 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. -#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)] -pub enum CompletionResolveCapability { - Documentation, - Detail, - AdditionalTextEdits, } impl CompletionConfig { pub fn allow_snippets(&mut self, yes: bool) { self.snippet_cap = if yes { Some(SnippetCap { _private: () }) } else { None } } - - /// 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) - } } #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -57,7 +36,6 @@ impl Default for CompletionConfig { add_call_argument_snippets: true, snippet_cap: Some(SnippetCap { _private: () }), merge: Some(MergeBehavior::Full), - active_resolve_capabilities: FxHashSet::default(), } } } diff --git a/crates/completion/src/lib.rs b/crates/completion/src/lib.rs index c57d05bbe..366aced71 100644 --- a/crates/completion/src/lib.rs +++ b/crates/completion/src/lib.rs @@ -20,7 +20,7 @@ use text_edit::TextEdit; use crate::{completions::Completions, context::CompletionContext, item::CompletionKind}; pub use crate::{ - config::{CompletionConfig, CompletionResolveCapability}, + config::CompletionConfig, item::{CompletionItem, CompletionItemKind, CompletionScore, ImportEdit, InsertTextFormat}, }; -- cgit v1.2.3