MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / parse_existing_args

Function parse_existing_args

src/completion/named_args.rs:371–394  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

369///
370/// Returns `(existing_named_args, positional_count)`.
371pub 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.

Callers 9

detect_named_arg_contextFunction · 0.85
no_argsFunction · 0.85
one_positionalFunction · 0.85
two_positionalFunction · 0.85
one_namedFunction · 0.85
multiple_namedFunction · 0.85
nested_call_in_argFunction · 0.85

Calls 4

split_args_top_levelFunction · 0.85
extract_named_arg_nameFunction · 0.85
pushMethod · 0.80
is_emptyMethod · 0.45

Tested by 7

no_argsFunction · 0.68
one_positionalFunction · 0.68
two_positionalFunction · 0.68
one_namedFunction · 0.68
multiple_namedFunction · 0.68
nested_call_in_argFunction · 0.68