2

I have a rather silly question. I am using xtext to define a simple dsl and Xpand to generate code.

Now I want to use xpand to read my dsl models and generate code. How can i do that?

I read lot of tutorials saying that I can simple do that by creating a new xtext project from the wizard. Then, among others, the following project will be created:

org.xtext.example.domainmodel.generator.

And inside, the generator looks like this:

  • src
    • model (place the dsl model)
    • templates (place the template for the code generator)
    • workflow (workflow file)

Then i simple run the workflow and generate the code from the dsl file. That s straightforwards and easy.

My problem is that when I create a new xtext project I dont get the org.xtext.example.domainmodel.generator. project. I only have the following four:

org.xtext.example.domainmodel

org.xtext.example.domainmodel.sdk

org.xtext.example.domainmodel.tests

org.xtext.example.domainmodel.ui

So how can i produce the org.xtext.example.domainmodel.generator file???

panipsilos
  • 2,219
  • 11
  • 37
  • 53

2 Answers2

0

Which tutorials do you mean? (links please) And do they really talk about a generator project? Talking about the package org.xtext.example.domainmodel.generator inside the org.xtext.example.domainmodel project is the usual thing.

A.H.
  • 63,967
  • 15
  • 92
  • 126
  • I mainly mean the official Eclipse tutorial : http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.xtext.doc%2Fhelp%2Fgetting-started-xpand.html There is a project generated called : org.eclipse.xtext.domainmodel.generator that contains the following packages: model, templates , workflow. I was able to create the generator package by adding the following line in the workflow : fragment = generator.GeneratorFragment auto-inject { generateMwe = true Can i simple create the model and template packages and drop there my model and the templates? – panipsilos Jul 01 '13 at 11:28
  • @panipsilos: Just to make things clear: Do you really use Helios? Or did you just link to the Helios help files by accident? Because the Xtext/Helios version is quite outdated and especially the code generation stuff have been changed considerably. This would also explain why you miss the generator project - modern Xtext does not have one. – A.H. Jul 01 '13 at 17:15
  • Right, I am using Eclipse galileo. I noticed that the the project is outdated. I was trying in vain to configure the new version of xtext to collaborate with xpand, without any luck I noticed that now xtext (at least in Galileo version) supports xtend out of the box. So i switched to xtend. – panipsilos Jul 02 '13 at 09:53
0

Probably not relevant to the original person who asked this :) but I had a similar problem and the reason was that in my grammar extended xbase.

When extending xbase building the mwe2 skips the generator stub generation and uses the xbase code generation which is generated instead (the antlr parser, serializer etc.)

Arnon Rotem-Gal-Oz
  • 25,469
  • 3
  • 45
  • 68