aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAaron Loucks <[email protected]>2020-05-31 23:58:54 +0100
committerAaron Loucks <[email protected]>2020-05-31 23:58:54 +0100
commit1211a46826ee8a08683e4cfe151649efd6fd90fa (patch)
treeb27ad5f0b5edd0c14ce62dae9508d4683d4d13ea /crates
parentf7f01dd5f0a8254abeefb0156e2c4ebe1447bfb6 (diff)
Unsquish parameter types in tooltips for macro-generated functions
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/display/function_signature.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/ra_ide/src/display/function_signature.rs b/crates/ra_ide/src/display/function_signature.rs
index 9572debd8..b081ecaad 100644
--- a/crates/ra_ide/src/display/function_signature.rs
+++ b/crates/ra_ide/src/display/function_signature.rs
@@ -207,7 +207,18 @@ impl From<&'_ ast::FnDef> for FunctionSignature {
207 res.push(raw_param); 207 res.push(raw_param);
208 } 208 }
209 209
210 res.extend(param_list.params().map(|param| param.syntax().text().to_string())); 210 // macro-generated functions are missing whitespace
211 fn fmt_param(param: ast::Param) -> String {
212 let text = param.syntax().text().to_string();
213 match text.find(':') {
214 Some(pos) if 1 + pos < text.len() => {
215 format!("{} {}", &text[0..1 + pos].trim(), &text[1 + pos..].trim())
216 }
217 _ => text,
218 }
219 }
220
221 res.extend(param_list.params().map(fmt_param));
211 res_types.extend(param_list.params().map(|param| { 222 res_types.extend(param_list.params().map(|param| {
212 let param_text = param.syntax().text().to_string(); 223 let param_text = param.syntax().text().to_string();
213 match param_text.split(':').nth(1).and_then(|it| it.get(1..)) { 224 match param_text.split(':').nth(1).and_then(|it| it.get(1..)) {