Skip to main content



      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 10:51 Go to next message
Eclipse UserFriend
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 14:15 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Check: problem with a constraint [message #530875 is a reply to message #530843] Sun, 02 May 2010 06:09 Go to previous message
Eclipse UserFriend
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: Wed Jul 30 14:56:50 EDT 2025

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

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

Back to the top