Search in sources :

Example 1 with Parameter

use of org.lara.language.specification.dsl.Parameter in project lara-framework by specs-feup.

the class NodeFactory method toNode.

private static ActionNode toNode(Action action) {
    DeclarationNode declNode = toNode(action.getDeclaration());
    ActionNode actionNode = new ActionNode(declNode);
    action.getToolTip().ifPresent(actionNode::setToolTip);
    for (Parameter parameter : action.getParameters()) {
        ParameterNode paramNode = toNode(parameter);
        actionNode.addChild(paramNode);
    }
    return actionNode;
}
Also used : Parameter(org.lara.language.specification.dsl.Parameter)

Example 2 with Parameter

use of org.lara.language.specification.dsl.Parameter in project lara-framework by specs-feup.

the class LangSpecsXmlParser method convertActions.

private static List<Action> convertActions(LanguageSpecificationV2 langSpecV2, List<XmlElement> actionNodes) {
    List<Action> newActions = new ArrayList<>();
    for (var action : actionNodes) {
        var parameterNodes = action.getElementsByName("parameter");
        List<Parameter> declarations = new ArrayList<>();
        for (var param : parameterNodes) {
            IType type = langSpecV2.getType(getType(param));
            String defaultValue = param.getAttribute("default");
            declarations.add(new Parameter(type, param.getAttribute("name"), defaultValue));
        }
        Action newAction = new Action(langSpecV2.getType(action.getAttribute("return", "void")), action.getAttribute("name"), declarations);
        setOptional(action.getAttribute("tooltip"), newAction::setToolTip);
        newActions.add(newAction);
    }
    Collections.sort(newActions);
    return newActions;
}
Also used : Action(org.lara.language.specification.dsl.Action) ArrayList(java.util.ArrayList) Parameter(org.lara.language.specification.dsl.Parameter) IType(org.lara.language.specification.dsl.types.IType)

Aggregations

Parameter (org.lara.language.specification.dsl.Parameter)2 ArrayList (java.util.ArrayList)1 Action (org.lara.language.specification.dsl.Action)1 IType (org.lara.language.specification.dsl.types.IType)1