aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroxalica <[email protected]>2021-03-15 16:58:42 +0000
committeroxalica <[email protected]>2021-03-15 17:05:56 +0000
commit7c855c940a5fdb5c942ddb3d3401c6e2dbbfca67 (patch)
treef017dd2e7df5bd14852917c2ed7bbbba2cbc5740
parent7101bada0f90eaf89718461affa583e1736f0099 (diff)
Clean usage of ShortLabel
-rw-r--r--crates/ide/src/display.rs1
-rw-r--r--crates/ide/src/display/navigation_target.rs14
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;
5mod short_label; 5mod short_label;
6 6
7pub(crate) use navigation_target::{ToNav, TryToNav}; 7pub(crate) use navigation_target::{ToNav, TryToNav};
8pub(crate) use short_label::ShortLabel;
9 8
10pub(crate) use syntax::display::{function_declaration, macro_label}; 9pub(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 @@
3use std::fmt; 3use std::fmt;
4 4
5use either::Either; 5use either::Either;
6use hir::{AssocItem, Documentation, FieldSource, HasAttrs, HasSource, InFile, ModuleSource}; 6use hir::{
7 AssocItem, Documentation, FieldSource, HasAttrs, HasSource, HirDisplay, InFile, ModuleSource,
8};
7use ide_db::{ 9use ide_db::{
8 base_db::{FileId, FileRange, SourceDatabase}, 10 base_db::{FileId, FileRange, SourceDatabase},
9 symbol_index::FileSymbolKind, 11 symbol_index::FileSymbolKind,
@@ -98,7 +100,7 @@ impl NavigationTarget {
98 SymbolKind::Module, 100 SymbolKind::Module,
99 ); 101 );
100 res.docs = module.attrs(db).docs(); 102 res.docs = module.attrs(db).docs();
101 res.description = src.value.short_label(); 103 res.description = Some(module.display(db).to_string());
102 return res; 104 return res;
103 } 105 }
104 module.to_nav(db) 106 module.to_nav(db)
@@ -251,8 +253,8 @@ impl ToNavFromAst for hir::Trait {
251 253
252impl<D> TryToNav for D 254impl<D> TryToNav for D
253where 255where
254 D: HasSource + ToNavFromAst + Copy + HasAttrs, 256 D: HasSource + ToNavFromAst + Copy + HasAttrs + HirDisplay,
255 D::Ast: ast::NameOwner + ShortLabel, 257 D::Ast: ast::NameOwner,
256{ 258{
257 fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> { 259 fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
258 let src = self.source(db)?; 260 let src = self.source(db)?;
@@ -262,7 +264,7 @@ where
262 D::KIND, 264 D::KIND,
263 ); 265 );
264 res.docs = self.docs(db); 266 res.docs = self.docs(db);
265 res.description = src.value.short_label(); 267 res.description = Some(self.display(db).to_string());
266 Some(res) 268 Some(res)
267 } 269 }
268} 270}
@@ -317,7 +319,7 @@ impl TryToNav for hir::Field {
317 let mut res = 319 let mut res =
318 NavigationTarget::from_named(db, src.with_value(it), SymbolKind::Field); 320 NavigationTarget::from_named(db, src.with_value(it), SymbolKind::Field);
319 res.docs = self.docs(db); 321 res.docs = self.docs(db);
320 res.description = it.short_label(); 322 res.description = Some(self.display(db).to_string());
321 res 323 res
322 } 324 }
323 FieldSource::Pos(it) => { 325 FieldSource::Pos(it) => {