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/render/macro_.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/completion/src/render/macro_.rs') diff --git a/crates/completion/src/render/macro_.rs b/crates/completion/src/render/macro_.rs index b4ab32c6e..15648b5b7 100644 --- a/crates/completion/src/render/macro_.rs +++ b/crates/completion/src/render/macro_.rs @@ -50,7 +50,7 @@ impl<'a> MacroRender<'a> { .kind(CompletionItemKind::Macro) .set_documentation(self.docs.clone()) .set_deprecated(self.ctx.is_deprecated(self.macro_)) - .add_import(import_to_add) + .add_import(import_to_add, self.ctx.completion.config.should_resolve_immediately()) .detail(self.detail()); let needs_bang = self.needs_bang(); -- 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/render/macro_.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'crates/completion/src/render/macro_.rs') diff --git a/crates/completion/src/render/macro_.rs b/crates/completion/src/render/macro_.rs index 15648b5b7..7a8eeb7b9 100644 --- a/crates/completion/src/render/macro_.rs +++ b/crates/completion/src/render/macro_.rs @@ -50,7 +50,10 @@ impl<'a> MacroRender<'a> { .kind(CompletionItemKind::Macro) .set_documentation(self.docs.clone()) .set_deprecated(self.ctx.is_deprecated(self.macro_)) - .add_import(import_to_add, self.ctx.completion.config.should_resolve_immediately()) + .add_import( + import_to_add, + self.ctx.completion.config.should_resolve_additional_edits_immediately(), + ) .detail(self.detail()); let needs_bang = self.needs_bang(); -- 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/render/macro_.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'crates/completion/src/render/macro_.rs') diff --git a/crates/completion/src/render/macro_.rs b/crates/completion/src/render/macro_.rs index 7a8eeb7b9..be7c53659 100644 --- a/crates/completion/src/render/macro_.rs +++ b/crates/completion/src/render/macro_.rs @@ -50,10 +50,7 @@ impl<'a> MacroRender<'a> { .kind(CompletionItemKind::Macro) .set_documentation(self.docs.clone()) .set_deprecated(self.ctx.is_deprecated(self.macro_)) - .add_import( - import_to_add, - self.ctx.completion.config.should_resolve_additional_edits_immediately(), - ) + .add_import(import_to_add, self.ctx.completion.config.resolve_edits_immediately()) .detail(self.detail()); let needs_bang = self.needs_bang(); -- 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/render/macro_.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'crates/completion/src/render/macro_.rs') diff --git a/crates/completion/src/render/macro_.rs b/crates/completion/src/render/macro_.rs index be7c53659..bdbc642ca 100644 --- a/crates/completion/src/render/macro_.rs +++ b/crates/completion/src/render/macro_.rs @@ -5,13 +5,13 @@ use syntax::display::macro_label; use test_utils::mark; use crate::{ - item::{CompletionItem, CompletionItemKind, CompletionKind, ImportToAdd}, + item::{CompletionItem, CompletionItemKind, CompletionKind, ImportEdit}, render::RenderContext, }; pub(crate) fn render_macro<'a>( ctx: RenderContext<'a>, - import_to_add: Option, + import_to_add: Option, name: String, macro_: hir::MacroDef, ) -> Option { @@ -38,7 +38,7 @@ impl<'a> MacroRender<'a> { MacroRender { ctx, name, macro_, docs, bra, ket } } - fn render(&self, import_to_add: Option) -> Option { + fn render(&self, import_to_add: Option) -> Option { // FIXME: Currently proc-macro do not have ast-node, // such that it does not have source if self.macro_.is_proc_macro() { @@ -50,7 +50,10 @@ impl<'a> MacroRender<'a> { .kind(CompletionItemKind::Macro) .set_documentation(self.docs.clone()) .set_deprecated(self.ctx.is_deprecated(self.macro_)) - .add_import(import_to_add, self.ctx.completion.config.resolve_edits_immediately()) + .add_import( + import_to_add, + self.ctx.completion.config.resolve_additional_edits_lazily(), + ) .detail(self.detail()); let needs_bang = self.needs_bang(); -- 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/render/macro_.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'crates/completion/src/render/macro_.rs') diff --git a/crates/completion/src/render/macro_.rs b/crates/completion/src/render/macro_.rs index bdbc642ca..eb3209bee 100644 --- a/crates/completion/src/render/macro_.rs +++ b/crates/completion/src/render/macro_.rs @@ -50,10 +50,7 @@ impl<'a> MacroRender<'a> { .kind(CompletionItemKind::Macro) .set_documentation(self.docs.clone()) .set_deprecated(self.ctx.is_deprecated(self.macro_)) - .add_import( - import_to_add, - self.ctx.completion.config.resolve_additional_edits_lazily(), - ) + .add_import(import_to_add) .detail(self.detail()); let needs_bang = self.needs_bang(); -- cgit v1.2.3