Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Xtext : Unicity element
Xtext : Unicity element [message #1764029] Wed, 24 May 2017 04:24 Go to next message
Eclipse UserFriend
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 04:26 Go to previous messageGo to next message
Eclipse UserFriend
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)
Re: Xtext : Unicity element [message #1764038 is a reply to message #1764031] Wed, 24 May 2017 04:40 Go to previous messageGo to next message
Eclipse UserFriend
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 04:58 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Xtext : Unicity element [message #1764052 is a reply to message #1764040] Wed, 24 May 2017 08:17 Go to previous message
Eclipse UserFriend
Thanks, I will see it.
Previous Topic:[SOLVED] Xtext : Personalize Description
Next Topic:Format on Save in Editor
Goto Forum:
  


Current Time: Sat Aug 30 22:52:36 EDT 2025

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

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

Back to the top