From 7e217a42e1c2dfd26defb9f448d8b0c57c7fc1a4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 12 Mar 2021 12:12:32 +0300 Subject: Unify naming --- crates/ide_completion/src/render/enum_variant.rs | 11 +++++------ crates/ide_completion/src/render/function.rs | 7 +++---- crates/ide_completion/src/render/macro_.rs | 13 ++++++------- crates/ide_completion/src/render/pattern.rs | 17 ++++++++--------- 4 files changed, 22 insertions(+), 26 deletions(-) (limited to 'crates/ide_completion/src/render') diff --git a/crates/ide_completion/src/render/enum_variant.rs b/crates/ide_completion/src/render/enum_variant.rs index 23c43496e..e8cfcc0c7 100644 --- a/crates/ide_completion/src/render/enum_variant.rs +++ b/crates/ide_completion/src/render/enum_variant.rs @@ -55,13 +55,12 @@ impl<'a> EnumRender<'a> { } fn render(self, import_to_add: Option) -> CompletionItem { - let mut builder = CompletionItem::new( + let mut item = CompletionItem::new( CompletionKind::Reference, self.ctx.source_range(), self.qualified_name.clone(), ); - builder - .kind(SymbolKind::Variant) + item.kind(SymbolKind::Variant) .set_documentation(self.variant.docs(self.ctx.db())) .set_deprecated(self.ctx.is_deprecated(self.variant)) .add_import(import_to_add) @@ -70,12 +69,12 @@ impl<'a> EnumRender<'a> { if self.variant_kind == StructKind::Tuple { cov_mark::hit!(inserts_parens_for_tuple_enums); let params = Params::Anonymous(self.variant.fields(self.ctx.db()).len()); - builder.add_call_parens(self.ctx.completion, self.short_qualified_name, params); + item.add_call_parens(self.ctx.completion, self.short_qualified_name, params); } else if self.path.is_some() { - builder.lookup_by(self.short_qualified_name); + item.lookup_by(self.short_qualified_name); } - builder.build() + item.build() } fn detail(&self) -> String { diff --git a/crates/ide_completion/src/render/function.rs b/crates/ide_completion/src/render/function.rs index 1e2f45f14..f4dabe3d1 100644 --- a/crates/ide_completion/src/render/function.rs +++ b/crates/ide_completion/src/render/function.rs @@ -41,13 +41,12 @@ impl<'a> FunctionRender<'a> { fn render(self, import_to_add: Option) -> CompletionItem { let params = self.params(); - let mut builder = CompletionItem::new( + let mut item = CompletionItem::new( CompletionKind::Reference, self.ctx.source_range(), self.name.clone(), ); - builder - .kind(self.kind()) + item.kind(self.kind()) .set_documentation(self.ctx.docs(self.func)) .set_deprecated( self.ctx.is_deprecated(self.func) || self.ctx.is_deprecated_assoc_item(self.func), @@ -56,7 +55,7 @@ impl<'a> FunctionRender<'a> { .add_call_parens(self.ctx.completion, self.name, params) .add_import(import_to_add); - builder.build() + item.build() } fn detail(&self) -> String { diff --git a/crates/ide_completion/src/render/macro_.rs b/crates/ide_completion/src/render/macro_.rs index 727f5e02e..3fa21ba7c 100644 --- a/crates/ide_completion/src/render/macro_.rs +++ b/crates/ide_completion/src/render/macro_.rs @@ -39,10 +39,9 @@ impl<'a> MacroRender<'a> { } fn render(&self, import_to_add: Option) -> Option { - let mut builder = + let mut item = CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), &self.label()); - builder - .kind(SymbolKind::Macro) + item.kind(SymbolKind::Macro) .set_documentation(self.docs.clone()) .set_deprecated(self.ctx.is_deprecated(self.macro_)) .add_import(import_to_add) @@ -53,18 +52,18 @@ impl<'a> MacroRender<'a> { Some(cap) if needs_bang => { let snippet = self.snippet(); let lookup = self.lookup(); - builder.insert_snippet(cap, snippet).lookup_by(lookup); + item.insert_snippet(cap, snippet).lookup_by(lookup); } None if needs_bang => { - builder.insert_text(self.banged_name()); + item.insert_text(self.banged_name()); } _ => { cov_mark::hit!(dont_insert_macro_call_parens_unncessary); - builder.insert_text(&self.name); + item.insert_text(&self.name); } }; - Some(builder.build()) + Some(item.build()) } fn needs_bang(&self) -> bool { diff --git a/crates/ide_completion/src/render/pattern.rs b/crates/ide_completion/src/render/pattern.rs index 4d8f2b17d..ca2926125 100644 --- a/crates/ide_completion/src/render/pattern.rs +++ b/crates/ide_completion/src/render/pattern.rs @@ -69,20 +69,19 @@ fn build_completion( ctx: RenderContext<'_>, name: String, pat: String, - item: impl HasAttrs + Copy, + def: impl HasAttrs + Copy, ) -> CompletionItem { - let mut completion = CompletionItem::new(CompletionKind::Snippet, ctx.source_range(), name); - completion - .kind(CompletionItemKind::Binding) - .set_documentation(ctx.docs(item)) - .set_deprecated(ctx.is_deprecated(item)) + let mut item = CompletionItem::new(CompletionKind::Snippet, ctx.source_range(), name); + item.kind(CompletionItemKind::Binding) + .set_documentation(ctx.docs(def)) + .set_deprecated(ctx.is_deprecated(def)) .detail(&pat); if let Some(snippet_cap) = ctx.snippet_cap() { - completion.insert_snippet(snippet_cap, pat); + item.insert_snippet(snippet_cap, pat); } else { - completion.insert_text(pat); + item.insert_text(pat); }; - completion.build() + item.build() } fn render_pat( -- cgit v1.2.3