Bug 436459 - ForTask problem if expression uses an array
Summary: ForTask problem if expression uses an array
Status: CLOSED FIXED
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 0.9   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 2.0.0   Edit
Assignee: Maxime Porhel CLA
QA Contact: Julien Dupont CLA
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2014-06-03 09:55 EDT by Laurent Redor CLA
Modified: 2014-10-27 06:52 EDT (History)
2 users (show)

See Also:


Attachments
Project ForTaskWithArray.design (7.13 KB, application/octet-stream)
2014-06-03 09:55 EDT, Laurent Redor CLA
no flags Details
Project ForTaskWithArray.sample (7.13 KB, application/zip)
2014-06-03 09:56 EDT, Laurent Redor CLA
no flags Details
ForTaskWithArray.sample (and not the design project twice) (2.49 KB, application/zip)
2014-07-28 05:23 EDT, Laurent Redor CLA
no flags Details
Sample (477 bytes, application/octet-stream)
2014-07-28 05:24 EDT, Maxime Porhel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Laurent Redor CLA 2014-06-03 09:55:37 EDT
Created attachment 243884 [details]
Project ForTaskWithArray.design

If the expression of a ForTask is an array, returned by the service interpreter or the variable interpreter, this task iterates only on one element (the array itself) and not on each element of the array.

Steps to reproduce:
* Import the project "ForTaskWithArray.design" in a workspace
* Launch a runtime
* Import the project "ForTaskWithArray.sample" in the runtime-workspace
* Open the diagram "new Diag"
* Use the tool "Duplicates classes with array with service" on p1 package, nothing happens (KO)
* Use the tool "Duplicates classes with array with variable" on p1 package, nothing happens (KO)
* Use the tool "Duplicates classes with list with service" on p1 package, the 3 classes are duplicated as expected. The behavior for the first tools should be the same.

In this use case, the difference between the 3 tools is that:
* the first iterates on an array (returned by the service org.eclipse.sirius.sample.fortaskwitharray.Services.getEClassesAsArray(EPackage))
* the second iterates on an array (returned by a variable)
* and the third iterates on a list (returned by the service org.eclipse.sirius.sample.fortaskwitharray.Services.getEClassesAsList(EPackage))

In ForTask, an array should be considered as list.
Comment 1 Laurent Redor CLA 2014-06-03 09:56:23 EDT
Created attachment 243885 [details]
Project ForTaskWithArray.sample
Comment 2 Maxime Porhel CLA 2014-07-28 05:11:09 EDT
Laurent, it seems you uploaded the same design project twice.
Comment 3 Laurent Redor CLA 2014-07-28 05:23:45 EDT
Created attachment 245426 [details]
ForTaskWithArray.sample (and not the design project twice)
Comment 4 Maxime Porhel CLA 2014-07-28 05:24:28 EDT
Created attachment 245427 [details]
Sample
Comment 5 Maxime Porhel CLA 2014-07-28 05:25:10 EDT
Thank you Laurent.
Comment 6 Maxime Porhel CLA 2014-07-28 08:21:56 EDT
See https://git.eclipse.org/r/30583, which propose a draft which enables ForTask  to iterate over arrays. 

But I think here the real issue is thaht we should call evaluateCollection instead of evaluate and then each IInterpreters should be able to handle arrays in its evaluateCollectionMethod.
Comment 7 Maxime Porhel CLA 2014-08-07 04:53:12 EDT
The current behavior allows to iterate on the for taks over non EObject elements, in this case, the evaluation context is still the element on which the for expression has been evaluated.

so we should correct handle the array case here but continue to call evaluate and not evalauteCollection which returns a collection of EObject and will remove the possibility to iterate over non EObject elements. However, handling the array case in the evaluateCollection method seems a good idea, it could be done in a separate commit/step on this bug.
Comment 8 Maxime Porhel CLA 2014-08-08 10:20:41 EDT
See
 . https://git.eclipse.org/r/#/c/30583/ which corrects the ForTask
 . https://git.eclipse.org/r/#/c/31171/ which handled arrays in our interpreters evaluateCollection methods.
Comment 9 Maxime Porhel CLA 2014-08-18 10:02:22 EDT
Corrected by commits
 . 389b9ddb366b77f1f05910d9dd33d50ecd43771d
 . 008bc96206e8afd5ad65cf0820cae88709c7be26
 . 7b7c8e2882cf16424e1694f51965dc49acc0f8e4
Comment 10 Pierre-Charles David CLA 2014-10-27 06:52:31 EDT
Available in Sirius 2.0.0.