Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to extend Xtext DSL to use a validation class packaged with a library model ?
How to extend Xtext DSL to use a validation class packaged with a library model ? [message #899075] Mon, 30 July 2012 09:38 Go to next message
Cristiano Gaviao is currently offline Cristiano Gaviao
Messages: 253
Registered: July 2009
Senior Member
Hi,

I'm working with one DSL and some library models that are packaged in its own bundles and could be installed separated.

I would like to deliver one validation class together to its own library (to deal with elements delivered by its library) but I don't want to add any dependency from the DSL to the libraries.

Could someone point me how could I do this ?

thanks,

Cristiano
Re: How to extend Xtext DSL to use a validation class packaged with a library model ? [message #899091 is a reply to message #899075] Mon, 30 July 2012 10:22 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik Lindberg
Messages: 2498
Registered: July 2009
Senior Member
Hi,
IIRC, the validation uses all registered validators for a model.
Explore the source how your DSL's JavaValidator gets registered and called.

So, basically, the optional library extensions would register their
accompanying validators the same way.

Sorry, but I don't remember the details, but hope that helps you somewhat.

Regards
- henrik

On 2012-30-07 15:38, Cristiano Gaviao wrote:
> Hi,
> I'm working with one DSL and some library models that are packaged in
> its own bundles and could be installed separated.
>
> I would like to deliver one validation class together to its own library
> (to deal with elements delivered by its library) but I don't want to add
> any dependency from the DSL to the libraries.
>
> Could someone point me how could I do this ?
>
> thanks,
>
> Cristiano
Re: How to extend Xtext DSL to use a validation class packaged with a library model ? [message #899118 is a reply to message #899091] Mon, 30 July 2012 11:25 Go to previous messageGo to next message
Cristiano Gaviao is currently offline Cristiano Gaviao
Messages: 253
Registered: July 2009
Senior Member
Hi Henrik,

Well, I study the source and I know that the default validation class is binded in the DslRuntimeModule class.

But, unfortunately I have no idea how I should register my custom validation class being it in another bundle and with a different lifecycle than master DSL bundles. Sad

any tip on that ?

thanks,

Cristiano
Re: How to extend Xtext DSL to use a validation class packaged with a library model ? [message #899126 is a reply to message #899118] Mon, 30 July 2012 11:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6143
Registered: July 2009
Senior Member
Hi what about doing the same as Xtext does. Let the activator create
an injector with a guice modules that has an eager binding to the
validator?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: How to extend Xtext DSL to use a validation class packaged with a library model ? [message #899150 is a reply to message #899126] Mon, 30 July 2012 12:46 Go to previous messageGo to next message
Cristiano Gaviao is currently offline Cristiano Gaviao
Messages: 253
Registered: July 2009
Senior Member
Christian Dietrich wrote on Mon, 30 July 2012 18:35
Hi what about doing the same as Xtext does. Let the activator create
an injector with a guice modules that has an eager binding to the
validator?


Hi,

Well, I swear that I've tried to understand what the UI activator is doing, but there is nothing being activated in the activator start() method :/

Who is activating the injectors ?
Re: How to extend Xtext DSL to use a validation class packaged with a library model ? [message #899155 is a reply to message #899150] Mon, 30 July 2012 13:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6143
Registered: July 2009
Senior Member
Hi,

its done by MyDslExecutableExtensionFactory

~Christian
Re: How to extend Xtext DSL to use a validation class packaged with a library model ? [message #899198 is a reply to message #899155] Mon, 30 July 2012 23:00 Go to previous messageGo to next message
Cristiano Gaviao is currently offline Cristiano Gaviao
Messages: 253
Registered: July 2009
Senior Member
Christian Dietrich wrote on Mon, 30 July 2012 20:04
Hi,

its done by MyDslExecutableExtensionFactory

~Christian


Ok Christian,

I think I'm understanding how things starts... but I'm still with doubts.

I've create a new MyDataLibraryExecutableExtensionFactory and use it in the plugin.xml with some extension point.

I've created my MyDataLibraryModule and added this to it:
	@org.eclipse.xtext.service.SingletonBinding(eager=true)	public Class<? extends AbstractDeclarativeValidator> bindMyDataLibraryJavaValidator() {
		return MyDataLibraryTemplateJavaValidator.class;
	}
@Override
	public void configure(Binder binder) {
		super.configure(binder);
		
		binder.bind(AbstractUIPlugin.class).toInstance(plugin);
	}


But how should I use it ?
should I create a new child Injector using as parent the Injector from the MyDslActivator.getInstance().getInjector()?

regards,

Cristiano

[Updated on: Mon, 30 July 2012 23:15]

Report message to a moderator

Re: How to extend Xtext DSL to use a validation class packaged with a library model ? [message #899208 is a reply to message #899198] Tue, 31 July 2012 01:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6143
Registered: July 2009
Senior Member
Hi sorry do not understand. You said you want to create something
self-contained so you may simply create a new injector with the new
module in the start method

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: How to extend Xtext DSL to use a validation class packaged with a library model ? [message #899304 is a reply to message #899208] Tue, 31 July 2012 08:25 Go to previous messageGo to next message
Cristiano Gaviao is currently offline Cristiano Gaviao
Messages: 253
Registered: July 2009
Senior Member
Hi,

Well, the goal is to trigger a custom validation method of a class that extends AbstractDeclarativeValidator and is packaged with in a Data Library bundle when editing a text in the main DSL editor.

I've tried to create a new Injector and also to create a child Injector, but both seems no work. At least the validation method is not being triggered.

what am I missing here ?

thanks,

Cristiano
Re: How to extend Xtext DSL to use a validation class packaged with a library model ? [message #899321 is a reply to message #899304] Tue, 31 July 2012 09:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6143
Registered: July 2009
Senior Member
Hi you implement the getepackages or something like that in the
validator?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: How to extend Xtext DSL to use a validation class packaged with a library model ? [message #899579 is a reply to message #899321] Wed, 01 August 2012 09:53 Go to previous message
Cristiano Gaviao is currently offline Cristiano Gaviao
Messages: 253
Registered: July 2009
Senior Member
Hi Christian,

I could make it work. Now the validation methods are being called properly.

The problem was the way that I've setup guice.

thanks.

Cristiano
Previous Topic:[Grammar] Declaration and definition of variables for a DSL
Next Topic:Variable declaration
Goto Forum:
  


Current Time: Wed Jul 30 17:21:11 EDT 2014

Powered by FUDForum. Page generated in 0.01808 seconds