[Acceleo] Dynamic overriding [message #902931] |
Tue, 21 August 2012 05:14  |
Eclipse User |
|
|
|
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 #977562 is a reply to message #905470] |
Fri, 09 November 2012 06:30  |
Eclipse User |
|
|
|
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
>>
>
|
|
|
Powered by
FUDForum. Page generated in 0.30674 seconds