Custom ParserManager

General Discussion on RSyntaxTextArea.

Moderator: robert

Custom ParserManager

Postby zybr » Sat Jun 07, 2014 5:39 pm

I am trying to figure out how to improve parsing performance for large files (> 1000 lines). Reparsing whole document does not seem right and my parser does support multiple syntactic elements as entry points. The ParseManager does track the dirty area which is exactly what I need to get started. However the relevant fields (firstOffsetModded, lastOffsetModded) are not passed on to a parser and are not accessible (only used for debug?). ParserManager itself is not public and there is no way it seems to provide a custom manager.

Is there any reason why ParseManager is not replaceable and why its fields firstOffsetModded, lastOffsetModded are private? They way things appear to me is that ParserManager is not finished?
zybr
 

Re: Custom ParserManager

Postby robert » Tue Jun 10, 2014 2:46 am

Yes, the parsing of the modified region is a feature that wasn't quite completed. I started working on this but never finished it. To implement this, in addition to passing firstOffsetModded/lastOffsetModded to parsers (or perhaps their line indexes, not sure which would be better), you'll need to modify the removeParserNotices(ParseResult) method to only remove noticed in the re-parsed line region.

Pull requests are welcome! ParserManager is private only because applications shouldn't have to modify *how* parsing is done; they should only have to install a Parser and wait for callbacks.
User avatar
robert
 
Posts: 801
Joined: Sat May 10, 2008 5:16 pm

Re: Custom ParserManager

Postby Guest » Tue Jul 01, 2014 9:58 am

Any plans to implement this feature? I can try to give it a go with something like this:
1) a new interface would identify parsers that are capable of accepting firstOffsetModded/lastOffsetModded in the parse method
2) ParserManager will check each registered parser for being an instance of the interface, cast and call an alternative parser method with block start/end positions
3) ParseResult is extended to define the area that was re-parsed
4) removeParserNotices(..) is made sensetive to the affected area as described in the passed ParseResult

Am I missing anything? Is this a sensible approach?

Best regards
Guest
 

Re: Custom ParserManager

Postby robert » Fri Jul 04, 2014 2:31 am

Yes, that sounds about right. Keep in mind that the ParseResult interface already provides methods to return the re-parsed range, but by line number as opposed to offset. I'm not sure if that's an OK approach (or sufficient) or not. The idea was that the ParserManager tells the Parser what changed, but the Parser is free to re-parse just that or some other range (likely, all lines >= the first modified line, or the entire document).

If you work on this, and submit a pull request, I'd prefer it on a non-master branch if possible. Patches are also OK.
User avatar
robert
 
Posts: 801
Joined: Sat May 10, 2008 5:16 pm


Return to Open Discussion

Who is online

Users browsing this forum: No registered users and 4 guests

cron