Documentation
¶
Overview ¶
Package patch composes immutable byte edits while retaining original-source correspondence. It assigns no YAML, comment or graph meaning to a footprint.
Index ¶
- Variables
- func New(original []byte, limits Limits) (*Table, Stats, error)
- type Correspondence
- type Fault
- type Limits
- type Mark
- type Part
- type Stats
- type Table
- func (t *Table) Correspondence(limits Limits) ([]Correspondence, Stats, error)
- func (t *Table) Len() int
- func (t *Table) Locate(mark Mark, limits Limits) (source.Span, bool, Stats, error)
- func (t *Table) OriginalSpan(span source.Span, limits Limits) (source.Span, bool, Stats, error)
- func (t *Table) Preserved(span source.Span, limits Limits) (bool, Stats, error)
- func (t *Table) Render(limits Limits) ([]byte, Stats, error)
- func (t *Table) Replace(span source.Span, replacement []byte, limits Limits) (*Table, Stats, error)
- func (t *Table) Rewrite(span source.Span, parts []Part, limits Limits) (*Table, Stats, error)
- func (t *Table) Track(span source.Span, limits Limits) (Mark, Stats, error)
- func (t *Table) Verify(candidate []byte, limits Limits) (Stats, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrLimit = errors.NewSentinel("yamldoc.patch.limit", "source patch resource limit exceeded") ErrTable = errors.NewSentinel("yamldoc.patch.table", "invalid source patch table") ErrMismatch = errors.NewSentinel("yamldoc.patch.mismatch", "candidate bytes do not match the declared source patch plan") )
var ErrReuse = errors.NewSentinel("yamldoc.patch.reuse", "source rewrite repeats retained bytes")
Functions ¶
Types ¶
type Correspondence ¶
type Mark ¶
type Mark struct {
// contains filtered or unexported fields
}
Mark identifies a nonempty byte occurrence in one source lineage. It follows retained pieces, including inserted bytes, without treating equal copied bytes as the same occurrence. It carries no YAML, comment ownership or view lifetime. A mark may retain the backing storage of generated bytes that it references.
type Part ¶
type Part struct {
// contains filtered or unexported fields
}
Part selects bytes to retain from the current table or new bytes to insert. Constructors store input until synchronous Rewrite admission copies new bytes.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func (*Table) Correspondence ¶
func (t *Table) Correspondence(limits Limits) ([]Correspondence, Stats, error)
func (*Table) OriginalSpan ¶
OriginalSpan maps a contiguous retained source occurrence into the current output. Equal replacement bytes are not proof that the original survived.
func (*Table) Preserved ¶
Preserved requires one contiguous original piece to cover the entire span. Merely retaining its bytes on both sides of an insertion is insufficient.
func (*Table) Rewrite ¶
Rewrite replaces a current source window with ordered parts. Retained spans must lie inside that window and may not overlap: relocation preserves identity, while explicit byte insertion creates a new occurrence even for equal bytes. Bytes outside the window are retained automatically. No YAML meaning is assigned.