Parse the arguments text between `(` and the cursor to determine: - Which parameter names have already been used as named arguments - How many positional (non-named) arguments precede the cursor Returns `(existing_named_args, positional_count)`.
(args_text: &str)
| 369 | /// |
| 370 | /// Returns `(existing_named_args, positional_count)`. |
| 371 | pub fn parse_existing_args(args_text: &str) -> (Vec<String>, usize) { |
| 372 | let mut named = Vec::new(); |
| 373 | let mut positional = 0usize; |
| 374 | |
| 375 | // Split by commas at the top level (respecting nested parens/strings) |
| 376 | let args = split_args_top_level(args_text); |
| 377 | |
| 378 | for arg in &args { |
| 379 | let trimmed = arg.trim(); |
| 380 | if trimmed.is_empty() { |
| 381 | continue; |
| 382 | } |
| 383 | |
| 384 | // Check if this argument is a named argument: `name: value` |
| 385 | // Named args look like `identifier:` (but NOT `::`) |
| 386 | if let Some(name) = extract_named_arg_name(trimmed) { |
| 387 | named.push(name); |
| 388 | } else { |
| 389 | positional += 1; |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | (named, positional) |
| 394 | } |
| 395 | |
| 396 | /// Split argument text by commas at the top level (depth 0), respecting |
| 397 | /// nested parentheses and string literals. |