Skip to main content

Module edit_apply

Module edit_apply 

Source
Expand description

Shared headless apply path for symbol-body edits (spec v2a §5.1).

local_range_write is the Trait-default for replace_symbol_body / insert_before_symbol / insert_after_symbol: it writes a resolved range to disk atomically, so edits work without any running language server / IDE. JetBrainsHttpBackend overrides the Trait methods with the in-IDE HTTP path; both paths apply the same tree-sitter range → byte-identical result.

Structs§

HeadlessBackend
Zero-dependency backend that carries only the Trait default-apply for the three edit methods (used by ctx_refactor when no IDE is reachable). The five mandatory read methods are unsupported here (edits never call them).

Functions§

local_range_write
Apply a resolved RangeEdit to disk (headless). Reads the file, optionally verifies expected_hash against the current bytes covered by range (mismatch → CONFLICT), replaces the range with text, writes atomically, and returns the post-edit range + a compact diff.
offset_of
Convert a 0-based (line, character) coordinate to a byte offset into content. line/character count UTF-8 bytes per line (wire convention here is byte columns, matching how Rust slices &str). Out-of-range → Err.
overview_from_index
Build a file’s structure overview from the tree-sitter symbol index (headless symbols_overview default, spec v2a §5.2). Best-effort: returns an empty vec when no graph is available.