Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Validate against model structure
Validate against model structure [message #1008176] Mon, 11 February 2013 09:32 Go to next message
Mr Manner is currently offline Mr Manner
Messages: 26
Registered: January 2013
Junior Member
Say I have a model with a supertype rule:

Options:
	'{'
		members+=Member
		(',' members+=Member)*
	'}';

Member:
    A | B | C | D | E | F;

RequiredMembers:
    A | B | C;


I want to write a validation method for "Options" where I check if the "members" feature has a entry for each of the RequiredMembers.

The example above is just pseudo code, the real live code is a bit mode complicated, I can't put the required members in "Options" and chain them with the & operator without forcing an order in the required members.

How can I get get the members in RequiredMembers from emf so I can use this info in my validator.

[Updated on: Mon, 11 February 2013 09:58]

Report message to a moderator

Re: Validate against model structure [message #1008257 is a reply to message #1008176] Mon, 11 February 2013 18:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6327
Registered: July 2009
Senior Member
Hi,

this is hard to say without having a concrete grammar.
in the case you have posted RequiredMembers is a supertype of A, B and C so an instanceof will do the trick
Re: Validate against model structure [message #1008434 is a reply to message #1008176] Tue, 12 February 2013 13:23 Go to previous messageGo to next message
Mr Manner is currently offline Mr Manner
Messages: 26
Registered: January 2013
Junior Member
The instanceof trick will work if you want to know if a class is s subtype of RequiredMember, but you can't know all the classes that implement the RequiredMember interface.

The model should be stored somewhere else, the content assist knows all members Options can have. How can I know what the content assist knows?

Regards
Re: Validate against model structure [message #1008475 is a reply to message #1008434] Tue, 12 February 2013 16:10 Go to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6327
Registered: July 2009
Senior Member
Hi rach DSL has a grammar access which offers such information. But
AS long AS you don't come up with a real world example it is hard to
tell if this will help you. You may have to debug into the stuff to
see what to do exactly.

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Previous Topic:Injection into a custom view
Next Topic:ImportURI scoping case sensitive
Goto Forum:
  


Current Time: Wed Oct 01 08:26:56 GMT 2014

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

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