Adding an IParseTarget to code documents' automatic parse requests

SyntaxEditor for WPF Forum

Posted 1 year ago by Will Gauthier
Version: 22.1.0
Avatar

Is there a way to to have the ParseRequests sent by CodeDocuments when a text change occurs include my IParseTarget-implementing class as an argument? I'd like to generate and store some supplemental data based on the parse results, but right now I'm having to fire an additional, manual ParseRequest of my own, which seems wasteful.

Comments (2)

Answer - Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Will,

I'm sorry but I'm not completely clear on what you are trying to do here.

There is an ICodeDocumentPropertyChangeEventSink language service you can register on your syntax language.  That will get notified when the IParseData is changed for a document using the syntax language.  If you only care about your other target getting notified of new IParseData results, that might be what you want to use, but it will not pass the original IParseRequest.

If on the other hand, you need more control over everything, you can override our default document.CreateParseRequest method to perhaps change the parse target to some other meta parse target that can notify the normal one and your other class.  Here's the default code for that method:

protected virtual IParseRequest CreateParseRequest() {
	if (language == null)
		return null;

	// Ensure the language has a parser
	if (language.GetService<IParser>() == null)
		return null;

	// Get a reader
	ITextBufferReader reader = this.CurrentSnapshot.GetMergedBufferReader();

	// Create a request
	ParseRequest request = new ParseRequest((String.IsNullOrEmpty(this.FileName) ? uniqueId.ToString() : this.FileName), reader, language, this);
	request.Snapshot = this.CurrentSnapshot;
	request.Tag = languageData;

	return request;
}

I hope one of those two options help.


Actipro Software Support

Posted 1 year ago by Will Gauthier
Avatar

Thank you for the reply.

Luckily I only need to be notified of new IParseData results, so I don't have to override the default document method. I tested the first approach you suggested with the event sink, and it worked, thanks!

The latest build of this product (v24.1.2) was released 3 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.