Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse of Parsers that can not parse line by line #454

Closed
Hellwig-SE opened this issue Jun 28, 2022 · 0 comments
Closed

Reuse of Parsers that can not parse line by line #454

Hellwig-SE opened this issue Jun 28, 2022 · 0 comments
Milestone

Comments

@Hellwig-SE
Copy link

Describe the solution you'd like
I want to reuse a parser for syntax highlighting that provides an interface as following:

List<Token> parse(String content) throws ParseException;

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants