tree-sitter / java-tree-sitter

Java bindings to the Tree-sitter parsing library
https://tree-sitter.github.io/java-tree-sitter/
MIT License
26 stars 5 forks source link

Using a node outside of a cursors scope #57

Open Emmeral opened 3 days ago

Emmeral commented 3 days ago

How to use a Node that was retrieved by a TreeCursor once the cursor has been closed?

According to the documentation, the native memory segment backing the Node is cleared once the cursor is deleted. If the tree of the node still exists it is in theory still usable. However, not with the current implementation.

Would it be possible to reassign the Node instance to another arena such that it can still be used afterwards? Either by binding it to Arena.ofAuto() or by adding a method that allows copying the Node to another memory segment management by a user supplied arena?

ObserverOfTime commented 3 days ago

PR welcome.