Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Questions regarding tutorial and Problems with generating Code(Code generation not triggered)
icon5.gif  Questions regarding tutorial and Problems with generating Code [message #775259] Thu, 05 January 2012 16:53 Go to next message
Tobias Böhm is currently offline Tobias Böhm
Messages: 21
Registered: January 2012
Junior Member
Hello and good day everyone,

while trying to write my first DSLs I hit a questions.

The first one is probably very simple. In the first tutorial after defining the grammar of my dsl (eclipse.org/Xtext/documentation/2_1_0/Xtext%202.1%20Documentation.pdf) 2.2 I'm generating the "Language Infrastructure" by running "Generate Xtext Artifacts" on the xtext-file. This I have to do every time I modify my .xtext-dsl, right?
In the second tutorial after defining my grammar however I "Generate language artifacts" by running "MWE2 Workflow" on the mwe2 file. Do I also have to do that every time I modify my grammar?
Why are the steps different for the two tutorials?

So after generating the xtext artifacts and starting the application I hit a main road block when I wanted to generate a source code file. I created a java project and an additional src-gen source-code-folder. Then I created a file in my DSL but the generation of the output file is never triggered. To verify I set a breakpoint at the beginning of the generated doGenerate method but it was never hit. There is no console-output so I can't really tell what the problem is.
Weird thing now is that the Statemachine-Example is working and even the generator is triggered when I change and save a file in its dsl. But I would rather be able to create a project from scratch that reusing the working example one.
I found the extended example (from the document above) but I can't find anything that I might have missed that prevents the generator from being triggered.

Is there anything that I have missed?

Thanks,
Tobi
Re: Questions regarding tutorial and Problems with generating Code [message #775303 is a reply to message #775259] Thu, 05 January 2012 18:39 Go to previous messageGo to next message
Christian Dietrich is currently online Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
Hi,

if you call "Generate Xtext Artifacts" you are actually calling the workflow (this is done through a name convention)

to you second problem: are your sure you registered your IGenerator in your Runtimemodule

~Christian
Re: Questions regarding tutorial and Problems with generating Code [message #775343 is a reply to message #775303] Thu, 05 January 2012 20:14 Go to previous messageGo to next message
Tobias Böhm is currently offline Tobias Böhm
Messages: 21
Registered: January 2012
Junior Member
Thanks for the heads up.

Regarding the generator, no I didn't register anything explicitly. The only reference to my IGenerator is in the generated class "public abstract class AbstractMyDslRuntimeModule extends DefaultRuntimeModule"

	// contributed by org.eclipse.xtext.generator.generator.GeneratorFragment
	public Class<? extends org.eclipse.xtext.generator.IGenerator> bindIGenerator() {
		return org.xtext.example.mydsl.generator.MyDslGenerator.class;
	}


Should that be enough already?
Re: Questions regarding tutorial and Problems with generating Code [message #775347 is a reply to message #775343] Thu, 05 January 2012 20:20 Go to previous messageGo to next message
Christian Dietrich is currently online Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
Hi,

yes it is. next question: is the model project a java project and the xtext nature added + build automatically activated + generator not explicitely deactivated (in project properties) for the model project.

~Christian
Re: Questions regarding tutorial and Problems with generating Code [message #775355 is a reply to message #775347] Thu, 05 January 2012 20:37 Go to previous messageGo to next message
Christian Dietrich is currently online Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
And make sure a Builder Participant is registered in the plugin.xml (of the ui project)
Re: Questions regarding tutorial and Problems with generating Code [message #775366 is a reply to message #775355] Thu, 05 January 2012 21:10 Go to previous messageGo to next message
Tobias Böhm is currently offline Tobias Böhm
Messages: 21
Registered: January 2012
Junior Member
Thanks for the help, I really appreciate it.

1. plugin.xml has an extension to point "org.eclipse.xtext.builder.participant" with the class "MyDslExecutableExtensionFactory" of package org.xtext.example.mydsl.ui
2. If by model project you mean the source project, the one where I define my dsl (created from New...->Other...->Xtext project), then yes it is a java project and the Xtext nature is added. "Build automatically" is checked.
3. I checked the project properties but I couldn't find anything regarding the generator. Only the "Compiler" options of Xtend. This compiler is activated.

Since I'm not sure what project you mean, 2. and 3. hold true for the "target" project, the one where I write code in my dsl, as well.

I copied the whole workflow of the working Statemachine-example to my mwe2 file but still no luck.

Any other idea maybe?
Re: Questions regarding tutorial and Problems with generating Code [message #775368 is a reply to message #775366] Thu, 05 January 2012 21:14 Go to previous messageGo to next message
Christian Dietrich is currently online Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
Hi,

with model project i mean the one you place the yourdsl files to.
can your share your project?

~Christian
Re: Questions regarding tutorial and Problems with generating Code [message #775375 is a reply to message #775368] Thu, 05 January 2012 21:26 Go to previous messageGo to next message
Tobias Böhm is currently offline Tobias Böhm
Messages: 21
Registered: January 2012
Junior Member
Sure, I put it on my Dropbox:
(I'm not allowed to share links yet...just replace those two <slash> with actual slashes)
http:<slash><slash>dl.dropbox.com/u/6465579/Projects/Xtext-Example/Xtext-Example.tar.gz
Thanks,
Tobi
Re: Questions regarding tutorial and Problems with generating Code [message #775379 is a reply to message #775375] Thu, 05 January 2012 21:40 Go to previous messageGo to next message
Christian Dietrich is currently online Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
works for me e.g. getting

package org.eclipselabs.recommenders.codesearchquery.rcp.indexer.lucene;

public class Fields {
	/**
			 * Can be applied to: org.xtext.example.mydsl.myDsl.impl.FieldTypeImpl@82ab51 (class: class, method: null, field: null, trycatch: null)*/
			public final static String Name = Value;
}
for
Name; "Value" ; class


so there must be something strange with your model project / runtime eclipse
Re: Questions regarding tutorial and Problems with generating Code [message #775382 is a reply to message #775379] Thu, 05 January 2012 21:52 Go to previous messageGo to next message
Tobias Böhm is currently offline Tobias Böhm
Messages: 21
Registered: January 2012
Junior Member
So we're getting closer.
I uploaded my model project as well (http:<slash><slash>dl.dropbox.com/u/6465579/Projects/Xtext-Example/Test01.tar.gz). Can you find something in there?
Regarding the eclipse runtime. What could I have done wrong there?
I selected launch with "all worspace and enabled target plug-ins" and those two projects are the only ones open in my workspace at the moment.
Re: Questions regarding tutorial and Problems with generating Code [message #775384 is a reply to message #775382] Thu, 05 January 2012 21:57 Go to previous messageGo to next message
Christian Dietrich is currently online Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
Hi,

mydsl != myDsl

somehow the editor works case insensitive regarding the file extension but the builder is case sensitive

~Christian
Re: Questions regarding tutorial and Problems with generating Code [message #775387 is a reply to message #775384] Thu, 05 January 2012 22:00 Go to previous message
Tobias Böhm is currently offline Tobias Böhm
Messages: 21
Registered: January 2012
Junior Member
oh my... how stupid I was.
I was looking at "generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"" and thought I must use that extension but instead the one defined in the mwe2 file, file.extensions, right?

On the other hand, maybe that should really just be a consistent behaviour, shouldn't it?

Thank you very much for your help.
Previous Topic:Debugging ComparisonFailure exceptions via SerializerTests.assertEqualWithEmfFormatter
Next Topic:Serialization format
Goto Forum:
  


Current Time: Fri Oct 24 12:57:34 GMT 2014

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

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