O(1) get current lezer parse tree ?

I have defined a lezer grammar. I want to retrieve the parse tree of the lezer grammar. In lezer debug view ? a method syntaxTree(editorState) is shown – but I do not know if that method is O(1) or if it is O(n), reparsing the editor state

Question: Is there an O(1) way of retrieving the lezer parse tree ?

The tree returned by syntaxTree is pre-computed on state updates, and accessing it is O(1). It may be incomplete if there was a lot of new content to parse. ensureSyntaxTree can force it to be complete up to a given point, but may require more work.

1 Like