Improve parameter hints a bit & add emacs support

- just include the name, not e.g. `mut`
 - don't return empty hints (or `_`)
This commit is contained in:
Florian Diebold 2020-01-18 13:40:32 +01:00
parent d1d91dfe4d
commit 18ec4e3403
3 changed files with 38 additions and 23 deletions

View file

@ -169,9 +169,22 @@ impl From<&'_ ast::FnDef> for FunctionSignature {
res.push(self_param.syntax().text().to_string())
}
res.extend(param_list.params().map(|param| {
param.pat().map(|pat| pat.syntax().text().to_string()).unwrap_or_default()
}));
res.extend(
param_list
.params()
.map(|param| {
Some(
param
.pat()?
.syntax()
.descendants()
.find_map(ast::Name::cast)?
.text()
.to_string(),
)
})
.map(|param| param.unwrap_or_default()),
);
}
res
}