aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-09 09:03:28 +0100
committerAleksey Kladov <[email protected]>2020-07-09 09:03:28 +0100
commit3a26752c665111499b01c34b90aadd94afcd8b28 (patch)
tree1e091ce4bd61245c48e017ff1bbd0ce4a9dbff2f
parent22269c67b87448a18d7772eaba0a10e595bcf50d (diff)
Reduce API
-rw-r--r--crates/ra_ide/src/hover.rs6
-rw-r--r--crates/ra_ide/src/markup.rs15
2 files changed, 8 insertions, 13 deletions
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs
index 79ed30388..9b4804906 100644
--- a/crates/ra_ide/src/hover.rs
+++ b/crates/ra_ide/src/hover.rs
@@ -93,9 +93,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
93 }; 93 };
94 if let Some(definition) = definition { 94 if let Some(definition) = definition {
95 if let Some(text) = hover_for_definition(db, definition) { 95 if let Some(text) = hover_for_definition(db, definition) {
96 res.markup.push_section(&text); 96 res.markup = text.into();
97 }
98 if !res.markup.is_empty() {
99 if let Some(action) = show_implementations_action(db, definition) { 97 if let Some(action) = show_implementations_action(db, definition) {
100 res.actions.push(action); 98 res.actions.push(action);
101 } 99 }
@@ -128,7 +126,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
128 } 126 }
129 }; 127 };
130 128
131 res.markup.push_section(&rust_code_markup(&ty.display(db))); 129 res.markup = rust_code_markup(&ty.display(db)).into();
132 let range = sema.original_range(&node).range; 130 let range = sema.original_range(&node).range;
133 Some(RangeInfo::new(range, res)) 131 Some(RangeInfo::new(range, res))
134} 132}
diff --git a/crates/ra_ide/src/markup.rs b/crates/ra_ide/src/markup.rs
index 2f2b3cc25..212ca80b7 100644
--- a/crates/ra_ide/src/markup.rs
+++ b/crates/ra_ide/src/markup.rs
@@ -16,6 +16,12 @@ impl From<Markup> for String {
16 } 16 }
17} 17}
18 18
19impl From<String> for Markup {
20 fn from(text: String) -> Self {
21 Markup { text }
22 }
23}
24
19impl fmt::Display for Markup { 25impl fmt::Display for Markup {
20 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 26 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21 fmt::Display::fmt(&self.text, f) 27 fmt::Display::fmt(&self.text, f)
@@ -26,13 +32,4 @@ impl Markup {
26 pub fn as_str(&self) -> &str { 32 pub fn as_str(&self) -> &str {
27 self.text.as_str() 33 self.text.as_str()
28 } 34 }
29 pub fn is_empty(&self) -> bool {
30 self.text.is_empty()
31 }
32 pub fn push_section(&mut self, section: &str) {
33 if !self.text.is_empty() {
34 self.text.push_str("\n\n___\n");
35 }
36 self.text.push_str(section);
37 }
38} 35}