Search in sources :

Example 1 with TypeAndFn

use of org.kie.dmn.feel.lang.ast.AtLiteralNode.TypeAndFn in project drools by kiegroup.

the class ASTCompilerVisitor method visit.

@Override
public DirectCompilerResult visit(AtLiteralNode n) {
    DirectCompilerResult stringLiteral = n.getStringLiteral().accept(this);
    String value = ((StringLiteralExpr) stringLiteral.getExpression()).asString();
    TypeAndFn typeAndFn = AtLiteralNode.fromAtValue(value);
    String functionName = typeAndFn.fnName;
    Type resultType = typeAndFn.type;
    if (resultType == BuiltInType.UNKNOWN) {
        return DirectCompilerResult.of(CompiledFEELSupport.compiledErrorExpression(Msg.createMessage(Msg.MALFORMED_AT_LITERAL, n.getText())), BuiltInType.UNKNOWN);
    }
    return DirectCompilerResult.of(Expressions.invoke(FeelCtx.getValue(functionName), stringLiteral.getExpression()), resultType).withFD(stringLiteral);
}
Also used : SimpleType(org.kie.dmn.feel.lang.SimpleType) UnknownType(com.github.javaparser.ast.type.UnknownType) BuiltInType(org.kie.dmn.feel.lang.types.BuiltInType) MapBackedType(org.kie.dmn.feel.lang.impl.MapBackedType) CompositeType(org.kie.dmn.feel.lang.CompositeType) Type(org.kie.dmn.feel.lang.Type) StringLiteralExpr(com.github.javaparser.ast.expr.StringLiteralExpr) TypeAndFn(org.kie.dmn.feel.lang.ast.AtLiteralNode.TypeAndFn)

Aggregations

StringLiteralExpr (com.github.javaparser.ast.expr.StringLiteralExpr)1 UnknownType (com.github.javaparser.ast.type.UnknownType)1 CompositeType (org.kie.dmn.feel.lang.CompositeType)1 SimpleType (org.kie.dmn.feel.lang.SimpleType)1 Type (org.kie.dmn.feel.lang.Type)1 TypeAndFn (org.kie.dmn.feel.lang.ast.AtLiteralNode.TypeAndFn)1 MapBackedType (org.kie.dmn.feel.lang.impl.MapBackedType)1 BuiltInType (org.kie.dmn.feel.lang.types.BuiltInType)1