Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 319230

Summary: Invalid template evaluation in a collection
Product: [Modeling] Acceleo Reporter: Stephane Begaudeau <stephane.begaudeau>
Component: CoreAssignee: Stephane Begaudeau <stephane.begaudeau>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ed
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Templates which reproduce the problem
none
Patch v1.0
none
Patch v2.0 none

Description Stephane Begaudeau CLA 2010-07-08 04:32:56 EDT
Build Identifier: Build id: I20100608-0911

If someone creates a template which takes a sequence or an orderedset (or I think any type of collection) and if inside that sequence you have some invocation of templates, the result of the invocation will be considered as an "ocl invalid result".

See: http://www.eclipse.org/forums/index.php?t=rview&goto=545350#msg_545350


Reproducible: Always
Comment 1 Stephane Begaudeau CLA 2010-07-08 04:38:01 EDT
Created attachment 173747 [details]
Templates which reproduce the problem

When tested with that file, there seems to be a problem with the resolution of [args->first()/]. It seems that someone (Acceleo ?, ocl ?) is not able to link correctly the content of the sequence with the result of the template evaluation.

the problem must be somewhere in org.eclipse.acceleo.engine.AcceleoEvaluationException when we visit the invocation of the template generateList, the parameter "args" is not resolved correctly.
Comment 2 Ed Willink CLA 2010-10-07 11:44:44 EDT
As noted in the newsgroup, I think the problem is solely in the quality of the diagnostic; the user model is wrong, since it creates a Sequence of template return values, which are only valid for serialisation to the output. A query has to be used to get a value.

So;

either diagnose use of a template return as a value,

or convert a template return to a string so that a template call is an OperationCallExp returning a String.

If you choose to do the latter, I would wait until you want to use the new MDT/OCL evaluator, since adding functionality to the EvaluationVisitorImpl for an OperationCallExp is not easy.
Comment 3 Stephane Begaudeau CLA 2010-10-07 14:21:19 EDT
Created attachment 180445 [details]
Patch v1.0

This patch will solve the problem for the template on the bugzilla but I cannot say if it would be enough to solve all cases in which that bug may appear. I will need to create some unit test to identify all cases in which the problem can appear and to see if that fix works in all cases (I dont think so).

More infos here: http://www.eclipse.org/forums/index.php?t=msg&S=10bea96b36b94d6d3a37df7e84421fc8&th=171462&goto=631500#msg_631500
Comment 4 Stephane Begaudeau CLA 2010-11-23 09:58:31 EST
Created attachment 183670 [details]
Patch v2.0

This patch is an improved version of the first one. Now the correction will be applied recursively on each variables. So it works for something like this:
someTemplate(Bag{Set{OrderedSet{Sequence{myTemplate(myVariable)}}}}).
Comment 5 Stephane Begaudeau CLA 2010-11-23 09:59:19 EST
Contributed on head and maintenance. The fix will be available in Acceleo 3.1.0M4 and in Acceleo 3.0.2.