| 
| [Acceleo 3] Overriding Templates [message #656426] | Fri, 25 February 2011 10:22  |  | 
| Eclipse User  |  |  |  |  | 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 ?
   
 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" ?
   
 Thank you for your answers,
 Sylvain
 
 
 |  |  |  | 
|  | 
| 
| Re: [Acceleo 3] Overriding Templates [message #657092 is a reply to message #656710] | Tue, 01 March 2011 10:27  |  | 
| Eclipse User  |  |  |  |  | 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
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.02921 seconds