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.rs | 1 - crates/ide/src/display/navigation_target.rs | 14 ++++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/ide/src/display.rs b/crates/ide/src/display.rs index bae9e40df..1f7b665c0 100644 --- a/crates/ide/src/display.rs +++ b/crates/ide/src/display.rs @@ -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}; 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