Skip to content

Fixed ReplaceStep to perform a real tree replace - #12

Merged
HassanAkbar merged 2 commits into
mainfrom
fix/replace-step-tree-replace
Jul 16, 2026
Merged

Fixed ReplaceStep to perform a real tree replace#12
HassanAkbar merged 2 commits into
mainfrom
fix/replace-step-tree-replace

Conversation

@HassanAkbar

@HassanAkbar HassanAkbar commented Jul 15, 2026

Copy link
Copy Markdown
Member

Metanorma PR checklist

Related to lutaml/lutaml-model#720
This PR fixes failures in https://github.com/lutaml/lutaml-model/actions/runs/29395937178/job/87293331371?pr=720

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Prosereflect’s transform pipeline so ReplaceStep performs a true tree-structured replace (rather than rebuilding via fragments), and ensures transformed documents remain traversable with correctly-typed node content.

Changes:

  • Implemented Node#replace and switched ReplaceStep#apply to use it, rejecting unsupported slice open boundaries and fixing invert to return a Slice.
  • Updated multiple transform steps to rebuild documents via Node#copy so doc.content contains nodes (not a wrapped Fragment).
  • Added leaf? / inline? node semantics and extensive specs covering replace edge cases (leaf handling, text merging, boundary insertion behavior).

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
spec/prosereflect/transform/step_content_spec.rb Adds regression coverage ensuring step results produce traversable documents with node content.
spec/prosereflect/transform/replace_spec.rb Expands ReplaceStep specs to validate correct text outcomes, node_size stability, and leaf/boundary behaviors.
lib/prosereflect/transform/replace_step.rb Switches ReplaceStep to delegate to doc.replace, adds open-boundary rejection, and wraps inversion content in a Slice.
lib/prosereflect/transform/replace_around_step.rb Uses doc.copy to rebuild docs without fragment-wrapping issues.
lib/prosereflect/transform/mark_step.rb Uses doc.copy when applying/removing marks to preserve correct node content.
lib/prosereflect/transform/attr_step.rb Uses doc.copy when applying attrs to preserve correct node content.
lib/prosereflect/node.rb Adds leaf?, inline?, and the core replace implementation used by ReplaceStep.
lib/prosereflect/text.rb Marks Text as inline to support boundary resolution decisions.
lib/prosereflect/hard_break.rb Declares hard_break as an inline leaf for correct replace insertion semantics.
lib/prosereflect/image.rb Declares image as an inline leaf for correct replace insertion semantics.
lib/prosereflect/horizontal_rule.rb Declares horizontal_rule as a leaf for correct replace insertion semantics.
lib/prosereflect/user.rb Declares user mention as an inline leaf for correct replace insertion semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/prosereflect/node.rb
Comment thread lib/prosereflect/node.rb
Comment thread lib/prosereflect/node.rb Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Comment thread lib/prosereflect/transform/replace_step.rb
@HassanAkbar
HassanAkbar requested a review from ronaldtse July 15, 2026 12:23
@HassanAkbar
HassanAkbar merged commit 78a66b8 into main Jul 16, 2026
15 checks passed
@HassanAkbar
HassanAkbar deleted the fix/replace-step-tree-replace branch July 16, 2026 07:56
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.

2 participants