The KSyntaxHighlighting framework has a function called
virtual void applyFormat(int offset, int length, const Format &format) = 0;
This function is called for all characters of text that is passed into highlightLine(text, state).
What applyFormat() is missing is a context object that can be used to obtain more information about the internal state of the syntax highlighting engine, in particular we need to know in which context are we are at the current location.
For instance, this context info is needed to obtain the currently available keyword lists for context-sensitive keyword completion (which we had in KTextEditor, but lost with the KSyntaxHighlighting transition). I.e., we want to add back a function QStringList Definition::keywordLists(void* context) const; or similar.
For this task, there is also a comment in src/lib/abstracthighlighter.h:
// TODO KF6: add an optional void* context argument that is passed through // to the applyX() calls, so highlighters dealing with some form of line object // (such as QSyntaxHighlighter or KTextEditor) can avoid some ugly hacks to have // this context available in their applyX methods