diff options
author | Benjamin Coenen <[email protected]> | 2020-09-15 16:14:48 +0100 |
---|---|---|
committer | Benjamin Coenen <[email protected]> | 2020-09-15 16:15:33 +0100 |
commit | 2e91159cedcf8e2acd9f2f32523cce582a2b89ea (patch) | |
tree | 84c9dce351786bb338c5fb7140d9a27eb0d16e1d /crates/ide | |
parent | 7ba578ab1413505e960dda305cc322a29bc00ab3 (diff) |
inline parameters for a function description #6002
Signed-off-by: Benjamin Coenen <[email protected]>
Diffstat (limited to 'crates/ide')
-rw-r--r-- | crates/ide/src/completion/complete_qualified_path.rs | 22 | ||||
-rw-r--r-- | crates/ide/src/display.rs | 8 |
2 files changed, 29 insertions, 1 deletions
diff --git a/crates/ide/src/completion/complete_qualified_path.rs b/crates/ide/src/completion/complete_qualified_path.rs index 79de50792..00e89f0fd 100644 --- a/crates/ide/src/completion/complete_qualified_path.rs +++ b/crates/ide/src/completion/complete_qualified_path.rs | |||
@@ -730,4 +730,26 @@ fn f() {} | |||
730 | expect![[""]], | 730 | expect![[""]], |
731 | ); | 731 | ); |
732 | } | 732 | } |
733 | |||
734 | #[test] | ||
735 | fn completes_function() { | ||
736 | check( | ||
737 | r#" | ||
738 | fn foo( | ||
739 | a: i32, | ||
740 | b: i32 | ||
741 | ) { | ||
742 | |||
743 | } | ||
744 | |||
745 | fn main() { | ||
746 | fo<|> | ||
747 | } | ||
748 | "#, | ||
749 | expect![[r#" | ||
750 | fn foo(…) fn foo(a: i32, b: i32) | ||
751 | fn main() fn main() | ||
752 | "#]], | ||
753 | ); | ||
754 | } | ||
733 | } | 755 | } |
diff --git a/crates/ide/src/display.rs b/crates/ide/src/display.rs index 41b5bdc49..5bb065fc1 100644 --- a/crates/ide/src/display.rs +++ b/crates/ide/src/display.rs | |||
@@ -41,7 +41,13 @@ pub(crate) fn function_declaration(node: &ast::Fn) -> String { | |||
41 | format_to!(buf, "{}", type_params); | 41 | format_to!(buf, "{}", type_params); |
42 | } | 42 | } |
43 | if let Some(param_list) = node.param_list() { | 43 | if let Some(param_list) = node.param_list() { |
44 | format_to!(buf, "{}", param_list); | 44 | let mut params = match param_list.self_param() { |
45 | Some(self_param) => vec![self_param.to_string()], | ||
46 | None => vec![], | ||
47 | }; | ||
48 | params.extend(param_list.params().map(|param| param.to_string())); | ||
49 | // Useful to inline parameters | ||
50 | format_to!(buf, "({})", params.join(", ")); | ||
45 | } | 51 | } |
46 | if let Some(ret_type) = node.ret_type() { | 52 | if let Some(ret_type) = node.ret_type() { |
47 | if ret_type.ty().is_some() { | 53 | if ret_type.ty().is_some() { |