serialize

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const SchemaVersion = "v1"

SchemaVersion defines the stable, versioned JSON output format version.

Variables

This section is empty.

Functions

func Marshal

func Marshal(es *actions.EditScript, ms *engine.Mapping, srcRoot, dstRoot *treesitter.ASTNode) ([]byte, error)

Marshal converts an actions.EditScript and the matching engine.Mapping into a JSON byte slice.

func Unmarshal

func Unmarshal(data []byte, srcRoot, dstRoot *treesitter.ASTNode) (*actions.EditScript, error)

Unmarshal reconstructs an actions.EditScript from the JSON data, resolving node references against the provided source (before) and destination (after) AST roots.

Types

type Action

type Action struct {
	Action        string   `json:"action"` // "insert", "delete", "update", "move"
	Node          *NodeRef `json:"node"`
	Parent        *NodeRef `json:"parent,omitempty"`
	Position      *int     `json:"position,omitempty"`
	OldParent     *NodeRef `json:"old_parent,omitempty"`
	OldPosition   *int     `json:"old_position,omitempty"`
	OldValue      string   `json:"old_value,omitempty"`
	NewValue      string   `json:"new_value,omitempty"`
	Subtree       *bool    `json:"subtree,omitempty"`
	DestNode      *NodeRef `json:"dest_node,omitempty"`
	DestStartByte *uint32  `json:"dest_start_byte,omitempty"`
	DestEndByte   *uint32  `json:"dest_end_byte,omitempty"`
	GroupID       string   `json:"group_id,omitempty"`
}

Action represents a serialized edit-script action. The absence of the "subtree" field always indicates false.

type Envelope

type Envelope struct {
	Version string   `json:"version"`
	Actions []Action `json:"actions"`
}

Envelope wraps the serialized actions list with a schema version.

type NodeRef

type NodeRef struct {
	Tree      string `json:"tree"` // "before" or "after"
	Path      []int  `json:"path"`
	Type      string `json:"type"`
	Label     string `json:"label,omitempty"`
	StartByte uint32 `json:"start_byte"`
	EndByte   uint32 `json:"end_byte"`
}

NodeRef is a stable and self-describing reference to an AST node.

Jump to

Keyboard shortcuts

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