Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » XText Binding Generators from another Project
XText Binding Generators from another Project [message #1796265] Tue, 09 October 2018 11:56 Go to next message
Mehmetcan Sinir is currently offline Mehmetcan SinirFriend
Messages: 55
Registered: September 2018
Member
When I start a new XText Project, and then generate the XText Artifacts from my XText File, A RunTimeModule is automatically created in the core logic Project where the xtext File defined, so that I can bind my own generators and validators.

Depending on my workflow, XText also automatically creates packages for generators and validation, also within this core Project.

Let's say I have another Project, where additional generators are defined, and this Project is dependent on the core Project where my RunTimeModule is.

But the core Project itself of course has no access to this second Project.

How can I bind these generators in this second Project, since in my RunTimeModule I have no access to these other generators?

To make it clearer
org.xtext.myDsl (Core Xtext Project)
    ---- org.xtext.myDsl
             ----MyDsl.xtext
            ----MyDslRuntimeModule.xtend
    ---- org.xtext.myDsl.Generator
    ----- org.xtext.myDsl.validation

org.xtext.second.myDsl (second Project dependent on org.xtext.msDsl)
      --- org.xtext.second.myDsl.generator (I want to bind the generators here)

[Updated on: Tue, 09 October 2018 12:01]

Report message to a moderator

Re: XText Binding Generators from another Project [message #1796266 is a reply to message #1796265] Tue, 09 October 2018 11:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
the generators are "found" via the

<extension point="org.eclipse.xtext.builder.participant">
<participant
class="org.xtext.example.mydsl.ui.MyDslExecutableExtensionFactory:org.eclipse.xtext.builder.IXtextBuilderParticipant"
fileExtensions="mydsl"/>
</extension>

extension point.

so you could do this with a custom MyDslGeneratorExecutableExtensionFactory (+ Activator + Bindings etc)


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: XText Binding Generators from another Project [message #1796267 is a reply to message #1796266] Tue, 09 October 2018 11:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
For standalone:

it depends on how you want to call the generators


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: XText Binding Generators from another Project [message #1796268 is a reply to message #1796267] Tue, 09 October 2018 12:03 Go to previous messageGo to next message
Mehmetcan Sinir is currently offline Mehmetcan SinirFriend
Messages: 55
Registered: September 2018
Member
thanks again, let's see how I can do that=)
Re: XText Binding Generators from another Project [message #1796269 is a reply to message #1796267] Tue, 09 October 2018 12:03 Go to previous messageGo to next message
Mehmetcan Sinir is currently offline Mehmetcan SinirFriend
Messages: 55
Registered: September 2018
Member
thanks again, let's see how I can do that=)
For standalone: I want to call the generators on every save
Re: XText Binding Generators from another Project [message #1796270 is a reply to message #1796268] Tue, 09 October 2018 12:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
which usecase do you target: eclipse or standalone?

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: XText Binding Generators from another Project [message #1796271 is a reply to message #1796270] Tue, 09 October 2018 12:05 Go to previous messageGo to next message
Mehmetcan Sinir is currently offline Mehmetcan SinirFriend
Messages: 55
Registered: September 2018
Member
Christian Dietrich wrote on Tue, 09 October 2018 12:03
which usecase do you target: eclipse or standalone?


Standalone

I am building an VS-Code Plugin
Re: XText Binding Generators from another Project [message #1796273 is a reply to message #1796271] Tue, 09 October 2018 12:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
then this wont work.

do you call the generator automatically or via command?
in both cases you need to make sure you call a composite generator in the end
(IGenerator2 that delegates to all generators you have)


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: XText Binding Generators from another Project [message #1796274 is a reply to message #1796273] Tue, 09 October 2018 12:19 Go to previous messageGo to next message
Mehmetcan Sinir is currently offline Mehmetcan SinirFriend
Messages: 55
Registered: September 2018
Member
Christian Dietrich wrote on Tue, 09 October 2018 12:13
then this wont work.

do you call the generator automatically or via command?
in both cases you need to make sure you call a composite generator in the end
(IGenerator2 that delegates to all generators you have)


I want the generators to be called every time I save the file Visual Studio Code

so I guess then the only way is to bind the generator like this

	// contributed by org.eclipse.xtext.xtext.generator.generator.GeneratorFragment2
	public Class<? extends IGenerator2> bindIGenerator2() {
		return MyDslGenerator.class;
	}


So I need a main IGenerator2 delegate that delegates to all my generators within the doGenerate method right?
Re: XText Binding Generators from another Project [message #1796275 is a reply to message #1796274] Tue, 09 October 2018 12:24 Go to previous messageGo to next message
Mehmetcan Sinir is currently offline Mehmetcan SinirFriend
Messages: 55
Registered: September 2018
Member
so
IXtextBuilderParticipant
allows me to process resources that are built by an Eclipse Project Builder.

But I cannot use this with VS-Code right?

Do you perhaps know if something similar exists for VS-Code?

Re: XText Binding Generators from another Project [message #1796280 is a reply to message #1796275] Tue, 09 October 2018 12:56 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
no in viscode you have to have a single IGenerator2
(you have create a delegating one in yourdsl.ide though)


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
Previous Topic:Serialization of Xtext model
Next Topic:IXTextBuilderParticipant for VS Code
Goto Forum:
  


Current Time: Sat Sep 18 05:49:14 GMT 2021

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

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

Back to the top