Skip to content

Record block end in the __origin__ sequence#14

Merged
reuvenharrison merged 3 commits into
v3from
feat/origin-end-emission
Jun 25, 2026
Merged

Record block end in the __origin__ sequence#14
reuvenharrison merged 3 commits into
v3from
feat/origin-end-emission

Conversation

@reuvenharrison

Copy link
Copy Markdown
Collaborator

Appends end_delta, end_col to each __origin__ sequence so a consumer can reconstruct the full block span [key_line, key_line+end_delta] (e.g. an entire endpoint/operation block). Line is stored as a delta from key_line (the sequence's single absolute line anchor, matching the existing f1_delta/s1_l0_delta convention); column is absolute. Appended last, so a consumer that stops after the sequences section ignores it (backward compatible).

Continues #10, which auto-closed when its base branch (feat/node-end-position, PR #9) was squash-merged and deleted. Same content, rebased onto the merged v3; the diff is just origin.go (+16) and origin_test.go (+69).

Builds on the EndLine/EndColumn work from #9 (now in v3).

reuvenharrison and others added 3 commits June 24, 2026 18:31
Node tracked only its start (Line/Column). Add EndLine/EndColumn,
populated from the parser event's end_mark: for scalars/aliases at
node construction, and for mappings/sequences from the matching
MAPPING-END/SEQUENCE-END event so the span covers the whole block,
not just its first line.

This lets a consumer extract an entire collection (e.g. a whole
OpenAPI operation block) from its node, which the change-origin work
upstream builds on.

TestNodeEndPosition covers scalar and nested-block spans, including
that a block does not bleed into its sibling. TestNodeRoundtrip clears
the new fields before its deep-equality check, since its expected
literals predate them (end positions are covered by the new test).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
buildOriginSeq now appends end_delta (line delta from key_line) and
end_col for the whole mapping block, using the node EndLine/EndColumn
added in the previous commit. This lets a consumer reconstruct an
element's full span (e.g. an entire endpoint operation block) from its
origin, not just the start.

Appended after the sequences section so a consumer that stops there
(today's kin-openapi originFromSeq) ignores the new fields -- backward
compatible, no lockstep release required.

TestOrigin_BlockEnd asserts the end reconstructs the block's last
content line without bleeding into the next sibling; the existing
golden origin tests are updated for the two new trailing entries.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# Conflicts:
#	decode.go
#	end_position_test.go
@reuvenharrison reuvenharrison merged commit 72f40b7 into v3 Jun 25, 2026
4 checks passed
@reuvenharrison reuvenharrison deleted the feat/origin-end-emission branch June 25, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant