Document Changed Event

SyntaxEditor for Windows Forms Forum

Posted 11 years ago by Scott Currie
Version: 4.0.0280
Avatar
I am using the XML semantic service from the Web package, but I think this is a more general question.

I need an event to hook up to that meets the following requirements:
1) It has to have an argument that tells me whether the last edit was programatically made (like DocumentTextChanged)
2) It has to fire only when the SemanticParseData is up-to-date.

Is there anything like that?

If not, is there any way I can check if the SemanticParseData is up-to-date with respect to the current Document.Text?

Thanks,
-Scott

Comments (3)

Posted 11 years ago by Scott Currie
Avatar
BTW, I just tried doing it this way, and it seems to work. Is this approach threadsafe? I don't know much about the timing of UserInterfaceUpdate events.

void SyntaxEditor_DocumentTextChanged(object sender, DocumentModificationEventArgs e)
{
   this._isLastDocumentTextChangeProgrammatic = e.IsProgrammaticTextReplacement;
}

void SyntaxEditor_UserInterfaceUpdate(object sender, EventArgs e)
{
   if (!this._isLastDocumentTextChangeProgrammatic)
   {
      ICompilationUnit compilationUnit = this.SyntaxEditor.Document.SemanticParseData as ICompilationUnit;
      if (compilationUnit != null && !compilationUnit.HasErrors && !String.IsNullOrEmpty(this.SyntaxEditor.Document.Text))
      {
         astEngine.MergeParse(this.SyntaxEditor.Document.Text);
      }
   }
}
Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Scott,

Instead of UserInterfaceUpdate, you may want to use DocumentSemanticParseDataChanged since it will fire immediately after the SemanticParseData is updated.


Actipro Software Support

Posted 11 years ago by Scott Currie
Avatar
The issue with that event is that the handler runs on the SemanticDataParser thread, which substantially limits what I can do in that handler without making a bunch of framework-level changes to support multi-threading.
The latest build of this product (v2020.1 build 0400) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.