StreamLanguage parser contextual autocomplete

Recently I switched my project CM5 → CM6 and with many great improvements, I encountered some trouble.

I am building a language extension with StreamLanguage parser.

While parsing, I keep track of some path structure as part of parser state.

Then in autocomplete plugin I can digout the final parser state this way:

With all my attempts to use cursor, I can find intermediate parser state in the parsed tree.

    const values = context.state.values;
    const tree = values.find(e => e.tree).tree;
    const cursor = tree.cursor();
    cursor.childBefore(word.from);
    console.log('cursor node tree:', cursor.node.toTree());

Where do I find Parser state inside TreeNode ?

You can’t. This is one of the reasons Lezer parsers are recommended—they make it much easier to implement contextual logic (also for folding, indentation, etc). I think a language like yours should be pretty straightforward to port to Lezer.

Indeed, WaveQL is a very simple language. It is similar to Forth. Is just words separated by spaces.
At first I did write parser in Lazer. But then I encounter the fact that Lazer is not re-parsing all my source text when I edit it. I know it is nice feature, but highlighting of WaveQL depends on hierarchical vocabulary, that is traversing and types of words it finds.
Streaming parser has a state path that is updated sequentially from start for finish and help to assign right types to the tokens.
Following your advice I rewrote it again in Lezer and can’t get correct tokens.
I know I am doing something extremely wrong.
Here is full commit: Lezer version of parser · wavedrom/ql@926db10 · GitHub