Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo 3] Overriding Templates
[Acceleo 3] Overriding Templates [message #656426] Fri, 25 February 2011 15:22 Go to next message
Sylvain Dudoit is currently offline Sylvain DudoitFriend
Messages: 5
Registered: February 2011
Junior Member
Hi,

I'm using Eclipse 3.5.2 with Acceleo 3.0.1.

Here is my situation :
- I have "plugin A" which implements "Documentation.mtl A" for elements of "meta-model A"
- "Documentation.mtl A" contains a template "generateElementDoc(e : Element)"
- I have "plugin B" which implements a "meta-model B" which extends "meta-model A"

I want to :
- Implement the generation action in "plugin A" which launches "Documentation.mtl A"
- I want to overrides "generateElementDoc(e : Element)" in "plugin B" to consider subclasses of "Element" (e.g. let's call it "SubElement")

After reading the documentation of Acceleo, I thought my solution could be :

---- Documentation.mtl A ----------------------------------------

[module Documentation('metamodelA.uri')/]

[template public generate(m : Model)]
        [comment @main /]
	[file ('index.html', false, 'UTF-8')]	
	  	[for (e : Element | m.elements)]
		[generateElementDoc(e)/]
	  	[/for]	  	
	[/file]
[/template]

[template public generateElementDoc(e : Element)]
       Hello, I'm an Element
[/template]



---- Documentation.mtl B ----------------------------------------

[module Documentation('metamodelB.uri') extends pluginA::Documentation/]

[template public generateElementDoc(e : SubElement) overrides generateElementDoc]
	Hello, I'm a SubElement
[/template]



But, I get an error under the second "generateElementDoc" in "Documentation.mtl B" which is saying
"No public template 'generateElementDoc' found." even if the package containing Documentation.mtl A
is exported.

Where am I wrong ? Crying or Very Sad

The last question is : since "plugin A" which implements the action doesn't know "plugin B", I will have to
use "dynamic template" extension for declaring "Documentation.mtl B" ? Rolling Eyes

Thank you for your answers,
Sylvain

Re: [Acceleo 3] Overriding Templates [message #656710 is a reply to message #656426] Mon, 28 February 2011 08:45 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi Sylvain,

First of all, I think you would need to have the uri of your two metamodels in the module B to make it work, and if you want to have no dependencies in your first generator to the second generator, you have to use the extension point for the dynamic overriding.

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Acceleo wiki: http://wiki.eclipse.org/Acceleo
Blogs: http://stephanebegaudeau.tumblr.com & http://sbegaudeau.tumblr.com
Re: [Acceleo 3] Overriding Templates [message #657092 is a reply to message #656710] Tue, 01 March 2011 15:27 Go to previous message
Sylvain Dudoit is currently offline Sylvain DudoitFriend
Messages: 5
Registered: February 2011
Junior Member
Hi Stéphane,

Thank you for your reply ! I've finally found my mystake.

The overriden method must have the same signature in "Documentation.mtl B".
In fact, I made a mystake by wanting "overriding" + "polymorphing".

So, in "Documentation.mtl B", the template must looks like this :

[module Documentation('metamodelA.uri', 'metamodelB.uri') extends pluginA::Documentation/]

[template public generateElementDoc(e : Element) overrides generateElementDoc]
	Hello, I'm redefining generateElementDoc !
[/template]


Sylvain
Previous Topic:[xpand/xtend] xtend expression retuns a string between square brakets
Next Topic:GMF integartion wid xpand
Goto Forum:
  


Current Time: Fri Apr 19 16:32:54 GMT 2024

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

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

Back to the top