diff

package
v0.3.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package diff computes minimal deltas between the current enriched AST and a previous snapshot.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CursorHash

func CursorHash(roots []*parser.ContextNode) string

func CursorHashFlat

func CursorHashFlat(flat []*parser.ContextNode) string

func CursorHashForChange added in v0.3.12

func CursorHashForChange(prevHeadID int64, deltas []Delta) string

Hash a change against its parent snapshot so reverting to a prior post-state still yields a unique digest. prevHeadID is the HEAD snapshot id (monotonic, never reused), so the result is unique per snapshot even when the deltas repeat.

func CursorHashForCompile added in v0.3.12

func CursorHashForCompile(prevHeadID int64, flat []*parser.ContextNode) string

Hash a compiled post-state against its parent snapshot so a compile that lands on a prior content state (edit, compile, revert, compile) still yields a unique digest. prevHeadID is the HEAD snapshot id (monotonic, never reused).

func CursorHashForRollback added in v0.3.1

func CursorHashForRollback(prevHeadID, targetID int64, deltas []Delta) string

func SnapshotFromNodes

func SnapshotFromNodes(roots []*parser.ContextNode) map[string]NodeState

Build a NodeState map from enriched nodes.

Types

type Delta

type Delta struct {
	NodeID     string
	OldHash    string
	NewHash    string
	OldContent string
	NewContent string
	Op
}

func Diff

func Diff(roots []*parser.ContextNode, prev map[string]NodeState) []Delta

Compare enriched nodes against the previous snapshot and returns one.

func DiffFlat

func DiffFlat(flat []*parser.ContextNode, prev map[string]NodeState) []Delta

type NodeState

type NodeState struct {
	Hash    string
	Content string
}

Node's hash+content pair from the previous snapshot.

type Op

type Op string
const (
	OpAdd Op = "add"
	OpMod Op = "mod"
	OpRem Op = "rem"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL