feat: _parent context for child selector matches#135
Merged
jamestexas merged 2 commits intomainfrom Mar 25, 2026
Merged
Conversation
When a child selector fans out a nested array (e.g. FixedIn[*]),
child templates can now reference parent fields via {{._parent.name}}.
Chains work too: {{._parent._parent.org}}.
parentAwareMatch wraps child matches, forwarding OriginProvider and
GetCaptureNode so tree-sitter features (doc comments, location,
write-back) continue to work.
Both processNode (MemoryStore) and collectNodes (SQLite streaming)
paths are wired.
3 tests, all TDD.
[mache-e4a559]
5dc0c74 to
92139b4
Compare
There was a problem hiding this comment.
Pull request overview
Adds parent-context propagation to ingestion match values so child node/file templates can reference parent fields via {{._parent.field}} (including multi-level chaining), while preserving tree-sitter-origin features by forwarding relevant interfaces.
Changes:
- Introduces
parentAwareMatchwrapper to inject a_parentmap intoMatch.Values()and forwardOriginProvider+GetCaptureNode. - Threads parent match values through both ingestion paths:
processNode(MemoryStore) andcollectNodes(SQLite streaming). - Adds tests covering array fanout, 2-level nesting, and root behavior (no
_parentat top level).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| internal/ingest/parent_match.go | Adds the match wrapper that injects _parent and forwards tree-sitter-related interfaces. |
| internal/ingest/parent_context_test.go | Adds JSON ingestion tests validating _parent access and chaining semantics. |
| internal/ingest/engine_records.go | Updates processNode call site for the new parent-values parameter. |
| internal/ingest/engine.go | Wires _parent injection into processNode and collectNodes, plus updates call sites/signatures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…eaming test - Document _parent as reserved key (underscore-prefixed = engine metadata) - Add TestEngine_ParentContext_SQLiteStreamingPath for collectNodes path - Values() double-call already fixed by caching in prior commit [mache-e4a559]
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.
Summary
_parentkey into child match values when a schema node recurses into children{{._parent.fieldName}}in child templates — chains work:{{._parent._parent.org}}parentAwareMatchwrapper forwardsOriginProviderandGetCaptureNodeso tree-sitter features (doc comments, location, write-back) continue to workprocessNode(MemoryStore) andcollectNodes(SQLite streaming) paths wiredTest plan
task lint— 0 issuestask test— full suite greenBead: mache-e4a559
🤖 Generated with Claude Code