Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [ACCELEO] wrong parameter value
[ACCELEO] wrong parameter value [message #1785552] Mon, 16 April 2018 14:51 Go to next message
Nicola Serreli is currently offline Nicola SerreliFriend
Messages: 26
Registered: July 2009
Junior Member
Hi,

sometimes, I find that the value of an acceleo template parameter is not the one I expected.

Here is an example:

[template public main(....)]
[''.test()/]
[/template]

[template public test(arg : String)]
[print(sub('abc'.a(2)), sub('cde'.a(3)))/]
[print(sub('abc'.a(2)), c())/]
[print(c(), sub('abc'.a(2)))/]
[/template]

[template public print(arg1 : String, arg2 : String)]
[file ('stdout', false, 'UTF-8')]
TEST ... [if (arg1.oclIsUndefined() or arg1='')]FAILED[/if]
    arg1 [arg1/] [arg1.oclIsUndefined()/]
    arg2 [arg2/] [arg2.oclIsUndefined()/]
[/file]
[/template]

[template public sub(arg : String)]([arg/])[/template]

[template public a(arg1 : String, index : Integer)][arg1 + ' - ' + index/][/template]

[query public c(any: OclAny) : String = '.ui' /]


The result is:

TEST ... 
    arg1 (abc - 2) false
    arg2 (cde - 3) false
TEST ... FAILED
    arg1  false
    arg2 .ui false
TEST ... 
    arg1 .ui false
    arg2 (abc - 2) false



Currently, I'm using acceleo 3.6.4.201605040614

Someone can help me to understand if I'm doing something wrong?

Bye,
Nicola
Re: [ACCELEO] wrong parameter value [message #1785555 is a reply to message #1785552] Mon, 16 April 2018 15:21 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7679
Registered: July 2009
Senior Member
Hi

The debugger is always a way to solve magic problems.

I would have to use the debugger too, but one guess is that you are using templates with non-EObject arguments which confuses traceability.

Regards

Ed Willink
Re: [ACCELEO] wrong parameter value [message #1785558 is a reply to message #1785555] Mon, 16 April 2018 16:13 Go to previous message
Nicola Serreli is currently offline Nicola SerreliFriend
Messages: 26
Registered: July 2009
Junior Member
Hi,

I tried to use java debugger to follow the acceleo execution.
For what I see, inside AcceleoEvaluationVisitor.prepareInvocation, it tries to prepare the list of all parameters needed to invoke a template.
If a parameter is computed during the preparation of the invocation, it has a name like temporaryInvocationVariable$0
In my test, the actual value of this variable is retrieved as "the last value computed for a variable with that name". All computed values are stored using a stack, to provide the correct value when the execution returns from a query/template (I think).
Unfortunately, sometimes, the correct value is not the last one but the second to last (or even elder).

I'm not sure, but it looks like, the computation of template/query inside a template invocation adds a new value to the "values stack", but forget to remove it.

Regards,
Nicola
Previous Topic:Save the text file generated in other project
Next Topic:Getting instance from the slot.value using Acceleo Code
Goto Forum:
  


Current Time: Wed Nov 06 21:22:34 GMT 2024

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

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

Back to the top