Parsing can not be restarted in a certain parser state, which is required by RSyntaxDocument#getTokenListForLine.
Since RSyntaxDocument#getTokenListForLine is marked final, i can not override this behaviour and therefore can not reuse the parser.
Are there any workarounds?
Not really
Additional context
Solution
A solution would be to remove the final modifier from RSyntaxDocument#getTokenListForLine. Then a subclass of the RSyntaxDocument can be created that parses the whole document on each change and caches the tokens by line.
This cache is then used to answer RSyntaxDocument#getTokenListForLine as expected by the rest of the system.
Describe the solution you'd like I want to reuse a parser for syntax highlighting that provides an interface as following:
Parsing can not be restarted in a certain parser state, which is required by
RSyntaxDocument#getTokenListForLine
.Since
RSyntaxDocument#getTokenListForLine
is markedfinal
, i can not override this behaviour and therefore can not reuse the parser.Are there any workarounds? Not really
Additional context
Solution A solution would be to remove the
final
modifier fromRSyntaxDocument#getTokenListForLine
. Then a subclass of theRSyntaxDocument
can be created that parses the whole document on each change and caches the tokens by line. This cache is then used to answerRSyntaxDocument#getTokenListForLine
as expected by the rest of the system.