From 2a214e15d38c7d97243e23e5e26fee5f4e26bb50 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Sun, 1 Nov 2020 13:48:42 +0300 Subject: Add doc-comments to the new files --- crates/completion/src/render.rs | 2 ++ crates/completion/src/render/const_.rs | 2 ++ crates/completion/src/render/enum_variant.rs | 2 ++ crates/completion/src/render/function.rs | 2 ++ crates/completion/src/render/macro_.rs | 8 +++++++- crates/completion/src/render/type_alias.rs | 2 ++ 6 files changed, 17 insertions(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/completion/src/render.rs b/crates/completion/src/render.rs index d78877421..dd9edc514 100644 --- a/crates/completion/src/render.rs +++ b/crates/completion/src/render.rs @@ -23,11 +23,13 @@ pub(crate) use crate::render::{ macro_::MacroRender, type_alias::TypeAliasRender, }; +/// Generic renderer for completion items. #[derive(Debug)] pub(crate) struct Render<'a> { ctx: RenderContext<'a>, } +/// Interface for data and methods required for items rendering. #[derive(Debug)] pub(crate) struct RenderContext<'a> { completion: &'a CompletionContext<'a>, diff --git a/crates/completion/src/render/const_.rs b/crates/completion/src/render/const_.rs index 829eb574d..3a1954211 100644 --- a/crates/completion/src/render/const_.rs +++ b/crates/completion/src/render/const_.rs @@ -1,3 +1,5 @@ +//! Renderer for `const` fields. + use hir::HasSource; use syntax::{ ast::{Const, NameOwner}, diff --git a/crates/completion/src/render/enum_variant.rs b/crates/completion/src/render/enum_variant.rs index bc96cc303..f8b151318 100644 --- a/crates/completion/src/render/enum_variant.rs +++ b/crates/completion/src/render/enum_variant.rs @@ -1,3 +1,5 @@ +//! Renderer for `enum` variants. + use hir::{HasAttrs, HirDisplay, ModPath, StructKind}; use itertools::Itertools; use test_utils::mark; diff --git a/crates/completion/src/render/function.rs b/crates/completion/src/render/function.rs index cf3852bf6..9d9bbe309 100644 --- a/crates/completion/src/render/function.rs +++ b/crates/completion/src/render/function.rs @@ -1,3 +1,5 @@ +//! Renderer for function calls. + use hir::{HasSource, Type}; use syntax::{ast::Fn, display::function_declaration}; diff --git a/crates/completion/src/render/macro_.rs b/crates/completion/src/render/macro_.rs index 6df121c66..066185559 100644 --- a/crates/completion/src/render/macro_.rs +++ b/crates/completion/src/render/macro_.rs @@ -1,3 +1,5 @@ +//! Renderer for macro invocations. + use hir::{Documentation, HasSource}; use syntax::display::macro_label; use test_utils::mark; @@ -66,7 +68,11 @@ impl<'a> MacroRender<'a> { } fn label(&self) -> String { - format!("{}!{}…{}", self.name, self.bra, self.ket) + if self.needs_bang() && self.ctx.snippet_cap().is_some() { + format!("{}!{}…{}", self.name, self.bra, self.ket) + } else { + self.banged_name() + } } fn snippet(&self) -> String { diff --git a/crates/completion/src/render/type_alias.rs b/crates/completion/src/render/type_alias.rs index 378aa8c67..50a6d06c2 100644 --- a/crates/completion/src/render/type_alias.rs +++ b/crates/completion/src/render/type_alias.rs @@ -1,3 +1,5 @@ +//! Renderer for type aliases. + use hir::HasSource; use syntax::{ ast::{NameOwner, TypeAlias}, -- cgit v1.2.3