aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/hover.rs24
1 files changed, 5 insertions, 19 deletions
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs
index d427ed46b..c32665142 100644
--- a/crates/ra_ide/src/hover.rs
+++ b/crates/ra_ide/src/hover.rs
@@ -73,20 +73,6 @@ pub struct HoverResult {
73 pub actions: Vec<HoverAction>, 73 pub actions: Vec<HoverAction>,
74} 74}
75 75
76impl HoverResult {
77 pub fn new() -> HoverResult {
78 Self::default()
79 }
80
81 pub fn is_empty(&self) -> bool {
82 self.markup.is_empty()
83 }
84
85 fn push_action(&mut self, action: HoverAction) {
86 self.actions.push(action);
87 }
88}
89
90// Feature: Hover 76// Feature: Hover
91// 77//
92// Shows additional information, like type of an expression or documentation for definition when "focusing" code. 78// Shows additional information, like type of an expression or documentation for definition when "focusing" code.
@@ -97,7 +83,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
97 let token = pick_best(file.token_at_offset(position.offset))?; 83 let token = pick_best(file.token_at_offset(position.offset))?;
98 let token = sema.descend_into_macros(token); 84 let token = sema.descend_into_macros(token);
99 85
100 let mut res = HoverResult::new(); 86 let mut res = HoverResult::default();
101 87
102 let node = token.parent(); 88 let node = token.parent();
103 let definition = match_ast! { 89 let definition = match_ast! {
@@ -111,17 +97,17 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
111 if let Some(text) = hover_for_definition(db, definition) { 97 if let Some(text) = hover_for_definition(db, definition) {
112 res.markup.push_section(&text); 98 res.markup.push_section(&text);
113 } 99 }
114 if !res.is_empty() { 100 if !res.markup.is_empty() {
115 if let Some(action) = show_implementations_action(db, definition) { 101 if let Some(action) = show_implementations_action(db, definition) {
116 res.push_action(action); 102 res.actions.push(action);
117 } 103 }
118 104
119 if let Some(action) = runnable_action(&sema, definition, position.file_id) { 105 if let Some(action) = runnable_action(&sema, definition, position.file_id) {
120 res.push_action(action); 106 res.actions.push(action);
121 } 107 }
122 108
123 if let Some(action) = goto_type_action(db, definition) { 109 if let Some(action) = goto_type_action(db, definition) {
124 res.push_action(action); 110 res.actions.push(action);
125 } 111 }
126 112
127 let range = sema.original_range(&node).range; 113 let range = sema.original_range(&node).range;