ReportSyntaxError with TextRange length of zero

SyntaxEditor for Windows Forms Forum

Posted 10 years ago by Timothy Coltman
Version: 4.0.0280
Avatar
I have a language that uses carriage returns to separate statements (like VB.NET) which I'm using SyntaxEditor to parse and render. I have encountered an issue with "ReportSyntaxError" where you pass it a TextRange that has a length of zero (i.e. StartOffset and EndOffset are the same). Where this is the case, the squiggly red line I would expect to see for an error is not shown. However, the error does appear in the "SyntaxErrors" collection - it isn't displayed.

This issue manifests itself in the following way. If I am on the very last line of the editor and there is a syntax error, it isn't displayed (no red line). As soon as I press ENTER, it is displayed (red line appears). Any errors on lines prior to the last line appear immediately.

I have put in a workaround whereby if the semantic parse data is changed, I check to see if the text of the Document ends with Environment.NewLine, and where this isn't the case, I add one. Very bad, but it works.

Is there any way around this, such as a way to add a new line before the end of the semantic parse data before it gets passed to the semantic parser? This would be more preferable to forcing a new line.

Comments (3)

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

That is by design, a syntax error with no length will not render anything. The end offset means the offset after an included caret. So if the text range is zero then no character is included.

That being said, right now there is a known issue where there isn't a way to render a squiggle line at the very end of document (after the last character in the document). As a workaround, if you encounter that scenario you'd probably want to back the range up one character.

So say your doc was 10 chars long and you wanted to report an error at the end. Normally you'd want to do a range like {10,11} but that won't render anything since that range is after the end of renderable characters. So instead back it up to {9,10}. It will render on the last character then.


Actipro Software Support

Posted 9 years ago by Joe
Avatar
Hi!
Quote:

So say your doc was 10 chars long and you wanted to report an error at the end. Normally you'd want to do a range like {10,11} but that won't render anything since that range is after the end of renderable characters. So instead back it up to {9,10}. It will render on the last character then.

I have the problem that I'd like to report an error after the last char.
Up to now if I get an Error with TextRange = 0. I decrement TextRange.StartOffset like you, but that is not completely right. Because not the correct char is underlined red.
Isn't there a better way now?

Regards, Joe
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Joe,

Sorry but nothing has been changed for this.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 7 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.