Skip to content

Keep interface clause remarks on their line - #335

Draft
HassanAkbar wants to merge 2 commits into
fix/compound-opener-remarksfrom
fix/interface-remarks
Draft

Keep interface clause remarks on their line#335
HassanAkbar wants to merge 2 commits into
fix/compound-opener-remarksfrom
fix/interface-remarks

Conversation

@HassanAkbar

Copy link
Copy Markdown
Member

A remark trailing an interface clause was dropped.

REFERENCE FROM vr_model_schema   -- ACME 5000-42

Why it happened

The remark never reached the clause. Schema did not list interfaces among
its collection attributes, so Interface nodes never entered the position
index. The remark fell through to the file, and the formatter emits no
remarks there.

The fix

  • Index interface clauses, so a remark trailing one can find it.
  • Exclude them from the own-line lookup. A remark on its own line below
    REFERENCE FROM x; introduces whatever comes next, and is not the clause's.
  • Accept a remark that closes a clause spanning several lines.
  • Serialize the clause's remarks, or they survive a format but not a cache
    read.

A TakesInlineRemark marker replaces two separate type checks. Attachment and
formatting have to agree on which types can carry these; when they disagree
the remark is marked and then never written.

Effect

Two example schemas go from five untagged losses each to none. Losses on the
production schema fall from 57 to 45, with nothing newly lost.

Notes

  • Indexing the clauses on its own regressed one fixture, which is what the
    own-line exclusion is for.
  • The serialization gap was found because a regenerated fixture came back
    byte-identical when it should not have.

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

Fixes loss of trailing -- remarks on interface clauses (REFERENCE FROM / USE FROM) by ensuring interface clauses participate in source-position indexing and are treated as valid inline-remark owners, while preventing own-line remarks below interface clauses from being incorrectly attached to (and lost on) the clause.

Changes:

  • Index Schema#interfaces so interface clauses are present in the position index used for remark attachment.
  • Introduce Model::TakesInlineRemark and apply it consistently in remark attachment + formatting, including Interface nodes.
  • Persist interface clause untagged_remarks through YAML serialization and add/adjust fixtures + specs to cover formatter + cache round trips.

Reviewed changes

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

Show a summary per file
File Description
spec/syntax/without_ending_newline.yaml Updates expected YAML to include inline untagged remarks on an interface clause.
spec/syntax/mathematical_functions_schema/mathematical_functions_schema.yaml Updates syntax fixture to record inline placement/region for interface-clause remarks and other inline remark placements.
spec/fixtures/remark_conservation/mathematical_functions_losses.yml Updates loss expectations consistent with improved inline remark preservation.
spec/expressir/express/formatter_remark_conservation_spec.rb Adjusts conservation expectations now that interface-clause trailing remarks survive.
spec/expressir/express/formatter_interface_remarks_spec.rb Adds targeted specs for interface-clause inline remarks, multi-line clause closing remarks, and YAML cache round trip.
lib/expressir/model/declarations/schema.rb Adds :interfaces to collection_attributes so interface clauses enter the node index.
lib/expressir/model/declarations/interface.rb Marks Interface as TakesInlineRemark and serializes untagged_remarks.
lib/expressir/model/concerns.rb Introduces TakesInlineRemark marker and makes Statement include it.
lib/expressir/model.rb Autoloads the new TakesInlineRemark concern.
lib/expressir/express/remark_attacher.rb Broadens inline remark ownership from Statement to TakesInlineRemark and adds “closing owner” fallback for multi-line clause terminators.
lib/expressir/express/node_position_index.rb Excludes Interface from own-line remark scoping while still indexing it for inline attachment.
lib/expressir/express/formatters/remark_formatter.rb Emits inline remarks for any TakesInlineRemark node (not only Statement).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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