From 4628d94e749f05a12ca51548a2c9afa2cc44ea84 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 16 Mar 2021 15:44:31 +0100 Subject: Remove ShortLabel --- crates/ide/src/display/navigation_target.rs | 30 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'crates/ide/src/display/navigation_target.rs') 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; use either::Either; use hir::{ AssocItem, Documentation, FieldSource, HasAttrs, HasSource, HirDisplay, InFile, ModuleSource, + Semantics, }; use ide_db::{ - base_db::{FileId, FileRange, SourceDatabase}, + base_db::{FileId, FileRange}, symbol_index::FileSymbolKind, SymbolKind, }; @@ -19,8 +20,6 @@ use syntax::{ use crate::FileSymbol; -use super::short_label::ShortLabel; - /// `NavigationTarget` represents and element in the editor's UI which you can /// click on to navigate to a particular piece of code. /// @@ -502,21 +501,22 @@ impl TryToNav for hir::ConstParam { /// /// e.g. `struct Name`, `enum Name`, `fn Name` pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option { - let parse = db.parse(symbol.file_id); - let node = symbol.ptr.to_node(parse.tree().syntax()); + let sema = Semantics::new(db); + let parse = sema.parse(symbol.file_id); + let node = symbol.ptr.to_node(parse.syntax()); match_ast! { match node { - ast::Fn(it) => it.short_label(), - ast::Struct(it) => it.short_label(), - ast::Enum(it) => it.short_label(), - ast::Trait(it) => it.short_label(), - ast::Module(it) => it.short_label(), - ast::TypeAlias(it) => it.short_label(), - ast::Const(it) => it.short_label(), - ast::Static(it) => it.short_label(), - ast::RecordField(it) => it.short_label(), - ast::Variant(it) => it.short_label(), + ast::Fn(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), + ast::Struct(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), + ast::Enum(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), + ast::Trait(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), + ast::Module(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), + ast::TypeAlias(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), + ast::Const(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), + ast::Static(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), + ast::RecordField(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), + ast::Variant(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), _ => None, } } -- cgit v1.2.3