Skip to main content

IndentResolver

Trait IndentResolver 

Source
pub trait IndentResolver {
    // Required method
    fn levels_for_line(&self, line: u32) -> Option<i32>;
}
Expand description

IN.7: how deep should this line sit?

The = operator needs a per-line indent level, which only the tree-sitter engine can compute — and this crate is deliberately tree-sitter-agnostic (see its Cargo.toml). Same shape and same reason as ScopeResolver above: the grammar declares the question, the host injects something that can answer it, and nothing tree-shaped crosses the boundary.

None from levels_for_line means “no answer for this row” — no tree, no indents.scm for the language, a parse error, or a position inside a string. The operator leaves such lines untouched rather than guessing, so = over a range containing a broken region reindents what it understands and does not mangle the rest.

Required Methods§

Source

fn levels_for_line(&self, line: u32) -> Option<i32>

Indent depth in levels (not columns) for line.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§