aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-08 19:26:20 +0100
committerAleksey Kladov <[email protected]>2020-07-08 19:35:54 +0100
commit16dcf020c47a4e386c667c6da4815686916fc0cf (patch)
tree3b025e3fee7a76ec763c15e430356b9d1654ac30 /crates/ra_ide
parentd74a77efb19c5f3c45a09bd8ccd5b50d453927d1 (diff)
simplify
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/hover.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs
index 98be22339..61359c770 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<RangeIn
113 113
114 let mut res = HoverResult::new(); 114 let mut res = HoverResult::new();
115 115
116 if let Some((node, name_kind)) = match_ast! { 116 let node = token.parent();
117 match (token.parent()) { 117 let definition = match_ast! {
118 match node {
118 ast::NameRef(name_ref) => { 119 ast::NameRef(name_ref) => {
119 classify_name_ref(&sema, &name_ref).map(|d| (name_ref.syntax().clone(), d.definition())) 120 classify_name_ref(&sema, &name_ref).map(|d| d.definition())
120 }, 121 },
121 ast::Name(name) => { 122 ast::Name(name) => {
122 classify_name(&sema, &name).map(|d| (name.syntax().clone(), d.definition())) 123 classify_name(&sema, &name).map(|d| d.definition())
123 }, 124 },
124 _ => None, 125 _ => None,
125 } 126 }
126 } { 127 };
128 if let Some(definition) = definition {
127 let range = sema.original_range(&node).range; 129 let range = sema.original_range(&node).range;
128 if let Some(text) = hover_text_from_name_kind(db, name_kind) { 130 if let Some(text) = hover_text_from_name_kind(db, definition) {
129 res.results.push(text); 131 res.results.push(text);
130 } 132 }
131 if !res.is_empty() { 133 if !res.is_empty() {
132 if let Some(action) = show_implementations_action(db, name_kind) { 134 if let Some(action) = show_implementations_action(db, definition) {
133 res.push_action(action); 135 res.push_action(action);
134 } 136 }
135 137
136 if let Some(action) = runnable_action(&sema, name_kind, position.file_id) { 138 if let Some(action) = runnable_action(&sema, definition, position.file_id) {
137 res.push_action(action); 139 res.push_action(action);
138 } 140 }
139 141
140 if let Some(action) = goto_type_action(db, name_kind) { 142 if let Some(action) = goto_type_action(db, definition) {
141 res.push_action(action); 143 res.push_action(action);
142 } 144 }
143 145