Search in sources :

Example 1 with EvalExpressionBuilder

use of org.drools.modelcompiler.builder.generator.expression.EvalExpressionBuilder in project drools by kiegroup.

the class EvalVisitor method visit.

public void visit(EvalDescr descr) {
    String expression = descr.getContent().toString();
    DrlxParseResult drlxParseResult = ConstraintParser.withoutVariableValidationConstraintParser(context, packageModel).drlxParse(null, null, expression);
    drlxParseResult.accept(drlxParseSuccess -> {
        SingleDrlxParseSuccess singleResult = (SingleDrlxParseSuccess) drlxParseResult;
        Expression rewriteExprAsLambdaWithoutThisParam = DrlxParseUtil.generateLambdaWithoutParameters(singleResult.getUsedDeclarations(), singleResult.getExpr(), true, Optional.empty(), context);
        // rewrites the DrlxParserResult expr as directly the lambda to use
        singleResult.setExpr(rewriteExprAsLambdaWithoutThisParam);
        singleResult.setStatic(true);
        new EvalExpressionBuilder(context).processExpression(singleResult);
    });
}
Also used : SingleDrlxParseSuccess(org.drools.modelcompiler.builder.generator.drlxparse.SingleDrlxParseSuccess) Expression(com.github.javaparser.ast.expr.Expression) DrlxParseResult(org.drools.modelcompiler.builder.generator.drlxparse.DrlxParseResult) EvalExpressionBuilder(org.drools.modelcompiler.builder.generator.expression.EvalExpressionBuilder)

Aggregations

Expression (com.github.javaparser.ast.expr.Expression)1 DrlxParseResult (org.drools.modelcompiler.builder.generator.drlxparse.DrlxParseResult)1 SingleDrlxParseSuccess (org.drools.modelcompiler.builder.generator.drlxparse.SingleDrlxParseSuccess)1 EvalExpressionBuilder (org.drools.modelcompiler.builder.generator.expression.EvalExpressionBuilder)1