Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Showing validation error at the right eStructural feature
Showing validation error at the right eStructural feature [message #1202969] Fri, 22 November 2013 12:10 Go to next message
Ashwini Nayak is currently offline Ashwini NayakFriend
Messages: 19
Registered: July 2013
Junior Member
Hello,

I am facing a problem while showing a validation error in my xText editor.

My xcore model looks like this:

class Application
{
String name
contains User[] users
}

class User
{
String name
String address
}


My xText grammar looks as below:

Application:
"system" name=ID
users+=User*
;

User:
"userName" userName=ID "{"
"address" address=STRING
"}"
;



I have a java validation method which looks as below:

@Check
public void testApplication(Application app){
//other method calls
for(User user :app.getUsers()){
//validation part goes here...
error("Error!!!", user.eClass().getEStructuralFeature(UserPackage.USER_NAME));
}
}

I need to show a validation error at the EStructural Feature, 'userName' in my editor. I am not able to show validation error at the right place.
I throws runtime exception : "The sources EClass 'Application' does not expose the feature 'User.userName'". I can show error at the right place if I pass 'User' as the parameter for my validation method.
But, for some reason, I take 'Application' as the parameter for my validation method.

Can anyone help me by suggesting how I can resolve this?

Thanks in advance Smile

[Updated on: Fri, 22 November 2013 12:11]

Report message to a moderator

Re: Showing validation error at the right eStructural feature [message #1203239 is a reply to message #1202969] Fri, 22 November 2013 14:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

you have to pass the eobject too

error(message, eobject, feature)

btw there is Yourdslpackage.Literals.USER_NAME too


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Showing validation error at the right eStructural feature [message #1206794 is a reply to message #1203239] Sun, 24 November 2013 08:06 Go to previous message
Ashwini Nayak is currently offline Ashwini NayakFriend
Messages: 19
Registered: July 2013
Junior Member
Hi Christian,

Your suggestion has helped me. Thanks Smile
Previous Topic:Generating code for Boolean expressions
Next Topic:Dangling references in XText editor
Goto Forum:
  


Current Time: Thu Apr 25 07:06:02 GMT 2024

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

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

Back to the top