Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Validation in Xtext(Validation in Xtext)
icon5.gif  Validation in Xtext [message #1693733] Tue, 28 April 2015 04:16 Go to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
HI all,

I have some common data which should go into all my validation checks.
This data is dependent on the model and I want to prepare this common data from my model before all the @Checks are called.

Is there any way to achieve this ?



Thanks for any help Smile


Arshad
Re: Validation in Xtext [message #1693734 is a reply to message #1693733] Tue, 28 April 2015 04:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13885
Registered: July 2009
Senior Member
Hi,

please define "the model" is it the file a part of a file the whole project ....

you may have a look at org.eclipse.xtext.validation.AbstractDeclarativeValidator.getContext()


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
icon5.gif  Re: Validation in Xtext [message #1693735 is a reply to message #1693734] Tue, 28 April 2015 04:34 Go to previous messageGo to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi Christian,

Its the resource that I save.


Regards,
Arshad


Arshad
Re: Validation in Xtext [message #1693736 is a reply to message #1693735] Tue, 28 April 2015 04:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13885
Registered: July 2009
Senior Member
can you elaborate a bit more on your usecase? what do you do with that kind of "data"

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
icon5.gif  Re: Validation in Xtext [message #1693742 is a reply to message #1693736] Tue, 28 April 2015 05:23 Go to previous messageGo to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi Christian,

When I save my file, in my validation class I get the root object for it (i.e. the object which contains whole data).

From this resource data I want to retrieve some common data by applying some business logic.

This common data I want to use in more than one @check methods.




Regards,
Arshad


Arshad
Re: Validation in Xtext [message #1693748 is a reply to message #1693742] Tue, 28 April 2015 06:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13885
Registered: July 2009
Senior Member
Then give the context a try (use it as cache)

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Validation in Xtext [message #1693751 is a reply to message #1693733] Tue, 28 April 2015 06:48 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 747
Registered: July 2009
Location: Dortmund, Germany
Senior Member

You could also use IDerivedStateComputer to put the derived common data into your resource on save.

Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
icon5.gif  Re: Validation in Xtext [message #1693766 is a reply to message #1693751] Tue, 28 April 2015 09:04 Go to previous messageGo to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi Christian,

Thanks for the info.
I will go ahead with your suggestion.

One more question I have:

Suppose I am modifying a file, in the background all the validations which do not have CheckType.Normal will be called.

i.e. by default it will be CheckType.Fast. I want to avoid the validations if there are no real changes in the editor . Consider a case where I just enter a whitespace.

Can we achieve this ..?


Regards,
Arshad


Arshad
Re: Validation in Xtext [message #1695245 is a reply to message #1693766] Wed, 13 May 2015 03:24 Go to previous message
Bob Tao is currently offline Bob TaoFriend
Messages: 23
Registered: March 2015
Junior Member

Using the context and check type feature solve my validation performance problem.
Thank Christian.
Previous Topic:Getting all JvmTypes matching a wildcard import
Next Topic:Antlr version
Goto Forum:
  


Current Time: Mon Apr 19 00:31:19 GMT 2021

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

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

Back to the top