access the final state of the parser for hinting

I have developed a custom mode for a custom programming language. I want to implement auto completion for it, both for fixed constructs and for identifiers.
Since the parser - for syntax highlighting - identifies the identifiers anyway, it’d be cool if I could store them in the state object, and access the final state object at the end. Is there any API for that? Does CodeMirror always run the mode to the end of the document? Do you know a better way?

See getStateAfter

Cool, I overlooked that. Thanks!