Documentation
¶
Index ¶
Constants ¶
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 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.