Add ConstRender

This commit is contained in:
Igor Aleksanov 2020-11-01 12:59:43 +03:00
parent fc8a1cd800
commit 944ccf6075
5 changed files with 65 additions and 28 deletions

View file

@ -5,15 +5,17 @@ mod macro_;
mod function;
mod builder_ext;
mod enum_variant;
mod const_;
use hir::HasAttrs;
use hir::{Documentation, HasAttrs};
use ide_db::RootDatabase;
use syntax::TextRange;
use crate::{config::SnippetCap, CompletionContext};
pub(crate) use crate::render::{
enum_variant::EnumVariantRender, function::FunctionRender, macro_::MacroRender,
const_::ConstRender, enum_variant::EnumVariantRender, function::FunctionRender,
macro_::MacroRender,
};
#[derive(Debug)]
@ -41,6 +43,10 @@ impl<'a> RenderContext<'a> {
pub fn is_deprecated(&self, node: impl HasAttrs) -> bool {
node.attrs(self.db()).by_key("deprecated").exists()
}
pub fn docs(&self, node: impl HasAttrs) -> Option<Documentation> {
node.docs(self.db())
}
}
impl<'a> From<&'a CompletionContext<'a>> for RenderContext<'a> {