Search in sources :

Example 6 with Parameter

use of org.yakindu.base.types.Parameter in project statecharts by Yakindu.

the class OperationImpl method getId.

@Override
public String getId() {
    String superId = super.getId();
    if (superId == null)
        return null;
    StringBuilder builder = new StringBuilder(superId);
    EList<Parameter> parameters = getParameters();
    for (Parameter parameter : parameters) {
        if (parameter.getType() == null || parameter.getType().getName() == null)
            continue;
        builder.append("_");
        builder.append(parameter.getType().getName());
    }
    return builder.toString();
}
Also used : Parameter(org.yakindu.base.types.Parameter) TypeParameter(org.yakindu.base.types.TypeParameter)

Example 7 with Parameter

use of org.yakindu.base.types.Parameter in project statecharts by Yakindu.

the class ArgumentSorter method getOrderedExpressions.

public static EList<Expression> getOrderedExpressions(List<Argument> arguments, Operation operation) {
    Expression[] result = new Expression[arguments.size()];
    for (int index = 0; index < arguments.size(); index++) {
        Argument argument = arguments.get(index);
        List<INode> nodes = NodeModelUtils.findNodesForFeature(argument, ExpressionsPackage.Literals.ARGUMENT__PARAMETER);
        if (nodes.isEmpty()) {
            result[index] = argument.getValue();
        } else {
            // EcoreUtil.equals.)
            for (Parameter param : operation.getParameters()) {
                if (param.getName().equals(nodes.get(0).getText())) {
                    int parameterIndex = operation.getParameters().indexOf(param);
                    if (parameterIndex < result.length)
                        result[parameterIndex] = argument.getValue();
                    break;
                }
            }
        }
    }
    EList<Expression> resultAsList = new BasicEList<Expression>();
    for (int i = 0; i < result.length; i++) {
        Expression expression = result[i];
        if (expression != null)
            resultAsList.add(expression);
    }
    return resultAsList;
}
Also used : INode(org.eclipse.xtext.nodemodel.INode) Argument(org.yakindu.base.expressions.expressions.Argument) Expression(org.yakindu.base.expressions.expressions.Expression) BasicEList(org.eclipse.emf.common.util.BasicEList) Parameter(org.yakindu.base.types.Parameter)

Aggregations

Parameter (org.yakindu.base.types.Parameter)7 Argument (org.yakindu.base.expressions.expressions.Argument)3 TypeParameter (org.yakindu.base.types.TypeParameter)3 ElementReferenceExpression (org.yakindu.base.expressions.expressions.ElementReferenceExpression)2 Expression (org.yakindu.base.expressions.expressions.Expression)2 HashSet (java.util.HashSet)1 BasicEList (org.eclipse.emf.common.util.BasicEList)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 INode (org.eclipse.xtext.nodemodel.INode)1 Check (org.eclipse.xtext.validation.Check)1 Test (org.junit.Test)1 ArgumentExpression (org.yakindu.base.expressions.expressions.ArgumentExpression)1 AssignmentExpression (org.yakindu.base.expressions.expressions.AssignmentExpression)1 BitwiseAndExpression (org.yakindu.base.expressions.expressions.BitwiseAndExpression)1 BitwiseOrExpression (org.yakindu.base.expressions.expressions.BitwiseOrExpression)1 BitwiseXorExpression (org.yakindu.base.expressions.expressions.BitwiseXorExpression)1 ConditionalExpression (org.yakindu.base.expressions.expressions.ConditionalExpression)1 LogicalAndExpression (org.yakindu.base.expressions.expressions.LogicalAndExpression)1 LogicalNotExpression (org.yakindu.base.expressions.expressions.LogicalNotExpression)1 LogicalOrExpression (org.yakindu.base.expressions.expressions.LogicalOrExpression)1