Closed TedDriggs closed 1 year ago
No. The tree doesn't have access to the document text, so it can't provide a getter or something for this. You could write a helper function tokenText = node => state.sliceDoc(node.from, node.to)
to simplify this code, I guess.
@marijnh could you add .text
as a get
please? I'm trying to port some tree-sitter code to lezer. I'm also missing .rootNode
and .children
I think.
I'm trying to implement custom completions for a language which has
Clause
nodes whose definition is:Appropriate completions for each property depend on looking up the value in the preceding elements; once the user has entered a property name, I look that up and discover it's a string, and therefore the list of operators available for completion are
=
,!=
,startswith
etc.Oddly enough, the most cumbersome/verbose piece is getting the text of each node so I can do that lookup. The closest API I've found to what I need is EditorState.sliceDoc, which works, but I have to separate the
from
and theto
values into two arguments when calling that, which gets clunky:Is there a more concise way that I'm missing to ask for the text of a given
SyntaxNode
?