Computing a Facet depending on syntaxTree

My app is reparsing the Lezer tree into a more high-level AST (without punctuation). I guess it would make sense to store this AST in a Facet and derive it with Facet.compute? For this I’d declare a dependency on Language.state however the static property is internal and thus not exposed in the TypeScript definitions:

  /// @internal
  static state: StateField<LanguageState>

Would it make sense to expose this?

Would it work to define this as a state field, and do a syntaxTree(tr.startState) != syntaxTree(tr.state) check to determine whether to recompute it?

Yes that should work. Thanks! I guess I should also check syntaxTreeAvailable(tr.state)?

Yes, if it’s important that some part of the doc is fully parsed, you can use that. But note that in a big document, the editor may never decide to parse the entire document unless you tell it to (with forceParsing or ensureSyntaxTree).