Record block end in the __origin__ sequence#14
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Appends
end_delta, end_colto 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 fromkey_line(the sequence's single absolute line anchor, matching the existingf1_delta/s1_l0_deltaconvention); 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 mergedv3; the diff is justorigin.go(+16) andorigin_test.go(+69).Builds on the
EndLine/EndColumnwork from #9 (now inv3).