Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Initialization in Xtext Validation(Initialization in Xtext Validation)
icon5.gif  Initialization in Xtext Validation [message #1662866] Tue, 10 March 2015 02:49 Go to next message
Eclipse UserFriend
Hi all,
I have a validation class. My all validation warnings/ error markers use some common data.

So I want to prepare some common data before even a single validation check is triggered.

Is there something already available to initialize data before checks are invoked ?


Thanks for any help Smile
Re: Initialization in Xtext Validation [message #1662876 is a reply to message #1662866] Tue, 10 March 2015 02:50 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

is the common data context free or not (depends on model)?

~Christian
Re: Initialization in Xtext Validation [message #1663016 is a reply to message #1662876] Tue, 10 March 2015 04:17 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian,
Thanks for the reply.
Yes its context free data. It does not depend on the model.

Regards,
Arshad
Re: Initialization in Xtext Validation [message #1663066 is a reply to message #1663016] Tue, 10 March 2015 04:47 Go to previous messageGo to next message
Eclipse UserFriend
you could do this eg. in the register method of the validator then
Re: Initialization in Xtext Validation [message #1663128 is a reply to message #1663066] Tue, 10 March 2015 05:24 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Thanks Christian..

Can't I write a static block for the validation class ?

Will it have problems ?


Regards,
Arshad
Re: Initialization in Xtext Validation [message #1663145 is a reply to message #1663128] Tue, 10 March 2015 05:31 Go to previous messageGo to next message
Eclipse UserFriend
i dont know
Re: Initialization in Xtext Validation [message #1679122 is a reply to message #1663145] Mon, 16 March 2015 09:32 Go to previous messageGo to next message
Eclipse UserFriend
Let me chime in here:
In some validators I do some caching which is valid for the duration of validating one resource.
I would be interested in hooks for (initializing and) clearing that cache.
I.e., more importantly than initialization (which I can do on-demand), I'd need a hook that is triggered when validation for a particular resource is done.
It seems I would need to override one of the final validate or internalValidate methods :-/

Stephan
Re: Initialization in Xtext Validation [message #1679123 is a reply to message #1679122] Mon, 16 March 2015 09:34 Go to previous messageGo to next message
Eclipse UserFriend
hi,

have a look at org.eclipse.xtext.validation.AbstractDeclarativeValidator.getContext() maybe it can be used as cache storage

[Updated on: Mon, 16 March 2015 09:37] by Moderator

Re: Initialization in Xtext Validation [message #1679214 is a reply to message #1679123] Mon, 16 March 2015 10:20 Go to previous messageGo to next message
Eclipse UserFriend
Quote:
have a look at org.eclipse.xtext.validation.AbstractDeclarativeValidator.getContext() maybe it can be used as cache storage


Thanks.
Can you say what is the lifecycle of that map? Is it ever cleared?
Re: Initialization in Xtext Validation [message #1679224 is a reply to message #1679214] Mon, 16 March 2015 10:25 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

afaik it is per resource
Re: Initialization in Xtext Validation [message #1679243 is a reply to message #1679224] Mon, 16 March 2015 10:32 Go to previous messageGo to next message
Eclipse UserFriend
Quote:
afaik it is per resource


sounds good, thanks.
Re: Initialization in Xtext Validation [message #1679274 is a reply to message #1679243] Mon, 16 March 2015 10:47 Go to previous message
Eclipse UserFriend
To close the loop: the following method defines the lifecycle of that context map:
org.eclipse.emf.ecore.util.Diagnostician.validate(EObject, Map<?, ?>)

So if no-one leaks the reference to the map it should be subject to GC after that method terminates.
And indeed this validate method is invoked for the main element of each resource.
While it does not provide a hook for cleanup it should implicitly free the memory.

thanks again.
Previous Topic:Xtext grammar : mismatched input '0' expecting RULE_INT
Next Topic:Warning for unused declarations
Goto Forum:
  


Current Time: Fri Nov 07 17:58:34 EST 2025

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

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

Back to the top