Expand description
Pure edit engine for griz.
Everything here computes; nothing here writes. A caller hands the engine
operations and a way to read files, and gets back a Plan: the exact
before and after text of every file, one Edit per change with the
Confidence it was matched at, and every Problem that stopped an
operation. Writing a plan to disk belongs to griz-store.
Structs§
- Anchor
- Text that locates an edit inside a file. A plain string is accepted as
shorthand for
{ text }. - Byte
Range - A half-open byte range
[start, end)in a file’s text. - Content
Hash Cache - An owned SHA-256 result cache with a byte capacity chosen by its caller.
- Create
File - Creates a new, empty file.
- Delete
File - Deletes a file.
- Diff
Item - One named definition a diff added, removed, or changed.
- Disk
Source - Reads files from disk.
- Edit
- One change the plan makes.
- File
Change - The planned before and after state of one file.
- File
Diff - The diff of one file.
- File
Summary - A matching file, its match count, and the fingerprint searched.
- File
Syntax - Parse facts for one file’s before and after text, in an enabled language.
- Find
Files Page - One page of matching files.
- Find
Page - One page of matches.
- Find
Query - What to search and where.
- MapSource
- Reads recorded file text, so a plan can be rebuilt against the exact bases it was first computed from.
- Match
- One match, carrying everything needed to edit exactly this text later.
- Patch
Error - Why patch text could not be parsed.
- Pattern
Locator - A structural pattern that locates an edit inside one file.
- Plan
- The complete, unwritten result of a set of operations.
- Position
- A 0-based line and character inside a file.
- Problem
- One operation that could not be planned.
- Range
- A half-open
[start, end)span of positions. - Rename
File - Renames a file. Becomes [
Op::Move]. - Syntax
Position - 1-based line and column of a syntax error or missing node.
- Text
Document Edit - Every edit to one file, applied together against its original text.
- Text
Document Identifier - Identifies the file a
TextDocumentEditchanges. - Text
Edit - One text change within a file.
- Window
- A line-numbered excerpt of real file text.
- Workspace
Edit - A workspace-wide edit from another tool.
Enums§
- Change
Kind - What a file change does.
- Confidence
- How sure the engine is that an edit landed where the caller meant.
- Document
Change - One entry of
documentChanges: edits to a file’s text, or a resource operation on it. A resource operation carries akindofcreate,rename, ordelete; a text edit carries none, which is how the two are told apart on the wire. - Item
Change - What happened to one named definition between before and after.
- Merge
Outcome - Result of merging a planned change onto a file that moved on.
- Occurrence
- Which matches of an anchor an operation targets.
- Op
- One requested change.
- Plan
Syntax - A plan’s overall syntax verdict, derived from every file’s
FileSyntax. - Position
Encoding - How a position’s
charactercounts into a line. - Problem
Kind - Why an operation could not be planned.
- Rung
- The matching rung that located an edit.
- Workspace
Edit Error - Why a
WorkspaceEditcould not become operations.
Traits§
- Source
- Reads the current text of a file, or
Nonewhen it does not exist.
Functions§
- annotate
- Parse facts for every changed file in an enabled language.
- build_
plan - Plans
opsin order againstsource. - content_
hash - Returns the lowercase hex SHA-256 of
text. - content_
hash_ bytes - Returns the lowercase hex SHA-256 of bytes.
- diff_
items - Named definitions
beforeandafterdisagree on, forpath’s language. Empty for a disabled language or with nothing named. - find
- Runs a query.
- find_
files - Searches with the same filters as
super::find, paging by matching file. - parse_
patch - Parses patch text into operations, resolving each path with
resolve. - plan_
syntax - The plan-wide verdict over already-computed per-file facts.
- render_
diff - Renders every change as a unified diff, naming files relative to
basewhen they are inside it. - three_
way - Merges the plan’s change (
basetoplanned) ontocurrent. - workspace_
edit_ to_ ops - Converts
editinto operations, resolving positions against each file’s text as read throughsource. Every text operation carriesexpect_hashfor the text it was converted against, so a file changed since is refused as stale when the plan is built.document_changesis preferred overchangeswhen both are given, matching the LSP client preference.