Skip to content

yeast: Add nicer location syntax - #22842

Open
tausbn wants to merge 3 commits into
mainfrom
tausbn/yeast-add-nicer-location-syntax
Open

tausbn wants to merge 3 commits into
mainfrom
tausbn/yeast-add-nicer-location-syntax

Conversation

@tausbn

@tausbn tausbn commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Adds support for a special location field on nodes in tree templates. This field should contain a Rust interpolation, the value of which will be treated as a node (or iterable of nodes) that provides/overrides the location of the node to which the field is attached. If multiple nodes are produced by the iterable, the location will be the smallest source range that contains all of these nodes.

The location field can also appear multiple times, in which case we apply the same unioning semantics as for iterables in a single field.

This fully supersedes the previous tree_at! and tree_spanning! macros, which are therefore removed.

Can be reviewed commit-by-commit.

When specified on a tree template node, this field is used to
override/set the location of the node it is attached to. The field
itself can contain an iterable of nodes, in which case the location will
be the smallest location spanning all of these nodes. The same behaviour
applies if there are multiple `location` fields on the same node.
@tausbn tausbn added the no-change-note-required This PR does not need a change note label Oct 19, 2026
@tausbn
tausbn marked this pull request as ready for review October 19, 2026 13:52
@tausbn
tausbn requested a review from a team as a code owner October 19, 2026 13:52
Copilot AI max review requested due to automatic review settings October 19, 2026 13:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

Parsing, range handling, and migrated callers are consistent, with focused regression coverage and no identified blocking issues.

No open issues 🎉

What changed in this PR

Adds location metadata to YEAST tree templates, simplifying source-range overrides used by the Swift extractor.

Changes:

  • Supports individual nodes, iterables, and repeated location fields.
  • Removes tree_at! and tree_spanning!, migrating Swift callers.
  • Updates documentation and adds parser and regression tests.
File Description
unified/​extractor/​src/​languages/​swift/​swift.rs Migrates location overrides to the new syntax.
shared/​yeast/​tests/​test.rs Tests overrides, range unions, and node-only effects.
shared/​yeast/​src/​lib.rs Removes obsolete macro exports.
shared/​yeast/​doc/​yeast.md Documents location-field syntax and behavior.
shared/​yeast-macros/​src/​template_parse.rs Parses location fields and validates their syntax.
shared/​yeast-macros/​src/​parse.rs Removes obsolete macro parsers.
shared/​yeast-macros/​src/​lower.rs Generates location-range union and assignment code.
shared/​yeast-macros/​src/​lib.rs Documents new syntax and removes old macros.
shared/​yeast-macros/​src/​ast.rs Represents location metadata in templates.

Review effort: Max

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation no-change-note-required This PR does not need a change note Unified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants