Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Generating code in project with classpath awareness
icon5.gif  Generating code in project with classpath awareness [message #649983] Fri, 21 January 2011 09:55 Go to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 112
Registered: June 2010
Senior Member
Hello,

I defined a DSL with Xtext, now I would like to define a code generator that would exploit it.

Knowing that my DSL is using using JavaVMTypes to reference java classes in the classpath of the current project and namespace naming of elements (with several files of the dsl anywhere in the classpath of the project)

So, what I would like is to be able to do the following:
I edit one or several dsl files in my Java project
I eventually edit one configuration file for my whole project to configure the generation
I generate for my whole project from the content of all the dsl files in the src directories, taking eventually into account imported files from other projects.
The generator would output in a src-gen directory in the java project.

I don't want my users to modify a mwe2 file, and execute it and stuffs like that, the best would be to run the generation for the project from an Eclipse menu.
Possibly, it would be nice if generation could be triggered from maven also, but well, let's not ask too much for now :)

In a way I want to mimic how the java compilation work, but with generation triggered by hand (for now at least).

Does anyone have example projects that does that, or guidelines and known pitfalls about it?
I am sure it is not so hard, but I remember there was problem with the access to a project classpath by a workflow in the past that prevented me to do it in practice!

Thank you very much!

Victor
Re: Generating code in project with classpath awareness [message #650013 is a reply to message #649983] Fri, 21 January 2011 13:09 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
You have to run the code generator from within the IDE. Have a look at
how we do that in the domainmodel example:
/org.eclipse.xtext.example.domainmodel.ui/src/org/eclipse/xt ext/example/ui/generator/Generator.java


Am 21.01.11 10:55, schrieb Victor v:
> Hello,
>
> I defined a DSL with Xtext, now I would like to define a code generator
> that would exploit it.
>
> Knowing that my DSL is using using JavaVMTypes to reference java classes
> in the classpath of the current project and namespace naming of elements
> (with several files of the dsl anywhere in the classpath of the project)
>
> So, what I would like is to be able to do the following:
> I edit one or several dsl files in my Java project
> I eventually edit one configuration file for my whole project to
> configure the generation
> I generate for my whole project from the content of all the dsl files in
> the src directories, taking eventually into account imported files from
> other projects.
> The generator would output in a src-gen directory in the java project.
>
> I don't want my users to modify a mwe2 file, and execute it and stuffs
> like that, the best would be to run the generation for the project from
> an Eclipse menu.
> Possibly, it would be nice if generation could be triggered from maven
> also, but well, let's not ask too much for now :)
>
> In a way I want to mimic how the java compilation work, but with
> generation triggered by hand (for now at least).
>
> Does anyone have example projects that does that, or guidelines and
> known pitfalls about it?
> I am sure it is not so hard, but I remember there was problem with the
> access to a project classpath by a workflow in the past that prevented
> me to do it in practice!
>
> Thank you very much!
>
> Victor


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Previous Topic:a string representation for program elements (EObjects)
Next Topic:Icons for Code Completion Proposals
Goto Forum:
  


Current Time: Fri Apr 26 22:12:56 GMT 2024

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

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

Back to the top