Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Check: problem with a constraint
icon5.gif  Check: problem with a constraint [message #530833] Sat, 01 May 2010 14:51 Go to next message
farah Mising name is currently offline farah Mising nameFriend
Messages: 58
Registered: July 2009
Member
hello,
I can't write this constraint with the check language:
Quote:

self.port-> forAll( p1, p2 : Port | p1<>p2 implies p1.name<>p2.name)



thank you for your help Smile
Re: Check: problem with a constraint [message #530843 is a reply to message #530833] Sat, 01 May 2010 18:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hello, you have to restructure your constraint a bit, but depending on your metamodel it should be easy to do it:

lets asume you have a metamodel like this (Xtext Synatx):

Model:
	(elements+=Element)*
;

Element: 
	"element" name=ID
;


then the check could look like this

context Element ERROR "Elements must have a unique name" :
	((Model)this.eContainer).elements.select(e|e.name == this.name).size == 1;


So in your case you have to check hat within all ports there is onlyone with the same same than the port you define the check for.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Check: problem with a constraint [message #530875 is a reply to message #530843] Sun, 02 May 2010 10:09 Go to previous message
farah Mising name is currently offline farah Mising nameFriend
Messages: 58
Registered: July 2009
Member
it's work, thank you very much for your help:)

also, I can write
Quote:

port.forAll( p1 | port.notExists(p2| p1!=p2 && p1.name == p2.name))

Previous Topic:[check] Problem with the metamodel
Next Topic:[Xtext][Xpand] How to generate a default textual syntax for existing metamodels?
Goto Forum:
  


Current Time: Fri Apr 26 05:13:37 GMT 2024

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

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

Back to the top