Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [XTEXT] How to display specific error for special characters?
[XTEXT] How to display specific error for special characters? [message #1752360] Mon, 23 January 2017 03:32 Go to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
I have an input that is a special characters.
The user enters a space.
When you read it in the hex editor, its hex value is A0 20. It shows as a space also so it is hard to tell at first what is causing the error.
An ASCII space has a hex value of 20.
But this one has A0 20.

When I ran the jar file, the error message say "no viable alternative at input ' '", which is confusing.

Is there a way for xtext to display a more specific error message? Like if the input is a special character, it could say "Only ASCII characters are supported." or something like that.
Re: [XTEXT] How to display specific error for special characters? [message #1752364 is a reply to message #1752360] Mon, 23 January 2017 04:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11502
Registered: July 2009
Senior Member
the extension point for syntax error messages is org.eclipse.xtext.parser.antlr.ISyntaxErrorMessageProvider

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com

[Updated on: Mon, 23 January 2017 04:31]

Report message to a moderator

Re: [XTEXT] How to display specific error for special characters? [message #1752365 is a reply to message #1752364] Mon, 23 January 2017 05:34 Go to previous messageGo to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
I looked at the documentation for ISyntaxErrorMessageProvider but it states "This interface is not intended to be implemented by clients."?
Re: [XTEXT] How to display specific error for special characters? [message #1752367 is a reply to message #1752365] Mon, 23 January 2017 05:59 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11502
Registered: July 2009
Senior Member
That's cause it's not easy and it might change
But it's all you have

You might subclass the default impl as the docs say

* Implementors should extends the {@link SyntaxErrorMessageProvider} rather than implementing
* the interface directly.


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com

[Updated on: Mon, 23 January 2017 06:34]

Report message to a moderator

Previous Topic:Problems with code generation
Next Topic:Disable errors reported by xtext
Goto Forum:
  


Current Time: Fri Dec 15 02:51:03 GMT 2017

Powered by FUDForum. Page generated in 0.02032 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software