Sychronizing Document with DotNetProjectResolver.

SyntaxEditor for Windows Forms Forum

Posted 15 years ago by Hu Xuenian
Version: 4.0.0276
Avatar
I have an issue when using the .SourceProjectContent.LoadForCode() method of DotNetProjectResolver object.
The problem is that the event SourceProjectContent.SemanticParseComplete object of does not get raised consistently after calling LoadForCode method. Sometimes the event is raised and sometimes not.
Which means it is not possible to ensure that the DotNetProjectResolver object has parsed the new code loaded before using it.

I will explain the situation in my code.
I have a document object _memorysourceDocument and a DotNetProjectResolver object _resolver.
I need these two to be always in sync, because I use the offsets from AstNodes in ICompilationUnit of the _resolver to extract segments of code from _memorysourceDocument.Text.
So I make the call
LoadForCode(new CSharpSyntaxLanguage(), fileName, _memorysourceDocument.Text)
everytime the _memorysourceDocument.Text is updated.
But sometimes by the time I used the _resolver, the parsing is not complete and the AstNodes offsets are all wrong with respect to latest _memorysourceDocument.

I have tried using SemanticParserService.WaitForParse method. But doesn't help.

Below is the code


ctor
{
_resolver.SourceProjectContent.SemanticParseComplete += new SemanticParseEventHandler(SourceProjectContent_SemanticParseComplete);

}
        
private DotNetProjectResolver _resolver;
private Document _memorysourceDocument;

 void SynchronizeDocument(string fileName)
 {            
    _memorysourceDocument.LoadFile(fileName);
    _resolver.SourceProjectContent.LoadForCode(new CSharpSyntaxLanguage(), fileName,   _memorysourceDocument.Text);
 }

void SourceProjectContent_SemanticParseComplete(object sender, SemanticParseEventArgs e)
{
...
}


Comments (3)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The SourceProjectContent.SemanticParseComplete event should always fire 1:1 with a call to LoadForCode. The only exception being if you call LoadForCode twice with the same filename, and the first call hasn't parsed yet. In that case, I believe it will cancel the first request and just keep the second queued.

If you think there is a problem, then please make a simple sample project that shows the problem and email it over. Thanks.


Actipro Software Support

Posted 15 years ago by Hu Xuenian
Avatar
Hi

Thanks for the Reply. So if i know that the first request with the same file name is still pending using the parse hash key how can i cancel that and make my second request of the same file name to parse and get notified about the parse completion?
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I was saying if you send one through with the same parse hash key, it auto cancels the existing pending request and queues up the new request instead. So only the new request will eventually be notified of completion.


Actipro Software Support

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.