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

Function variable_range_without_sigil

src/linked_editing.rs:262–270  ·  view source on GitHub ↗

Convert a byte range for a `$varName` token into an LSP [`Range`] that excludes the leading `$` sigil. The `$` is skipped by advancing `start` by one byte. This is safe because `$` is a single-byte ASCII character and all PHP source files are UTF-8 (or ASCII-compatible).

(content: &str, start: usize, end: usize)

Source from the content-addressed store, hash-verified

260/// because `$` is a single-byte ASCII character and all PHP source
261/// files are UTF-8 (or ASCII-compatible).
262fn variable_range_without_sigil(content: &str, start: usize, end: usize) -> Range {
263 // Skip the `$` at the start of the token.
264 let name_start = start + 1;
265 debug_assert!(
266 name_start <= end,
267 "variable token too short to have a name after $"
268 );
269 byte_range_to_lsp_range(content, name_start, end)
270}
271
272/// Collect all LSP [`Range`]s for a variable within the definition
273/// region that contains `cursor_offset`.

Callers 1

Calls 1

byte_range_to_lsp_rangeFunction · 0.85

Tested by

no test coverage detected