tree-sitter / node-tree-sitter

Node.js bindings for tree-sitter
https://www.npmjs.com/package/tree-sitter
MIT License
649 stars 114 forks source link

parseTextBufferSync error with Atom TextBuffer #59

Closed dschwen closed 4 years ago

dschwen commented 4 years ago
parseTextBufferSync(editor.getBuffer(), tree)

throws an error Uncaught (in promise) TypeError: buffer.getSnapshot is not a function here. editor.getBuffer() returns a TextBuffer object, but it does not have a getSnapshot() method. I've looked and found getSnapshot mentioned in the super string interface, but not in Atom's TextBuffer object. Are we talking about a different TextBuffer here?

maxbrunsfeld commented 4 years ago

Yes, parseTextBufferSync takes a superstring text buffer, which is available as a private field of the Atom TextBuffer.

dschwen commented 4 years ago

Uhm, wait, its either available or ts private. Or is there a getter? How else would I parse an atom editor buffer?

maxbrunsfeld commented 4 years ago

It's private, but this JavaScript, so private just means that it's undocumented, and not guaranteed by the Atom team to be API-stable.

Are you doing this in Atom? Or are you using the text-buffer library in your own application? I'm going to close this out, since I don't think there is an issue with this library.