Skip to main content

Crate griz_core

Crate griz_core 

Source
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 }.
ByteRange
A half-open byte range [start, end) in a file’s text.
ContentHashCache
An owned SHA-256 result cache with a byte capacity chosen by its caller.
CreateFile
Creates a new, empty file.
DeleteFile
Deletes a file.
DiffItem
One named definition a diff added, removed, or changed.
DiskSource
Reads files from disk.
Edit
One change the plan makes.
FileChange
The planned before and after state of one file.
FileDiff
The diff of one file.
FileSummary
A matching file, its match count, and the fingerprint searched.
FileSyntax
Parse facts for one file’s before and after text, in an enabled language.
FindFilesPage
One page of matching files.
FindPage
One page of matches.
FindQuery
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.
PatchError
Why patch text could not be parsed.
PatternLocator
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.
RenameFile
Renames a file. Becomes [Op::Move].
SyntaxPosition
1-based line and column of a syntax error or missing node.
TextDocumentEdit
Every edit to one file, applied together against its original text.
TextDocumentIdentifier
Identifies the file a TextDocumentEdit changes.
TextEdit
One text change within a file.
Window
A line-numbered excerpt of real file text.
WorkspaceEdit
A workspace-wide edit from another tool.

Enums§

ChangeKind
What a file change does.
Confidence
How sure the engine is that an edit landed where the caller meant.
DocumentChange
One entry of documentChanges: edits to a file’s text, or a resource operation on it. A resource operation carries a kind of create, rename, or delete; a text edit carries none, which is how the two are told apart on the wire.
ItemChange
What happened to one named definition between before and after.
MergeOutcome
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.
PlanSyntax
A plan’s overall syntax verdict, derived from every file’s FileSyntax.
PositionEncoding
How a position’s character counts into a line.
ProblemKind
Why an operation could not be planned.
Rung
The matching rung that located an edit.
WorkspaceEditError
Why a WorkspaceEdit could not become operations.

Traits§

Source
Reads the current text of a file, or None when it does not exist.

Functions§

annotate
Parse facts for every changed file in an enabled language.
build_plan
Plans ops in order against source.
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 before and after disagree on, for path’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 base when they are inside it.
three_way
Merges the plan’s change (base to planned) onto current.
workspace_edit_to_ops
Converts edit into operations, resolving positions against each file’s text as read through source. Every text operation carries expect_hash for the text it was converted against, so a file changed since is refused as stale when the plan is built. document_changes is preferred over changes when both are given, matching the LSP client preference.