mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-22 11:24:24 +00:00
maybe this is better??
This commit is contained in:
parent
4fbc4b9356
commit
312eafe916
4 changed files with 30 additions and 18 deletions
|
@ -1,6 +1,6 @@
|
|||
//! Logic for rendering the different hover messages
|
||||
use either::Either;
|
||||
use hir::{AsAssocItem, HasAttrs, HasSource, HirDisplay, Semantics, TypeInfo};
|
||||
use hir::{AsAssocItem, Const, HasAttrs, HasSource, HirDisplay, Semantics, TypeInfo};
|
||||
use ide_db::{
|
||||
base_db::SourceDatabase,
|
||||
defs::Definition,
|
||||
|
@ -352,7 +352,7 @@ pub(super) fn definition(
|
|||
Definition::Function(it) => label_and_docs(db, it),
|
||||
Definition::Adt(it) => label_and_docs(db, it),
|
||||
Definition::Variant(it) => label_and_docs(db, it),
|
||||
Definition::Const(it) => label_and_docs(db, it),
|
||||
Definition::Const(it) => const_label_value_and_docs(db, it),
|
||||
Definition::Static(it) => label_and_docs(db, it),
|
||||
Definition::Trait(it) => label_and_docs(db, it),
|
||||
Definition::TypeAlias(it) => label_and_docs(db, it),
|
||||
|
@ -381,6 +381,21 @@ where
|
|||
(label, docs)
|
||||
}
|
||||
|
||||
fn const_label_value_and_docs(
|
||||
db: &RootDatabase,
|
||||
konst: Const,
|
||||
) -> (String, Option<hir::Documentation>) {
|
||||
let label = if let Some(expr) = konst.value(db) {
|
||||
format!("{} = {}", konst.display(db), expr)
|
||||
} else {
|
||||
konst.display(db).to_string()
|
||||
};
|
||||
|
||||
let docs = konst.attrs(db).docs();
|
||||
|
||||
(label, docs)
|
||||
}
|
||||
|
||||
fn definition_mod_path(db: &RootDatabase, def: &Definition) -> Option<String> {
|
||||
if let Definition::GenericParam(_) = def {
|
||||
return None;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue