node

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package node defines the core data types for diff results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeKind

type ChangeKind int

ChangeKind classifies a line or structural element.

const (
	Unchanged ChangeKind = iota
	Added
	Removed
	Modified // structured diffs only (phases 4–6)
)

type Diff

type Diff struct {
	Format   Format
	FileA    string
	FileB    string
	Hunks    []Hunk    // populated for text diffs
	Root     *DiffNode // populated for structured diffs (phases 4–6)
	Added    int
	Removed  int
	Modified int // structured diffs only
}

Diff is the top-level result returned by all parse functions.

type DiffNode

type DiffNode struct {
	Kind     ChangeKind
	Path     string // e.g. ".users[0].name"
	Key      string
	Index    int    // -1 if not an array element
	OldValue string // raw leaf value
	NewValue string
	Children []*DiffNode
}

DiffNode represents a single node in a structured diff tree (phases 4–6).

type Format

type Format int

Format identifies the detected file format.

const (
	FormatText Format = iota
	FormatJSON
	FormatYAML
	FormatTerraform
)

func (Format) String

func (f Format) String() string

type Hunk

type Hunk struct {
	OldStart int
	OldCount int
	NewStart int
	NewCount int
	Lines    []Line
}

Hunk is a contiguous group of changes plus surrounding context.

type Line

type Line struct {
	Kind    ChangeKind
	OldNum  int    // 0 when Added
	NewNum  int    // 0 when Removed
	Content string // raw line content, no leading +/-
}

Line is a single line in a text diff hunk.

Jump to

Keyboard shortcuts

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