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 #1202968] 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 code
for(User user :app.getUsers()){
//validation 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

Re: Showing validation error at the right eStructural feature [message #1213323 is a reply to message #1202968] Wed, 27 November 2013 07:35 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Use
error("Error!!", user, UserPackage.Literals.USER_NAME)
Previous Topic:Generator problems when using cross references in xtext
Next Topic:Using cross references in xtext
Goto Forum:
  


Current Time: Sat Apr 27 04:34:46 GMT 2024

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

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

Back to the top