NullReferenceException using Irony Parser with AmbientParseRequestDispatcherProvider

SyntaxEditor for WPF Forum

Posted 10 years ago by Malcolm Stockham
Version: 13.2.0592
Platform: .NET 4.5
Environment: Windows 7 (64-bit)
Avatar

I am currently evaluating the SyntaxEditing component, and have encountered a problem while attempting to manually issue a parse request to the AmbientParseRequestDispatcherProvider outside the context of the syntax editor.

I initially encountered this problem with our own Irony Grammar, but have replicated the problem using the IronyIntegration example project which uses the SimpleLanguageGrammar.

IParseRequest request = new ParseRequest(UniqueId.ToString(), new StringTextBufferReader("function Add(x, y) { return x + y; }"), _language, this)
{
  Priority = ParseRequest.LowPriority,
};

if (AmbientParseRequestDispatcherProvider.Dispatcher != null)
{
  AmbientParseRequestDispatcherProvider.Dispatcher.QueueRequest(request);
  AmbientParseRequestDispatcherProvider.Dispatcher.WaitForParse(request.ParseHashKey);
} 

 When I run this code, I get the following error during the WaitForParse():

System.NullReferenceException was unhandled
Message: An unhandled exception of type 'System.NullReferenceException' occurred in ActiproSoftware.Text.Addons.Irony.Wpf.dll
Additional information: Object reference not set to an instance of an object.

I can call the language parser directly without problem, ie 

parseData = (IIronyParseData) _language.Parse("function Add(x, y) { return x + y; }");

This works perfectly and returns exactly what I would expect. Am I doing something obviously wrong?

[Modified 10 years ago]

Comments (2)

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

Hi Malcolm,

Thanks for letting us know about this.  The IronyParser class of ours is currently trying to get the text to send to the real Irony parser from the request.Snapshot, but in your first snippet, no snapshot has been assigned to the request.  We have updated the logic for the next version to get the text from the reader instead, which gets your example working either way.

In the meantime, the Parse extension method you indicated at the bottom would be the best workaround.


Actipro Software Support

Posted 10 years ago by Malcolm Stockham
Avatar

I'll do that.  Thanks for your rapid response.

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

Add Comment

Please log in to a validated account to post comments.