Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide_assists/src/utils.rs')
| -rw-r--r-- | crates/ide_assists/src/utils.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/crates/ide_assists/src/utils.rs b/crates/ide_assists/src/utils.rs index 3d4ab968fb..c1092b97c2 100644 --- a/crates/ide_assists/src/utils.rs +++ b/crates/ide_assists/src/utils.rs @@ -525,3 +525,19 @@ pub(crate) fn trimmed_text_range(source_file: &SourceFile, initial_range: TextRa } trimmed_range } + +/// Convert a list of function params to a list of arguments that can be passed +/// into a function call. +pub(crate) fn convert_param_list_to_arg_list(list: ast::ParamList) -> ast::ArgList { + let mut args = vec![]; + for param in list.params() { + if let Some(ast::Pat::IdentPat(pat)) = param.pat() { + if let Some(name) = pat.name() { + let name = name.to_string(); + let expr = make::expr_path(make::ext::ident_path(&name)); + args.push(expr); + } + } + } + make::arg_list(args) +} |