Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext : Unicity element
Xtext : Unicity element [message #1764029] Wed, 24 May 2017 08:24 Go to next message
Pascal Lacabanne is currently offline Pascal LacabanneFriend
Messages: 17
Registered: November 2016
Junior Member
Hi,

I have a new problem. In my grammar, I want to have the unicity between objects.
If the objects déclarations are in the same file, that works. I uncomment this part :

[code]
composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
[\code]

However, if element are not in the same file, that does not work.


I created a new function in MyDslValidator. I retrieve my element but I can not compare it with others elements.

I would like to know how I can have access at all created objects. I read in the forum I can use the GlobalScopeProvider.

How can I do that or is there another method ?
Thank you

Re: Xtext : Unicity element [message #1764031 is a reply to message #1764029] Wed, 24 May 2017 08:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
Hi,

can you explain why NamesAreUniqueValidator does not work?
did you rerun the workflow? did you change the validator superclass?
it basically does what you need (query the index and search for duplicates)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Xtext : Unicity element [message #1764038 is a reply to message #1764031] Wed, 24 May 2017 08:40 Go to previous messageGo to next message
Pascal Lacabanne is currently offline Pascal LacabanneFriend
Messages: 17
Registered: November 2016
Junior Member
That does not work because (I believe) I use "package". Here, an exemple :

My First file
package fts {
     OBJ obj1
     Description "Text 1"

     OBJ obj1
     Description "Text 2"
}


My Second file
package fts {
     OBJ obj1
     Description "Text 1"
}


In my first file, I retrieve the errors. The two objects have the same id.
But in my second file, I do not have the error. For me, the Id have to be unique even if the object is in another package.

Is that clear ( I m french) ?
Re: Xtext : Unicity element [message #1764040 is a reply to message #1764038] Wed, 24 May 2017 08:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
hmmm good question

looks like that validator is not doing what it tells.

maybe you can use/inspire by the code in

org.eclipse.xtext.xbase.validation.UniqueClassNameValidator

and

org.eclipse.xtext.xbase.ui.validation.ProjectAwareUniqueClassNameValidator


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Xtext : Unicity element [message #1764052 is a reply to message #1764040] Wed, 24 May 2017 12:17 Go to previous message
Pascal Lacabanne is currently offline Pascal LacabanneFriend
Messages: 17
Registered: November 2016
Junior Member
Thanks, I will see it.
Previous Topic:[SOLVED] Xtext : Personalize Description
Next Topic:Format on Save in Editor
Goto Forum:
  


Current Time: Sat Dec 07 18:51:39 GMT 2024

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

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

Back to the top