mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
simplify
This commit is contained in:
parent
d74a77efb1
commit
16dcf020c4
1 changed files with 11 additions and 9 deletions
|
@ -113,31 +113,33 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
|
||||||
|
|
||||||
let mut res = HoverResult::new();
|
let mut res = HoverResult::new();
|
||||||
|
|
||||||
if let Some((node, name_kind)) = match_ast! {
|
let node = token.parent();
|
||||||
match (token.parent()) {
|
let definition = match_ast! {
|
||||||
|
match node {
|
||||||
ast::NameRef(name_ref) => {
|
ast::NameRef(name_ref) => {
|
||||||
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) => {
|
ast::Name(name) => {
|
||||||
classify_name(&sema, &name).map(|d| (name.syntax().clone(), d.definition()))
|
classify_name(&sema, &name).map(|d| d.definition())
|
||||||
},
|
},
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
} {
|
};
|
||||||
|
if let Some(definition) = definition {
|
||||||
let range = sema.original_range(&node).range;
|
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);
|
res.results.push(text);
|
||||||
}
|
}
|
||||||
if !res.is_empty() {
|
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);
|
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);
|
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);
|
res.push_action(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue