Skip to main content


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 13:38 Go to next message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
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 14:22 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
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 15:25 Go to previous messageGo to next message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
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 15:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.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 16:46 Go to previous messageGo to next message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
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 17:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

its done by MyDslExecutableExtensionFactory

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to extend Xtext DSL to use a validation class packaged with a library model ? [message #899198 is a reply to message #899155] Tue, 31 July 2012 03:00 Go to previous messageGo to next message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
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: Tue, 31 July 2012 03: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 05:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.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 12:25 Go to previous messageGo to next message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
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 13:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.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 13:53 Go to previous message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
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: Fri Mar 29 08:36:01 GMT 2024

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

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

Back to the top