protected void checkOperationCallType(OclExpression oclExpression, String typeName, String operationName, Type sourceClass, String sourceType, Object[] argTypes) { Assert.IsTrue(oclExpression is OperationCallExp); OperationCallExp exp = (OperationCallExp)oclExpression; Assert.AreEqual(typeName, exp.getType().getName()); Assert.IsTrue(exp.getReferredOperation().operationNameMatches(operationName)); if (sourceClass != null) { Assert.IsTrue(sourceClass.IsInstanceOfType(exp.getSource())); Assert.AreEqual(exp.getSource().getType().getName(), sourceType); } else { Assert.IsFalse(exp.getReferredOperation().isInstanceScope()); } if (argTypes == null) { Assert.AreEqual(0, exp.getArguments().Count); } else { Assert.AreEqual(argTypes.Length, exp.getArguments().Count); } }
protected OperationCallExp checkOperationCallExp(OclExpression oclExpression, String opName, String returnTypeName) { Assert.IsTrue(oclExpression is OperationCallExp); OperationCallExp opExp = (OperationCallExp)oclExpression; Assert.AreEqual(opName, opExp.getReferredOperation() != null ? opExp.getReferredOperation().getName() : opExp.getName()); // Assert.AreEqual(returnTypeName, opExp.getReferredOperation() != null? opExp.getReferredOperation().getReturnType().getName() : opExp.getType().getName()); Assert.AreEqual(returnTypeName, opExp.getType().getName()); return(opExp); }
public void visitOperationCalllExpEnd(OperationCallExp exp) { // put parenthesis in the end of operation formula var operation = exp.getReferredOperation(); if (operation != null && !(exp.getSource() is VariableExpImpl)) { formula += ")"; navigationLevel = 0; } }
public void visitOperationCalllExpBegin(OperationCallExp exp) { var operation = exp.getReferredOperation(); if (operation == null) { return; } // get type of operation string operationName = operation.getName(); OperationCallExpImpl operationCall = (OperationCallExpImpl)exp; bool isBasicOperator = operationCall.isBasicOperator(operationName); bool isBooleanOperator = operationCall.isBooleanOperator(operationName); if (isBooleanOperator) { formula += ","; } else if (isBasicOperator) { formula += string.Format(" {0} ", operationName); } }
public void visitOperationCalllExpBeforeBegin(OperationCallExp exp) { var operation = exp.getReferredOperation(); if (operation == null) { return; } // get type of operation string operationName = operation.getName(); OperationCallExpImpl operationCall = (OperationCallExpImpl)exp; bool isBasicOperator = operationCall.isBasicOperator(operationName); bool isBooleanOperator = operationCall.isBooleanOperator(operationName); var source = operationCall.getSource(); // boolean operators or not basic operators (because boolean operator is a basic operator) if (isBooleanOperator || !isBasicOperator) { // set formula name based on operation name string xoperationname = operationName; // map operation name to formula name based on source expression if (source is AssociationEndCallExpImpl || source is IteratorExpImpl) { if (operationName.Equals("size")) { xoperationname = "COUNTIFS"; } else if (operationName.Equals("sum")) { xoperationname = "SUMIFS"; } } else if (source is VariableExpImpl) { formula += string.Format("[{0}]", operationName); } else { if (operationName.Equals("size")) { xoperationname = "COUNTA"; } else if (operationName.Equals("sum")) { xoperationname = "SUM"; } else if (operationName.Equals("toDate")) { xoperationname = ""; // suppress toDate operation } } if (!(source is VariableExpImpl)) { formula += xoperationname.ToUpper(); } } if (!(source is VariableExpImpl)) { formula += "("; } }