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

Function skip_string_backward

src/completion/named_args.rs:202–224  ·  view source on GitHub ↗

Skip backward past a string literal ending at position `end` (which points to the closing quote character `q`). Returns the position of the opening quote, or 0 if not found.

(chars: &[char], end: usize, q: char)

Source from the content-addressed store, hash-verified

200///
201/// Returns the position of the opening quote, or 0 if not found.
202pub fn skip_string_backward(chars: &[char], end: usize, q: char) -> usize {
203 if end == 0 {
204 return 0;
205 }
206 let mut j = end - 1;
207 while j > 0 {
208 if chars[j] == q {
209 // Check it's not escaped
210 let mut backslashes = 0u32;
211 let mut k = j;
212 while k > 0 && chars[k - 1] == '\\' {
213 backslashes += 1;
214 k -= 1;
215 }
216 if backslashes.is_multiple_of(2) {
217 // Not escaped — this is the opening quote
218 return j;
219 }
220 }
221 j -= 1;
222 }
223 0
224}
225
226/// Extract the call expression that precedes the opening paren at `open`.
227///

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected