Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Two DSLs in one Eclipse project(Noob)
Two DSLs in one Eclipse project [message #1153464] Thu, 24 October 2013 16:30 Go to next message
Gary Worsham is currently offline Gary WorshamFriend
Messages: 176
Registered: September 2013
Senior Member
OK, last night I actually got some preliminary Xtend code generation working! Shocked

Here's my long term goal and why I think I might want to use 2 DSLs in one Eclipse project.

My first DSL/XText models a block of DSP code with input and output connections. For any given algorithm, several of these can be linked together in different ways to create the overall processing function. Each different block defined needs to have an entry in the Swing application's menu to allow the user to insert it. So, I have bunch of different blocks in my end application.

Right now, using brute force Java, I create the new block class and then I go over to the Swing JFrame class which contains the menu definition and I add code that creates a new menu entry to call the block's insert() method. I'd just as soon have a menu creation DSL possible at the same time (with a different source file type, of course) to handle this. There is only one menu in the end application, though I can imagine that different users might want to customize it one way or the other.

Then my menu definition file could be a very simplified representation. When it generated code (or perhaps in the validation step) it would look up the block class by name, and of course complain if it couldn't find it. Then I imagine it would create the menu class, which would be called by reference instead of inline in my JFrame as done currently.

Any reason I can't just define a second Xtext and corresponding Xtend file for this menu creation code in my existing project?

By the way I did find a similar discussion here:

http://www.eclipse.org/forums/index.php/m/927101/?srch=multiple+DSL#msg_927101

but it's not quite what I am asking.

Thanks,

GW

[Updated on: Thu, 24 October 2013 16:54]

Report message to a moderator

Re: Two DSLs in one Eclipse project [message #1153509 is a reply to message #1153464] Thu, 24 October 2013 17:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13493
Registered: July 2009
Senior Member
Hi you can do this.
Add a second language part to the workflow.
You may find examples in the forum/web

p.S. maybe i got your question totally wrong

--
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


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 24 October 2013 18:11]

Report message to a moderator

Re: Two DSLs in one Eclipse project [message #1153698 is a reply to message #1153509] Thu, 24 October 2013 19:57 Go to previous messageGo to next message
Gary Worsham is currently offline Gary WorshamFriend
Messages: 176
Registered: September 2013
Senior Member
One thing I don't understand is the difference between selecting the Xtext file and choosing Run As...Generate Xtext Artifacts compared to selecting the mwe2 file and choosing Run As...Generate MWE2 Workflow.

In general, up to now I have selected the Xtext file, then click on the green "Run" button. After that completes, I select the top-level package and click on the Green "Run" button again, which launches Eclipse. Most of the time this works OK, but in many of the examples the mwe2 workflow is referenced. Although I have read these descriptions several times, I still have no idea what an mwe2 workflow is, what it does, and whether I need to worry about it.

[Updated on: Thu, 24 October 2013 19:58]

Report message to a moderator

Re: Two DSLs in one Eclipse project [message #1153720 is a reply to message #1153698] Thu, 24 October 2013 20:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13493
Registered: July 2009
Senior Member
Hi,

It is a "naming convention" with the mwe file youre on the save side


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Two DSLs in one Eclipse project [message #1153726 is a reply to message #1153720] Thu, 24 October 2013 20:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13493
Registered: July 2009
Senior Member
P.S:

a mwe workflow is basically a dsl to glue together a java object tree. (thats all)


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Two DSLs in one Eclipse project [message #1171110 is a reply to message #1153726] Tue, 05 November 2013 03:14 Go to previous messageGo to next message
Gary Worsham is currently offline Gary WorshamFriend
Messages: 176
Registered: September 2013
Senior Member
OK I finally tried this today.

I have an existing grammar SpinCAD.xtext.

Next to this, in the same package, I created a new grammar file, SpinCADMenu.xtext. I did not use any project creation wizard.

When I right click on SpinCADMenu.xtext, I don't get "Generate Xtext Artifacts".

So I copied GenerateSpinCAD.mwe2 to GenerateSpinCADMenu.mwe2 and changed some entries as follows:

GenerateSpinCAD.mwe2
var grammarURI = "classpath:/com/holycityaudio/spincad/SpinCAD.xtext"
var fileExtensions = "spincad"
var projectName = "spincad"


GenerateSpinCADMenu.mwe2
var grammarURI = "classpath:/com/holycityaudio/spincad/SpinCADMenu.xtext"
var fileExtensions = "spincadmenu"
var projectName = "spincad"



Now I can right click on GenerateSpinCADMenu.mwe2 and select "Generate MWE2 Workflow".

I get some classes created:

SpinCADMenuRuntimeModule.java
SpinCADMenuStandaloneSetup.java

Simultaneously, I get errors in the existing methods:

SpinCADRuntimeModule.java
SpinCADStandaloneSetup.java

com.holycityaudio.spincad.AbstractSpinCADRuntimeModule cannot be resolved to a type
The method createInjectorAndDoEMFRegistration() is undefined for the type SpinCADStandaloneSetup

I suppose I could continue to chase this around, but I think I am doing something fundamentally wrong.

Here's my goal.

I have an existing hand written Java application. To this I have added Java classes which were generated by the "spincad" grammar and Xtend code generator. This is working pretty well.

Now I wish to add a different grammar to the story, so that I can write "spincadmenu" grammar files and have them create other Java classes to be included in the same Java application.

But it looks to me that I can really only work on one grammar at a time. How do I bring them together in a single project?
Re: Two DSLs in one Eclipse project [message #1171220 is a reply to message #1171110] Tue, 05 November 2013 04:57 Go to previous messageGo to next message
Gary Worsham is currently offline Gary WorshamFriend
Messages: 176
Registered: September 2013
Senior Member
OK since that didn't work, I ran the "New Xtext Wizard" and arranged it so that the new grammar uses the same packages as the other one. This looks promising..
Re: Two DSLs in one Eclipse project [message #1177003 is a reply to message #1171220] Fri, 08 November 2013 18:00 Go to previous message
Gary Worsham is currently offline Gary WorshamFriend
Messages: 176
Registered: September 2013
Senior Member
It's working pretty well so far. Very Happy I do get a message while launching my DSL enabled instance of Eclipse that I have two xtext files which reference the same package, but that is to be expected.
Previous Topic:Xtend local variable scope?
Next Topic:Embarrassing Data Type rule question [solved]
Goto Forum:
  


Current Time: Fri Jul 10 17:28:32 GMT 2020

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

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

Back to the top