From 16dcf020c47a4e386c667c6da4815686916fc0cf Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 8 Jul 2020 20:26:20 +0200 Subject: [PATCH] simplify --- crates/ra_ide/src/hover.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index 98be223395..61359c7702 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -113,31 +113,33 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option { - classify_name_ref(&sema, &name_ref).map(|d| (name_ref.syntax().clone(), d.definition())) + classify_name_ref(&sema, &name_ref).map(|d| d.definition()) }, ast::Name(name) => { - classify_name(&sema, &name).map(|d| (name.syntax().clone(), d.definition())) + classify_name(&sema, &name).map(|d| d.definition()) }, _ => None, } - } { + }; + if let Some(definition) = definition { let range = sema.original_range(&node).range; - if let Some(text) = hover_text_from_name_kind(db, name_kind) { + if let Some(text) = hover_text_from_name_kind(db, definition) { res.results.push(text); } if !res.is_empty() { - if let Some(action) = show_implementations_action(db, name_kind) { + if let Some(action) = show_implementations_action(db, definition) { res.push_action(action); } - if let Some(action) = runnable_action(&sema, name_kind, position.file_id) { + if let Some(action) = runnable_action(&sema, definition, position.file_id) { res.push_action(action); } - if let Some(action) = goto_type_action(db, name_kind) { + if let Some(action) = goto_type_action(db, definition) { res.push_action(action); }