Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export tree sitter's id field #28

Merged
merged 2 commits into from
Jun 5, 2024
Merged

Conversation

lijunsong
Copy link
Contributor

This PR exports the underlying tree_node's id field as UInt.

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 id field. Details see #26

lijunsong added 2 commits May 21, 2024 09:33
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.
@lijunsong
Copy link
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.

@mattmassicotte
Copy link
Contributor

This is great, thank you!

@mattmassicotte mattmassicotte merged commit e06be7d into tree-sitter:main Jun 5, 2024
6 checks passed
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