Clean usage of ShortLabel

This commit is contained in:
oxalica 2021-03-16 00:58:42 +08:00
parent 7101bada0f
commit 7c855c940a
No known key found for this signature in database
GPG key ID: CED392DE0C483D00
2 changed files with 8 additions and 7 deletions

View file

@ -5,6 +5,5 @@ pub(crate) mod navigation_target;
mod short_label;
pub(crate) use navigation_target::{ToNav, TryToNav};
pub(crate) use short_label::ShortLabel;
pub(crate) use syntax::display::{function_declaration, macro_label};

View file

@ -3,7 +3,9 @@
use std::fmt;
use either::Either;
use hir::{AssocItem, Documentation, FieldSource, HasAttrs, HasSource, InFile, ModuleSource};
use hir::{
AssocItem, Documentation, FieldSource, HasAttrs, HasSource, HirDisplay, InFile, ModuleSource,
};
use ide_db::{
base_db::{FileId, FileRange, SourceDatabase},
symbol_index::FileSymbolKind,
@ -98,7 +100,7 @@ impl NavigationTarget {
SymbolKind::Module,
);
res.docs = module.attrs(db).docs();
res.description = src.value.short_label();
res.description = Some(module.display(db).to_string());
return res;
}
module.to_nav(db)
@ -251,8 +253,8 @@ impl ToNavFromAst for hir::Trait {
impl<D> TryToNav for D
where
D: HasSource + ToNavFromAst + Copy + HasAttrs,
D::Ast: ast::NameOwner + ShortLabel,
D: HasSource + ToNavFromAst + Copy + HasAttrs + HirDisplay,
D::Ast: ast::NameOwner,
{
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
let src = self.source(db)?;
@ -262,7 +264,7 @@ where
D::KIND,
);
res.docs = self.docs(db);
res.description = src.value.short_label();
res.description = Some(self.display(db).to_string());
Some(res)
}
}
@ -317,7 +319,7 @@ impl TryToNav for hir::Field {
let mut res =
NavigationTarget::from_named(db, src.with_value(it), SymbolKind::Field);
res.docs = self.docs(db);
res.description = it.short_label();
res.description = Some(self.display(db).to_string());
res
}
FieldSource::Pos(it) => {