diff options
Diffstat (limited to 'crates/ide/src/display/navigation_target.rs')
-rw-r--r-- | crates/ide/src/display/navigation_target.rs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index 69c3751a1..c086de163 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs | |||
@@ -5,9 +5,10 @@ use std::fmt; | |||
5 | use either::Either; | 5 | use either::Either; |
6 | use hir::{ | 6 | use hir::{ |
7 | AssocItem, Documentation, FieldSource, HasAttrs, HasSource, HirDisplay, InFile, ModuleSource, | 7 | AssocItem, Documentation, FieldSource, HasAttrs, HasSource, HirDisplay, InFile, ModuleSource, |
8 | Semantics, | ||
8 | }; | 9 | }; |
9 | use ide_db::{ | 10 | use ide_db::{ |
10 | base_db::{FileId, FileRange, SourceDatabase}, | 11 | base_db::{FileId, FileRange}, |
11 | symbol_index::FileSymbolKind, | 12 | symbol_index::FileSymbolKind, |
12 | SymbolKind, | 13 | SymbolKind, |
13 | }; | 14 | }; |
@@ -19,8 +20,6 @@ use syntax::{ | |||
19 | 20 | ||
20 | use crate::FileSymbol; | 21 | use crate::FileSymbol; |
21 | 22 | ||
22 | use super::short_label::ShortLabel; | ||
23 | |||
24 | /// `NavigationTarget` represents and element in the editor's UI which you can | 23 | /// `NavigationTarget` represents and element in the editor's UI which you can |
25 | /// click on to navigate to a particular piece of code. | 24 | /// click on to navigate to a particular piece of code. |
26 | /// | 25 | /// |
@@ -502,21 +501,22 @@ impl TryToNav for hir::ConstParam { | |||
502 | /// | 501 | /// |
503 | /// e.g. `struct Name`, `enum Name`, `fn Name` | 502 | /// e.g. `struct Name`, `enum Name`, `fn Name` |
504 | pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option<String> { | 503 | pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option<String> { |
505 | let parse = db.parse(symbol.file_id); | 504 | let sema = Semantics::new(db); |
506 | let node = symbol.ptr.to_node(parse.tree().syntax()); | 505 | let parse = sema.parse(symbol.file_id); |
506 | let node = symbol.ptr.to_node(parse.syntax()); | ||
507 | 507 | ||
508 | match_ast! { | 508 | match_ast! { |
509 | match node { | 509 | match node { |
510 | ast::Fn(it) => it.short_label(), | 510 | ast::Fn(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), |
511 | ast::Struct(it) => it.short_label(), | 511 | ast::Struct(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), |
512 | ast::Enum(it) => it.short_label(), | 512 | ast::Enum(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), |
513 | ast::Trait(it) => it.short_label(), | 513 | ast::Trait(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), |
514 | ast::Module(it) => it.short_label(), | 514 | ast::Module(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), |
515 | ast::TypeAlias(it) => it.short_label(), | 515 | ast::TypeAlias(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), |
516 | ast::Const(it) => it.short_label(), | 516 | ast::Const(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), |
517 | ast::Static(it) => it.short_label(), | 517 | ast::Static(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), |
518 | ast::RecordField(it) => it.short_label(), | 518 | ast::RecordField(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), |
519 | ast::Variant(it) => it.short_label(), | 519 | ast::Variant(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), |
520 | _ => None, | 520 | _ => None, |
521 | } | 521 | } |
522 | } | 522 | } |