export tree sitter's id field#28
Merged
Merged
Conversation
Making Node hashable is tricky. As the node equality depends on not only node id, but also node's tree. After parsing, the id can stay the same but the tree can change, so even if the node is hashable based on its id, fetching a value from a directory of type [Node:Any] can lead to surprising missing values. So the best way so far to id a Node is to export the id field, and let the user decide how they want to id a node.
Contributor
Author
|
Note: I could clean it up on my end with a squashed commit. But I think you can simply squash it with a click on your end when merge, so I'll let you handle it. Let me know if you need me to clean it. |
Contributor
|
This is great, thank you! |
jimsynz
pushed a commit
to jimsynz/outrun
that referenced
this pull request
Oct 13, 2025
… "0.25.0" (#78) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [tree-sitter/swift-tree-sitter](https://github.com/tree-sitter/swift-tree-sitter) | minor | `from: "0.8.0"` -> `from: "0.25.0"` | --- ### Release Notes <details> <summary>tree-sitter/swift-tree-sitter (tree-sitter/swift-tree-sitter)</summary> ### [`v0.25.0`](tree-sitter/swift-tree-sitter@0.9.0...0.25.0) [Compare Source](tree-sitter/swift-tree-sitter@0.9.0...0.25.0) ### [`v0.9.0`](https://github.com/tree-sitter/swift-tree-sitter/releases/tag/0.9.0) [Compare Source](tree-sitter/swift-tree-sitter@0.8.0...0.9.0) #### What's Changed - fix ios cannot load queries issue by [@​ElvisWong213](https://github.com/ElvisWong213) in [tree-sitter/swift-tree-sitter#22](tree-sitter/swift-tree-sitter#22) - Replace git submodule with package dependency for tree-sitter integration by [@​yeatse](https://github.com/yeatse) in [tree-sitter/swift-tree-sitter#23](tree-sitter/swift-tree-sitter#23) - Hotfix alloc crash, when no read data avail. by [@​furby-tm](https://github.com/furby-tm) in [tree-sitter/swift-tree-sitter#24](tree-sitter/swift-tree-sitter#24) - Fix README formatting by [@​nakajima](https://github.com/nakajima) in [tree-sitter/swift-tree-sitter#27](tree-sitter/swift-tree-sitter#27) - export tree sitter's id field by [@​lijunsong](https://github.com/lijunsong) in [tree-sitter/swift-tree-sitter#28](tree-sitter/swift-tree-sitter#28) - Add `reset` Method On Parser by [@​thecoolwinter](https://github.com/thecoolwinter) in [tree-sitter/swift-tree-sitter#30](tree-sitter/swift-tree-sitter#30) - Deprecate `ResolvingQueryCursor. injections()` - Lots of documentation additions - `includedRanges` API for both `Tree` and `MutableTree` - Many bug fixes for `LanguageLayer` - Sublayer resolution is now opt-in - Some concurrency-related fixes - Parser bundle queries are now found on iOS - Removed the need for escaping closures in parsing functions - Attempting to use a language layer query that is unsupported now throws - Use tree-sitter 0.23.0 #### New Contributors - [@​ElvisWong213](https://github.com/ElvisWong213) made their first contribution in [tree-sitter/swift-tree-sitter#22](tree-sitter/swift-tree-sitter#22) - [@​yeatse](https://github.com/yeatse) made their first contribution in [tree-sitter/swift-tree-sitter#23](tree-sitter/swift-tree-sitter#23) - [@​furby-tm](https://github.com/furby-tm) made their first contribution in [tree-sitter/swift-tree-sitter#24](tree-sitter/swift-tree-sitter#24) - [@​nakajima](https://github.com/nakajima) made their first contribution in [tree-sitter/swift-tree-sitter#27](tree-sitter/swift-tree-sitter#27) - [@​lijunsong](https://github.com/lijunsong) made their first contribution in [tree-sitter/swift-tree-sitter#28](tree-sitter/swift-tree-sitter#28) - [@​thecoolwinter](https://github.com/thecoolwinter) made their first contribution in [tree-sitter/swift-tree-sitter#30](tree-sitter/swift-tree-sitter#30) **Full Changelog**: <tree-sitter/swift-tree-sitter@0.8.0...0.9.0> </details> --- ### Configuration 📅 **Schedule**: Branch creation - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) in timezone Pacific/Auckland, Automerge - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) in timezone Pacific/Auckland. 🚦 **Automerge**: Disabled because a matching PR was automerged previously. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNy4wIiwidXBkYXRlZEluVmVyIjoiNDEuODIuNiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsicmVub3ZhdGUiXX0=--> Reviewed-on: https://harton.dev/outrun/outrun/pulls/78 Co-authored-by: Renovate Bot <bot@harton.nz> Co-committed-by: Renovate Bot <bot@harton.nz>
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.
This PR exports the underlying tree_node's
idfield asUInt.There were two choices to make: one is to export the id, the other is to make a Node hashable based on the id. Investigation shows it's the least confusion solution to export the
idfield. Details see #26