Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » What is the fastest way to make sure some names are unique?
What is the fastest way to make sure some names are unique? [message #822340] Fri, 16 March 2012 13:45 Go to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
What is the most simple way to say "in my model, all children of type X must be unique?"

My guess is that I should extend NamesAreUniqueValidationHelper but how? Is it enough to add all relevant types to the result of `getClusterTypes()`?
Re: What is the fastest way to make sure some names are unique? [message #822352 is a reply to message #822340] Fri, 16 March 2012 13:59 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 13468
Registered: July 2009
Senior Member
Hi,

is your model "one model file" or "the set of all model files in a project"?
if the answer is "one model file" enabling

            fragment = validation.JavaValidatorFragment {
            //    composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
                composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
            }


and binding a appropriate NamesAreUniqueValidationHelper should do the trick

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 16 March 2012 14:03]

Report message to a moderator

Re: What is the fastest way to make sure some names are unique? [message #822361 is a reply to message #822352] Fri, 16 March 2012 14:09 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 13468
Registered: July 2009
Senior Member
And just to be complete:

to check a complete project - the solution is described here: http://www.eclipse.org/forums/index.php/mv/msg/267004/766678/#msg_766678

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: What is the fastest way to make sure some names are unique? [message #825256 is a reply to message #822361] Tue, 20 March 2012 17:04 Go to previous messageGo to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
NamesAreUniqueValidator is only applied when the instance is referenced or exported. This is somehow related to NamesAreUniqueValidationHelper (as I said above) but I don't understand how.
Re: What is the fastest way to make sure some names are unique? [message #825262 is a reply to message #822352] Tue, 20 March 2012 17:10 Go to previous messageGo to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
Christian Dietrich wrote on Fri, 16 March 2012 14:59
Hi,

is your model "one model file" or "the set of all model files in a project"?

~Christian


It's in a single file. I have this enabled the fragment but only some names are validated.

Further inspection shows that only referenced names (where I have "type=[Type]") are considered. So Type.name is checked but all other names are not.
Re: What is the fastest way to make sure some names are unique? [message #825292 is a reply to message #825262] Tue, 20 March 2012 17:34 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 13468
Registered: July 2009
Senior Member
Can you share a reproduce able test case?

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: What is the fastest way to make sure some names are unique? [message #825847 is a reply to message #825292] Wed, 21 March 2012 10:28 Go to previous messageGo to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
Christian Dietrich wrote on Tue, 20 March 2012 18:34
Can you share a reproduce able test case?


Here you go.

For some reason, in this example not even the referenced names are considered. So all in all, I'm 100% confused by the NamesAreUniqueValidator.

**EDIT** Just run the tests as "JUnit test" (not JUnit plugin test).

[Updated on: Wed, 21 March 2012 13:00]

Report message to a moderator

Re: What is the fastest way to make sure some names are unique? [message #826184 is a reply to message #825847] Wed, 21 March 2012 19:22 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 13468
Registered: July 2009
Senior Member
Hi,

the problem is the way you use the parsehelper (imho its a bug in the parse helper so a ticket into bugzilla would be welcome

val model = parser.parse('''
			top e
			top f
			top f
			
			base {
				a
				b
				b
			}

			refs {
				x a
				y a
				y a
			}
		''',URI::createURI("dummy.names"))


~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: What is the fastest way to make sure some names are unique? [message #826565 is a reply to message #826184] Thu, 22 March 2012 08:22 Go to previous messageGo to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
Now, I'm confused. How is this different from ... it's the extension! If I don't provide one, then ParserHelper uses ".uri" and somehow, the validator isn't run in this case.
Re: What is the fastest way to make sure some names are unique? [message #826588 is a reply to message #826565] Thu, 22 March 2012 08:59 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 13468
Registered: July 2009
Senior Member
As i said: it (ParserHelper ) is buggy. so a bugzilla would be welcome

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: What is the fastest way to make sure some names are unique? [message #829418 is a reply to message #826588] Mon, 26 March 2012 08:57 Go to previous message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
Done: https://bugs.eclipse.org/bugs/show_bug.cgi?id=375027

I've attached an improved version of the code.
Previous Topic:alternative for opening external xtext files
Next Topic:building an Xtext project (using also Xtend) with Tycho
Goto Forum:
  


Current Time: Fri May 29 11:51:12 GMT 2020

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

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

Back to the top