Skip to main content

ScopeResolver

Trait ScopeResolver 

Source
pub trait ScopeResolver {
    // Required methods
    fn scope_at(
        &self,
        line: u32,
        col_byte: u32,
        suffix: &str,
    ) -> Option<ProtoRange>;
    fn scope_toward(
        &self,
        line: u32,
        col_byte: u32,
        suffix: &str,
        dir: NavDir,
        boundary: NavBoundary,
        count: u32,
    ) -> Option<Position>;
}
Expand description

Resolves a tree-sitter scope near the cursor, for the structural text objects (af / ac / aa / …) and structural motions (]f / [c / …).

Defined here so lattice-grammar stays free of any tree-sitter dependency: the host implements it (backed by the buffer’s SyntaxSnapshot) and threads it in through GrammarEnv::scope_resolver to TextObjectContext and MotionContext. Introduced in N.1.4a.

Required Methods§

Source

fn scope_at(&self, line: u32, col_byte: u32, suffix: &str) -> Option<ProtoRange>

The innermost node at (line, col_byte) whose capture name ends with suffix (e.g. "function.outer"), as a byte-precise half-open [start, end) [ProtoRange] — byte columns, not just rows, so intra-line objects like aa / ia are charwise-accurate. End is exclusive, matching tree-sitter node ranges and the operator slice convention. None when there is no parse or no match.

Source

fn scope_toward( &self, line: u32, col_byte: u32, suffix: &str, dir: NavDir, boundary: NavBoundary, count: u32, ) -> Option<Position>

The count-th node whose capture name ends with suffix, in dir, targeting the node’s boundary. Respects the enclosing-object rule (see treesitter-motions.md §4.1): (Forward, Start) / (Backward, End) skip the object the cursor is inside; (Backward, Start) / (Forward, End) may land on the current object’s own boundary. Returns the target position, or None (no tree / no match / fewer than count candidates).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§