Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Dynamic overriding
[Acceleo] Dynamic overriding [message #902931] Tue, 21 August 2012 09:14 Go to next message
Hendrik Reddehase is currently offline Hendrik ReddehaseFriend
Messages: 7
Registered: March 2011
Junior Member
Hi,
I want to extend an existing code generator. If I have understood the
framework correctly, I have to use the extension point
"org.eclipse.acceleo.engine.dynamic.templates".

So I created two test projects. The first one named
org.eclipse.acceleo.module.sample1 with the following module:

[module M1('http://www.eclipse.org/uml2/2.1.0/UML')]

[template public foo(aClass : Class)]
[bar(aClass)/]
[/template]

[template public bar(aClass : Class)]
M1
[/template]


And a second one named org.eclipse.acceleo.module.sample2 and the module:

[module M2('http://www.eclipse.org/uml2/2.1.0/UML') extends
org::eclipse::acceleo::module::sample1::common::M1]

[template public generator(aClass : Class)]
[comment @main /]
[file ('test.txt', false, 'Cp1252')]
[subfoo(aClass)/]
[/file]
[/template]

[template public subfoo(aClass : Class) overrides foo]
[super/]
[/template]

[template public bar(aClass : Class) overrides bar]
M2
[/template]

The project sample2 has a dependency to sample1 and defines the
extension point "org.eclipse.acceleo.engine.dynamic.templates".
Templates path: src/org/eclipse/acceleo/module/sample2/common/
Generator id: org.eclipse.acceleo.module.sample1

If I start the generator, the content of test.txt is almost M1. But
sometimes it works correctly and I get M2.

So I copied the module M2 to project sample1 added an extension point
etc. and there it seems to be working correctly.

Is this a bug or what is my mistake?

Configuration:
Eclipse 3.7.2 and Acceleo 3.2.1

Thanks a lot for you help.
Hendrik
Re: [Acceleo] Dynamic overriding [message #904398 is a reply to message #902931] Tue, 28 August 2012 11:25 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hendrik,

The names of the overriden and overriding templates must match :

[module M1('http://www.eclipse.org/uml2/2.1.0/UML')]

[template public foo(aClass : Class)]
    [bar(aClass)/]
[/template]

[template public bar(aClass : Class)]
    M1
[/template]


[module M2('http://www.eclipse.org/uml2/2.1.0/UML') extends
org::eclipse::acceleo::module::sample1::common::M1]
[template public [b]foo[/b](aClass : Class) overrides foo]
    [super/]
[/template]

[template public bar(aClass : Class) overrides bar]
    M2
[/template]


Laurent Goubet
Obeo
Re: [Acceleo] Dynamic overriding [message #905439 is a reply to message #904398] Thu, 30 August 2012 11:37 Go to previous messageGo to next message
Hendrik Reddehase is currently offline Hendrik ReddehaseFriend
Messages: 7
Registered: March 2011
Junior Member
Hi Laurent,

I have already tried this. The Problem is if I make a clean on both
projects and rebuilt both, it only works for the first time and I get
M2. But the result of regeneration is M1.

Hendrik

Am 28.08.2012 13:25, schrieb Laurent Goubet:
> Hendrik,
>
> The names of the overriden and overriding templates must match :
>
>
> [module M1('http://www.eclipse.org/uml2/2.1.0/UML')]
>
> [template public foo(aClass : Class)]
> [bar(aClass)/]
> [/template]
>
> [template public bar(aClass : Class)]
> M1
> [/template]
>
>
>
> [module M2('http://www.eclipse.org/uml2/2.1.0/UML') extends
> org::eclipse::acceleo::module::sample1::common::M1]
> [template public foo(aClass : Class) overrides foo]
> [super/]
> [/template]
>
> [template public bar(aClass : Class) overrides bar]
> M2
> [/template]
>
>
> Laurent Goubet
> Obeo
Re: [Acceleo] Dynamic overriding [message #905470 is a reply to message #905439] Thu, 30 August 2012 12:42 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
HI

You mentioned at the outset that you are extending an existing generator.

Do you have both production and development versions of the models
installed in your workspace? There are many potential hazards associated
with this.

You might want to take copies of the (ASCII) *.emtl files in a 'good'
and a 'bad' state to see what the difference is. You'll probably find
that those produced by the editor have different URIs to those from the
builder.

Regards

Ed Willink

On 30/08/2012 12:37, Hendrik Reddehase wrote:
> Hi Laurent,
>
> I have already tried this. The Problem is if I make a clean on both
> projects and rebuilt both, it only works for the first time and I get
> M2. But the result of regeneration is M1.
>
> Hendrik
>
> Am 28.08.2012 13:25, schrieb Laurent Goubet:
>> Hendrik,
>>
>> The names of the overriden and overriding templates must match :
>>
>>
>> [module M1('http://www.eclipse.org/uml2/2.1.0/UML')]
>>
>> [template public foo(aClass : Class)]
>> [bar(aClass)/]
>> [/template]
>>
>> [template public bar(aClass : Class)]
>> M1
>> [/template]
>>
>>
>>
>> [module M2('http://www.eclipse.org/uml2/2.1.0/UML') extends
>> org::eclipse::acceleo::module::sample1::common::M1]
>> [template public foo(aClass : Class) overrides foo]
>> [super/]
>> [/template]
>>
>> [template public bar(aClass : Class) overrides bar]
>> M2
>> [/template]
>>
>>
>> Laurent Goubet
>> Obeo
>
Re: [Acceleo] Dynamic overriding [message #977562 is a reply to message #905470] Fri, 09 November 2012 11:30 Go to previous message
Hendrik Reddehase is currently offline Hendrik ReddehaseFriend
Messages: 7
Registered: March 2011
Junior Member
Hi,

yes I know that there are some problems with the production and
development versions of the model. But it does not work in my little
example too and there are no relations to my model. You can find this
example in the attachment.

I found out that the mechanism works, if I have installed the generator
in the runtime. But it only runs for the first time on development time.
I looked for the dynamic templates extension point and debugged it. It
looks like that it works not correctly because the method
added(IExtension[] extensions) of the class
DynamicTemplatesRegistryListener is not always called.
Is this a bug?

Regards
Hendrik Reddehase

Am 30.08.2012 14:42, schrieb Ed Willink:
> HI
>
> You mentioned at the outset that you are extending an existing generator.
>
> Do you have both production and development versions of the models
> installed in your workspace? There are many potential hazards associated
> with this.
>
> You might want to take copies of the (ASCII) *.emtl files in a 'good'
> and a 'bad' state to see what the difference is. You'll probably find
> that those produced by the editor have different URIs to those from the
> builder.
>
> Regards
>
> Ed Willink
>
> On 30/08/2012 12:37, Hendrik Reddehase wrote:
>> Hi Laurent,
>>
>> I have already tried this. The Problem is if I make a clean on both
>> projects and rebuilt both, it only works for the first time and I get
>> M2. But the result of regeneration is M1.
>>
>> Hendrik
>>
>> Am 28.08.2012 13:25, schrieb Laurent Goubet:
>>> Hendrik,
>>>
>>> The names of the overriden and overriding templates must match :
>>>
>>>
>>> [module M1('http://www.eclipse.org/uml2/2.1.0/UML')]
>>>
>>> [template public foo(aClass : Class)]
>>> [bar(aClass)/]
>>> [/template]
>>>
>>> [template public bar(aClass : Class)]
>>> M1
>>> [/template]
>>>
>>>
>>>
>>> [module M2('http://www.eclipse.org/uml2/2.1.0/UML') extends
>>> org::eclipse::acceleo::module::sample1::common::M1]
>>> [template public foo(aClass : Class) overrides foo]
>>> [super/]
>>> [/template]
>>>
>>> [template public bar(aClass : Class) overrides bar]
>>> M2
>>> [/template]
>>>
>>>
>>> Laurent Goubet
>>> Obeo
>>
>
  • Attachment: workspace.zip
    (Size: 47.14KB, Downloaded 208 times)
Previous Topic:[Acceleo] Problem invoke java service
Next Topic:How to interact with metamodel.ecore and Model.xmi elements in one template
Goto Forum:
  


Current Time: Fri Mar 29 08:32:09 GMT 2024

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

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

Back to the top