Request for delayed parsing mechanism

SyntaxEditor for WPF Forum

Posted 8 years ago by James Zheng
Version: 16.1.0632
Avatar

Hi Actipro,

We've an issue with intermittent UI freezes when use types in a large document. As user types, every single character input is going to raise a parse request which involves some lengthy operations proportional to the size of the document.

I've tried using the AmbientParseRequestDispatcherProvider.Dispatcher for parsing in other threads. But it doesn't help. I would like to ask if it's possible to have delayed parsing mechanism. Following could be the flow:

Step 1: Delayed parse is enabled in the document

Step 2: User types a character

Step 3: CodeDocument.OnTextChanged is called, but no parse is performed to reflect its syntax highlighting.

Step 4: User types more characters

Step 5: CodeDocument.OnTextChanged is called, but no parse is performed to reflect its syntax highlighting.

Step 6: Client of the editor detects user stops typing for a while (Note: this could be in the client code)

Step7: Client requests to start a delayed parsing.

Step 8: The parse can be done either in the GUI thread or AmbientParseRequestDispatcherProvider.Dispatcher thread.

Please let me know if this is possible. This will greatly reduce our pressure on optimizing the performance.

Thanks and regards,

James Zheng

Comments (4)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi James,

It sounds like something isn't configured correctly in your setup.  If you have the AmbientParseRequestDispatcherProvider set up, then parsing shouldn't be an issue at all.  As an example, we can load the C# language in our .NET Languages Add-on and open a 10MB C# file and type in it fine with full parsing, outlining, etc. without any noticable delays. 

You might want to use a performance profiler on your app to see what is truly causing the slowdown in the UI thread, assuming you have AmbientParseRequestDispatcherProvider set up.  Perhaps you have some custom tagger or other process that is causing it?


Actipro Software Support

Posted 8 years ago by James Zheng
Avatar

Hi Actipro,

AmbientParseRequestDispatcherProvider worked, but not the syntax highlighting. During parse, some information which is responsible for syntax highlighting is not available at the time. I used performance analysis tool to spot some hot paths, but the required fix won't be straight forward due to its legacy code.

I'm requesting this feature, so that I can request for a parse when it's ready. The following are the requirements I would like to have:

  • Be able to enable and disable parse requests when text change.
  • After a parse operation is done, I would like to be notified, so that I can process some custom post parsing operations.
  • Be able to refresh the syntax highlighting and squiggle lines.

Thanks and regards,

James Zheng

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi James,

I believe we already have some of that functionality in place.

1) You could disable parsing if you removed the IParser service from the syntax language.  Then add it back when you want parsing enabled on text changes again.

2) What you can do here is create a class that implements IParser and "wrap" the normal IParser that you use.  That way, your custom IParser.Parse method implementation can call the wrapped IParser.Parse method and when that returns, you can do your post parsing operations and return an appropriate IParseData result.

3) You could try calling editor.InvalidateViews() for that.


Actipro Software Support

Posted 8 years ago by James Zheng
Avatar

Hi Actipro,

Thanks for the feedback. I'll investigate further.

Regards,

James Zheng

The latest build of this product (v24.1.3) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.