// implements the interface method
 public Environment createOperationContext(Environment parent, Operation operation) {
   Environment result = createEnvironment(parent);
   if (result instanceof AbstractEnvironment) {
     ((AbstractEnvironment) result).setContextOperation(operation);
   }
   OCLFactory oclFactory = parent.getOCLFactory();
   for (Parameter next : operation.getOwnedParameters()) {
     // ensure that we use the OCL primitive types wherever possible
     Variable var = oclFactory.createVariable();
     var.setName(next.getName());
     var.setType(next.getType());
     var.setRepresentedParameter(next);
     result.addElement(var.getName(), var, true);
   }
   return result;
 }
示例#2
0
 @Override
 protected void installBindings(
     EnvironmentView environmentView,
     Type forType,
     EObject eObject,
     Map<TemplateParameter, ParameterableElement> bindings) {
   List<Parameter> parameters = ((Operation) eObject).getOwnedParameter();
   int iMax = parameters.size();
   if (iMax > 0) {
     for (int i = 0; i < iMax; i++) {
       Parameter parameter = parameters.get(i);
       OclExpression argument = getExpressionArgument(i);
       if (argument != null) {
         Type parameterType = parameter.getType();
         if (parameterType instanceof LambdaType) {
           PivotUtil.getAllTemplateParameterSubstitutions(
               bindings, argument.getType(), (LambdaType) parameterType);
         }
       }
     }
   }
   super.installBindings(environmentView, forType, eObject, bindings);
 }