Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Re: Suppress rather than override static JET templates
Re: Suppress rather than override static JET templates [message #10022] Wed, 04 April 2007 13:28 Go to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Claude:

I'm replying to the M2T newsgroup, as this is where JET/JET2 is moving.

It is not clear from your question whether you are using JET1 (that is, EMF
JET, org.eclipse.emf.codegen) or JET2 (org.eclipse.jet).

If you are using JET1, then you must negotiate with the creator of the Java
program that orchestrates the template invocations to create some sort of
semantic that indicates you don't want to generate a particular file.

If you are using JET2, you have a bit more control, as the template
invocations are also coded in JET templates that you can override (and thus
remove the invocation of the template you care about).

But the bottom line is that easy overriding of a transformation's behavior
(including suppression of some of its outputs) is the result of a design
decision in the original implementation. An analogy to Java classes is
appropriate: Just because the Java language lets you extend many classes, it
does not mean that many classes are easy to extend - the ones are are were
designed to be extended in particular ways.

So, if you're trying to extend an existing generator, it is worth talking
with the generator's author to see if they can adjust the design to support
you use case.

Paul

"Claude Knaus" <claude.knaus@profidatalab.com> wrote in message
news:euvpi7$uvf$1@build.eclipse.org...
> Hi,
>
> I would like to use dynamic templates to generate some classes from a
> model. In my case, I don't need all the classes which are generated by the
> static templates.
>
> Is there a way to suppress the processing of some of the static templates,
> or do I need to use Merlin for this kind of flexibility?
>
> -- Claude
>
Re: Suppress rather than override static JET templates [message #10045 is a reply to message #10022] Thu, 05 April 2007 09:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: claude.knaus.profidatalab.com

Hi Paul,

Thanks for the elaborate answer. What I want is to use EMF to pass in the
GenModel. From that point on, I want full control over code generation using
my own templates. If there was an easy way to set up a GenModel instance by
"hand" I would just use JET without EMF.

As for the JET version: I use EMF 2.2.2 and JET 0.7.2.

My understanding is that JET 0.7.2 is JET2, but EMF 2.2.2 was built using
JET1?

Will I need to use EMF 2.3.0 to take full advantage of JET2?

-- Claude

"Paul Elder" <pelder@ca.ibm.com> wrote in message
news:ev095v$e7i$1@build.eclipse.org...
> Claude:
>
> I'm replying to the M2T newsgroup, as this is where JET/JET2 is moving.
>
> It is not clear from your question whether you are using JET1 (that is,
> EMF JET, org.eclipse.emf.codegen) or JET2 (org.eclipse.jet).
>
> If you are using JET1, then you must negotiate with the creator of the
> Java program that orchestrates the template invocations to create some
> sort of semantic that indicates you don't want to generate a particular
> file.
>
> If you are using JET2, you have a bit more control, as the template
> invocations are also coded in JET templates that you can override (and
> thus remove the invocation of the template you care about).
>
> But the bottom line is that easy overriding of a transformation's behavior
> (including suppression of some of its outputs) is the result of a design
> decision in the original implementation. An analogy to Java classes is
> appropriate: Just because the Java language lets you extend many classes,
> it does not mean that many classes are easy to extend - the ones are are
> were designed to be extended in particular ways.
>
> So, if you're trying to extend an existing generator, it is worth talking
> with the generator's author to see if they can adjust the design to
> support you use case.
>
> Paul
>
> "Claude Knaus" <claude.knaus@profidatalab.com> wrote in message
> news:euvpi7$uvf$1@build.eclipse.org...
>> Hi,
>>
>> I would like to use dynamic templates to generate some classes from a
>> model. In my case, I don't need all the classes which are generated by
>> the static templates.
>>
>> Is there a way to suppress the processing of some of the static
>> templates, or do I need to use Merlin for this kind of flexibility?
>>
>> -- Claude
>>
>
>
Re: Suppress rather than override static JET templates [message #10067 is a reply to message #10045] Thu, 05 April 2007 13:02 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Claude:

Some answers to your questions. The easy ones first...

> My understanding is that JET 0.7.2 is JET2, but EMF 2.2.2 was built using
> JET1?

Correct.

> Will I need to use EMF 2.3.0 to take full advantage of JET2?

No. EMFT JET works with both 2.2.0 and 2.3.0

> .... From that point on, I want full control over code generation using my
> own templates. If there was an easy way to set up a GenModel instance by
> "hand" I would just use JET without EMF.

So, it sounds like you want to start with a .genmodel file, but generate
something completely different from what EMF is producing.

In that case, I think I'd create an EMFT JET Transformation project, and
make the following modification:

1) Open plugin.xml
2) Go to the Extensions tab
3) Expand org.eclipse.jet.transform, and click on (transform)
4) Enter org.eclipse.jet.emf in the modelLoader property.

This will tell the JET engine to take the source model (a .genmodel file),
and attempt to load it using the EMF registry. From there, you have complete
control.

Here is a dump.jet file that shows some XPath navigation tricks. You can
insert it into a JET transformation with the above model loader
modifications, and then create a JET launch configuration against a
..genmodel input.

<?xml version="1.0" encoding="utf-8"?>
<aGenModelDump>
<c:iterate select="//GenClass" var="genClass">
<genClass eclass="<c:get select="$genClass/ecoreClass/@name"/>">
<c:iterate select="$genClass/genFeatures" var="genFeature">
<genFeature ecoreFeature="<c:get
select="$genFeature/ecoreFeature/@name"/>"/>
</c:iterate>
</genClass>
</c:iterate>
</aGenModelDump>

For genModel.genmodel, it produces something like this...

<?xml version="1.0" encoding="utf-8"?>
<aGenModelDump>
<genClass eclass="GenModel">
<genFeature ecoreFeature="copyrightText"/>
<genFeature ecoreFeature="modelDirectory"/>
<genFeature ecoreFeature="creationCommands"/>
...
</genClass>
...
</aGenModelDump>
Previous Topic:JET2 - invoking with a different input file.
Next Topic:JET2 - multiple input models
Goto Forum:
  


Current Time: Fri Nov 28 18:24:55 GMT 2014

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

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