Keep interface clause remarks on their line - #335
Draft
HassanAkbar wants to merge 2 commits into
Draft
Conversation
There was a problem hiding this comment.
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#interfacesso interface clauses are present in the position index used for remark attachment. - Introduce
Model::TakesInlineRemarkand apply it consistently in remark attachment + formatting, includingInterfacenodes. - Persist interface clause
untagged_remarksthrough 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.
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.
A remark trailing an interface clause was dropped.
Why it happened
The remark never reached the clause.
Schemadid not listinterfacesamongits collection attributes, so
Interfacenodes never entered the positionindex. The remark fell through to the file, and the formatter emits no
remarks there.
The fix
REFERENCE FROM x;introduces whatever comes next, and is not the clause's.read.
A
TakesInlineRemarkmarker replaces two separate type checks. Attachment andformatting 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
own-line exclusion is for.
byte-identical when it should not have.