Skip to content

Commit

Permalink
delete return variables (fix #223)
Browse files Browse the repository at this point in the history
These variables are not used anymore: action return values can be stored in variable using variable declaration assign expression.
  • Loading branch information
gdaniel committed May 8, 2019
1 parent ee64827 commit eb660bb
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 49 deletions.
Expand Up @@ -29,7 +29,6 @@

import static fr.inria.atlanmod.commons.Preconditions.checkNotNull;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;

/**
* The concrete implementation of a {@link PlatformDefinition}.
Expand Down Expand Up @@ -292,9 +291,6 @@ public RuntimeAction createRuntimeAction(ActionInstance actionInstance, JarvisSe
throw new JarvisException(MessageFormat.format("Cannot find a {0} constructor for the provided parameter " +
"types ({1})", runtimeActionClass.getSimpleName(), printClassArray(fullParameters)), e);
}
if (nonNull(actionInstance.getReturnVariable())) {
runtimeAction.setReturnVariable(actionInstance.getReturnVariable().getReferredVariable().getName());
}
runtimeAction.init();
return runtimeAction;
}
Expand Down
Expand Up @@ -3,7 +3,6 @@
import edu.uoc.som.jarvis.core.ExecutionService;
import edu.uoc.som.jarvis.core.platform.RuntimePlatform;
import edu.uoc.som.jarvis.core.session.JarvisSession;
import edu.uoc.som.jarvis.intent.EventInstance;
import edu.uoc.som.jarvis.intent.RecognizedIntent;
import edu.uoc.som.jarvis.platform.ActionDefinition;

Expand Down Expand Up @@ -41,18 +40,6 @@ public abstract class RuntimeAction<T extends RuntimePlatform> implements Callab
*/
protected JarvisSession session;

/**
* The name of the variable to use to store the result of the {@link #call()} method.
* <p>
* The value of this attribute is used by
* {@link ExecutionService#handleEventInstance(EventInstance, JarvisSession)} to store
* the result of each {@link RuntimeAction} in the variable defined in the provided execution model.
*
* @see ExecutionService#handleEventInstance(EventInstance, JarvisSession)
* @see #getReturnVariable()
*/
protected String returnVariable;

/**
* Constructs a new {@link RuntimeAction} with the provided {@code runtimePlatform} and {@code session}.
*
Expand All @@ -79,23 +66,6 @@ public void init() {

}

public final void setReturnVariable(String variableName) {
this.returnVariable = variableName;
}

/**
* Return the name of the variable to use to store the result of the {@link #call()} method.
* <p>
* This method is used by {@link ExecutionService#handleEventInstance(EventInstance, JarvisSession)} to
* store the result of each {@link RuntimeAction} in the variable defined in the provided execution model.
*
* @return the name of the variable to use to store the result of the {@link #call()} method
* @see ExecutionService#handleEventInstance(EventInstance, JarvisSession)
*/
public final String getReturnVariable() {
return returnVariable;
}

/**
* Disable the default constructor, RuntimeActions must be constructed with their containing runtimePlatform.
*/
Expand Down
Expand Up @@ -230,20 +230,6 @@ public void createRuntimeActionValidActionInstanceNoParameters() {
.class);
}

@Test
public void createRuntimeActionValidActionInstanceWithReturnType() {
ActionDefinition actionDefinition = getNoParameterActionDefinition();
ActionInstance actionInstance = createActionInstanceFor(actionDefinition);
VariableDeclaration returnVariable = commonFactory.createVariableDeclaration();
returnVariable.setName("return");
VariableAccess returnVariableAccess = commonFactory.createVariableAccess();
returnVariableAccess.setReferredVariable(returnVariable);
actionInstance.setReturnVariable(returnVariableAccess);
RuntimeAction runtimeAction = runtimePlatform.createRuntimeAction(actionInstance, new JarvisSession("session"), executionContext);
assertThat(runtimeAction.getReturnVariable()).as("Valid return variable name").isEqualTo(returnVariable
.getName());
}

@Test(expected = JarvisException.class)
public void createRuntimeActionTooManyParametersInAction() {
ActionDefinition actionDefinition = getNoParameterActionDefinition();
Expand Down
Expand Up @@ -26,7 +26,6 @@ class ExecutionRule {
class ActionInstance extends Expression {
refers ActionDefinition action
contains ParameterValue[] values
contains VariableAccess returnVariable
contains ActionInstance[] onError
}

Expand Down

0 comments on commit eb660bb

Please sign in to comment.