From 7c855c940a5fdb5c942ddb3d3401c6e2dbbfca67 Mon Sep 17 00:00:00 2001 From: oxalica Date: Tue, 16 Mar 2021 00:58:42 +0800 Subject: Clean usage of ShortLabel --- crates/ide/src/display/navigation_target.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'crates/ide/src/display') diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index 198243466..69c3751a1 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs @@ -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 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 { 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) => { -- cgit v1.2.3