Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo3] Strange template invocation error
[Acceleo3] Strange template invocation error [message #665572] Fri, 15 April 2011 06:56 Go to next message
Wilbert Alberts is currently offline Wilbert AlbertsFriend
Messages: 99
Registered: June 2010
Member
Hi,

I'm encountering a strange problem. My template module contains the following template definition:

[template private genParamDecls(ds: OrderedSet(PG_FuncParam)) post(trim())]
[for (d : PG_FuncParam| ds) separator (', ')][generateCDeclaration(d.name, d.type, OrderedSet(PG_Dimension){})/][/for]
[for (d : PG_FuncParam| ds) separator (', ')][generateCDeclaration(d.name, d.type, d.dimensions)/][/for]
[/template]


The generateCDeclaration template is defined in a different module (which obviously is included here). It looks like:
[template public generateCDeclaration(s: String, t: PG_Type, ds: OrderedSet(PG_Dimension)) post(trim())]
[genCDecl(s, t, ds)/]
[/template]


PG_FuncParam specialises PG_TypedElement which contains the PG_Dimension sequence:
class PG_TypedElement extends pg_core::PG_NamedElement { abstract }
{
	property type : PG_Type[1];
	property dimensions : PG_Dimension[*] { composes };
}


The problem is that acceleo detects an error in the second of the two 'for' loop invocations (from above), the one that operates on d.dimensions.

The moment I copy the generateCDeclaration template definition to the module containing its invocation, the error disappears. However, that is not an option as it would require copying the whole module.

Anyone having an idea what is going on here?

Greetings,
Wilbert.
Re: [Acceleo3] Strange template invocation error [message #665587 is a reply to message #665572] Fri, 15 April 2011 07:51 Go to previous messageGo to next message
Wilbert Alberts is currently offline Wilbert AlbertsFriend
Messages: 99
Registered: June 2010
Member
Hi,

I must admit that the module containing the generateCDeclaration also contains another template definition:

[template public generateCDeclaration(s: String, t: PG_Type, ds: OrderedSet(PG_Dimension)) post(trim())]
[genCDecl(s, t, ds)/]
[/template]

[template public generateCDeclaration(te : PG_TypedElement) post(trim())]
[genCDecl(te.name, te.type, te.dimensions)/]
[/template]


As the PG_FuncParam also is an PG_TypedElement I was able to change the invocation of the template from:
[template private genParamDecls(ds: OrderedSet(PG_FuncParam)) post(trim())]
[for (d : PG_FuncParam| ds) separator (', ')][generateCDeclaration(d.name, d.type, d.dimensions)/][/for]
[/template]

into:
[template private genParamDecls(ds: OrderedSet(PG_FuncParam)) post(trim())]
[for (d : PG_FuncParam| ds) separator (', ')][generateCDeclaration(d)/][/for]
[/template]


This modification made my module work but I don't understand why....

Greetings,
Wilbert.
Re: [Acceleo3] Strange template invocation error [message #665591 is a reply to message #665572] Fri, 15 April 2011 08:09 Go to previous message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 413
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi Wilbert,

From my point of view, both of your modules seem not to have any problems. Yet we had two known bugs involving false errors on invocations of template coming from imported module (that could be solved by a Project -> clean..) and a problem with the scope of the variables. Both of those problems were fixed during the last few days. You will be able to get those fix in Acceleo 3.1M7 next month. In the mean time, I would advise to try not to use several time the same variable name in your templates.

Stephane Begaudeau, Obeo
--
Twitter: @sbegaudeau
Acceleo wiki: http://wiki.eclipse.org/Acceleo
Blogs: http://stephanebegaudeau.tumblr.com & http://sbegaudeau.tumblr.com



Previous Topic:[Xpand] Strange behaviour of polymorphism when using stereotypes
Next Topic:[Acceleo] eContainer returns invalid class
Goto Forum:
  


Current Time: Sat Dec 20 03:51:08 GMT 2014

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

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