inline parameters for a function description #6002
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
This commit is contained in:
parent
7ba578ab14
commit
2e91159ced
@ -730,4 +730,26 @@ fn f() {}
|
|||||||
expect![[""]],
|
expect![[""]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn completes_function() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
fn foo(
|
||||||
|
a: i32,
|
||||||
|
b: i32
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
fo<|>
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
fn foo(…) fn foo(a: i32, b: i32)
|
||||||
|
fn main() fn main()
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,13 @@ pub(crate) fn function_declaration(node: &ast::Fn) -> String {
|
|||||||
format_to!(buf, "{}", type_params);
|
format_to!(buf, "{}", type_params);
|
||||||
}
|
}
|
||||||
if let Some(param_list) = node.param_list() {
|
if let Some(param_list) = node.param_list() {
|
||||||
format_to!(buf, "{}", param_list);
|
let mut params = match param_list.self_param() {
|
||||||
|
Some(self_param) => vec![self_param.to_string()],
|
||||||
|
None => vec![],
|
||||||
|
};
|
||||||
|
params.extend(param_list.params().map(|param| param.to_string()));
|
||||||
|
// Useful to inline parameters
|
||||||
|
format_to!(buf, "({})", params.join(", "));
|
||||||
}
|
}
|
||||||
if let Some(ret_type) = node.ret_type() {
|
if let Some(ret_type) = node.ret_type() {
|
||||||
if ret_type.ty().is_some() {
|
if ret_type.ty().is_some() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user