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

Method find_enclosing_scope

src/symbol_map/mod.rs:529–537  ·  view source on GitHub ↗

Find the innermost scope that contains `offset`. Returns the `scope_start` (opening brace offset) of the innermost function/method/closure body that contains the cursor, or `0` when the cursor is in top-level code.

(&self, offset: u32)

Source from the content-addressed store, hash-verified

527 /// function/method/closure body that contains the cursor, or `0` when
528 /// the cursor is in top-level code.
529 pub fn find_enclosing_scope(&self, offset: u32) -> u32 {
530 let mut best: u32 = 0;
531 for &(start, end) in &self.scopes {
532 if start <= offset && offset <= end && start > best {
533 best = start;
534 }
535 }
536 best
537 }
538
539 /// Determine the effective scope for a variable reference at `offset`.
540 ///

Calls

no outgoing calls