Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » JVMModelInferrer - suppressing java code generation
JVMModelInferrer - suppressing java code generation [message #898030] Wed, 25 July 2012 16:12 Go to next message
Florian Pirchner is currently offline Florian PirchnerFriend
Messages: 94
Registered: July 2009
Member

Hi,

we are writing an entity DSL that works really fine. It is based on Xbase and we are using the ModelInferrer to provide a JVMModel. This JVMModel will also be used to generate the jave code by Xbase internal JvmModelGenerator.
So far, everything is fine.

But now i have to suppress the generation of the java code.
Therefore i added a flag "no source" to my grammar. If true, then no java code should be generated. But the JVMModel should still be created by the JVMModelInferrer, so that JVM-elements can still be used / referenced inside the model. The only difference should be, that no java code output should be created.

Question: Is it possible to set a flag somewhere from / in the JVMModelInferrer to suppress the java code generation. Could not find anything.
Like this:
MyModelInferrer.class
if(model.noSource)
   setJavaCodeGen(false)
...


Additional info - practical usecase:
I have created a second model - JPA model. It can be used to address entities from the EntityModel and offers the semantics to redefine the JPA defaults. If not redefined, the JPA code for the selected entities is generated with a good default. But the java code generation must be supressed for the EntityModel. Only the JPAModel should generate the code in that case.
And the user can decide how he would like to use the model. Only generating entities for use without persistence. Or generating JPAEntities based on the entity model.

Following JPAModel will generate all entities contained in package your.jpa.* or my.jpa.* as JPAEntities. But the generation of the entity model should not be processed.
include your.jpa.*
include my.jpa.*

redefines your.jpa.Cat as noncacheable embeddable MyNewCat{
	schema MY_SCHEMA
	table MY_TABLE
}  


Thanks,
Florian

Re: JVMModelInferrer - suppressing java code generation [message #898037 is a reply to message #898030] Wed, 25 July 2012 16:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13352
Registered: July 2009
Senior Member
Guess you should customize jvmmodelgenerator.

--
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
Re: JVMModelInferrer - suppressing java code generation [message #898040 is a reply to message #898030] Wed, 25 July 2012 16:28 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3107
Registered: July 2009
Senior Member
Hi Flo,

you may want to use the IJvmModelAssociations to obtain the original
model and check the given flag in a custom generator implementation.

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

Am 25.07.12 18:12, schrieb Florian Pirchner:
> Hi,
>
> we are writing an entity DSL that works really fine. It is based on
> Xbase and we are using the ModelInferrer to provide a JVMModel. This
> JVMModel will also be used to generate the jave code by Xbase internal
> JvmModelGenerator.
> So far, everything is fine.
>
> But now i have to suppress the generation of the java code. Therefore i
> added a flag "no source" to my grammar. If true, then no java code
> should be generated. But the JVMModel should still be created by the
> JVMModelInferrer, so that JVM-elements can still be used / referenced
> inside the model. The only difference should be, that no java code
> output should be created.
>
> Question: Is it possible to set a flag somewhere from / in the
> JVMModelInferrer to suppress the java code generation. Could not find
> anything.
> Like this:
>
> MyModelInferrer.class
> if(model.noSource)
> setJavaCodeGen(false)
> ...
>
>
> Additional info - practical usecase:
> I have created a second model - JPA model. It can be used to address
> entities from the EntityModel and offers the semantics to redefine the
> JPA defaults. If not redefined, the JPA code for the selected entities
> is generated with a good default. But the java code generation must be
> supressed for the EntityModel. Only the JPAModel should generate the
> code in that case.
> And the user can decide how he would like to use the model. Only
> generating entities for use without persistence. Or generating
> JPAEntities based on the entity model.
>
> Following JPAModel will generate all entities contained in package
> your.jpa.* or my.jpa.* as JPAEntities. But the generation of the entity
> model should not be processed.
>
> include your.jpa.*
> include my.jpa.*
>
> redefines your.jpa.Cat as noncacheable embeddable MyNewCat{
> schema MY_SCHEMA
> table MY_TABLE
> }
>
> Thanks,
> Florian
>
>
Re: JVMModelInferrer - suppressing java code generation [message #898044 is a reply to message #898040] Wed, 25 July 2012 16:38 Go to previous message
Florian Pirchner is currently offline Florian PirchnerFriend
Messages: 94
Registered: July 2009
Member

Hi Christian, hi Sebastian,

thanks a lot! Great idea... Will implement it that way.

Best, Florian
Previous Topic:Use xtend2 and xbase-based DSL in GWT application client
Next Topic:Static Enumeration Literal Assignment
Goto Forum:
  


Current Time: Mon Feb 17 00:11:38 GMT 2020

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

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

Back to the top