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

Function split_params

src/completion/phpdoc/helpers.rs:54–73  ·  view source on GitHub ↗

Split a parameter string on commas, respecting nested `()`, `<>`, `[]`, and `{}` delimiters. Returns borrowed slices into the input string.

(params_str: &str)

Source from the content-addressed store, hash-verified

52///
53/// Returns borrowed slices into the input string.
54pub(super) fn split_params(params_str: &str) -> Vec<&str> {
55 let mut result = Vec::new();
56 let mut depth = 0i32;
57 let mut start = 0;
58 let bytes = params_str.as_bytes();
59
60 for (i, &b) in bytes.iter().enumerate() {
61 match b {
62 b'(' | b'<' | b'[' | b'{' => depth += 1,
63 b')' | b'>' | b']' | b'}' => depth -= 1,
64 b',' if depth == 0 => {
65 result.push(&params_str[start..i]);
66 start = i + 1;
67 }
68 _ => {}
69 }
70 }
71 result.push(&params_str[start..]);
72 result
73}

Callers 2

parse_paramsFunction · 0.70
parse_paramsFunction · 0.70

Calls 2

iterMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected