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

Bug 436465

Summary: unSetVariable is not implemented for VariableInterpreter
Product: [Modeling] Sirius Reporter: Laurent Redor <laurent.redor>
Component: CoreAssignee: Maxime Porhel <maxime.porhel>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: maxime.porhel, pierre-charles.david
Version: 0.9Keywords: triaged
Target Milestone: 2.0.0   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 435203    
Attachments:
Description Flags
Project use case none

Description Laurent Redor CLA 2014-06-03 10:52:14 EDT
Created attachment 243890 [details]
Project use case

The behavior of org.eclipse.sirius.common.tools.api.interpreter.IInterpreter.unSetVariable(String) is not well documented. As consequence, the behavior is not the same for acceleo3 query and for the new variable interpreter.
The name of the unSetVariable method is not well named. Indeed, the expected behavior when a variable is unsetted is to retreive its previous value (the one before the last setVariable() call).

Steps to reproduce:
* Import the project "VarInterperterUnsetProblem" in your workspace
* Open the diagram "new Diag"
* Use the tool "Reveal packages and classes using var" on diagram, only the first package and its classes appear (KO)
* Delete this package from the diagram (and not from the model)
* Use the tool "Reveal packages and classes using acceleo3" on diagram, all the packages and their classes appear as expected.

In this use case, the difference between the 2 tools is that:
* the first uses "var:containerView" as container view expression of CreateView task
* the second uses "[containerView/]" as container view expression of CreateView task

With the variable interpreter, during the creation of the first view, a refresh is launched and the containerView is override by another value. During the second iteration, the containerView variable has not the expected value because the unSetVariable did nothing.
Comment 1 Pierre-Charles David CLA 2014-06-03 10:54:47 EDT
Note that proper variable management should probably be handled directly in AbstractInterpreter, as ServiceInterpreter extends AbstractInterpreter and also needs a correct view of the current variables value.
Comment 2 Laurent Redor CLA 2014-06-03 11:06:02 EDT
First version of fix: https://git.eclipse.org/r/27830

This solution uses the VariableManager (as query legacy) to manage the
push/peak/pop mechanism for the variables.
Comment 3 Maxime Porhel CLA 2014-07-16 10:12:41 EDT
Bug 435203 duplicates this bug, but will be used for the (partial) report of the correction on 1.0.x. 

On master we could think about using the VariableManager in AcceleoMTLInterpretr too, to have the same vaiabral managmeent logic in all our interpreters.
Comment 4 Maxime Porhel CLA 2014-07-24 04:47:23 EDT
See https://git.eclipse.org/r/#/c/27830/4 which adds the variable stack support to var: and service:

See https://git.eclipse.org/r/#/c/30408/ for a DRAFT which makes the AcceleoMTLInterpreter use a VariableManager, but Acceleo is expecting a ListMultiMap, so we have to create one on each evaluation. We need to check the impact on performances.
Comment 5 Maxime Porhel CLA 2014-07-24 11:47:09 EDT
See commit 5e601dc2130d92b15ca8d2dc0959dfb5daf9fde5 for the unSetVariable implementation for var: and service:
Comment 6 Maxime Porhel CLA 2014-08-07 10:12:57 EDT
The second proposed commit (https://git.eclipse.org/r/#/c/30408/) has been abandonned as it does not correct a bug and could introduce some performance regressions.
Comment 7 Pierre-Charles David CLA 2014-10-27 06:52:34 EDT
Available in Sirius 2.0.0.