Search in sources :

Example 1 with MultipleDrlxParseSuccess

use of org.drools.modelcompiler.builder.generator.drlxparse.MultipleDrlxParseSuccess in project drools by kiegroup.

the class PatternExpressionBuilder method buildExpressionWithIndexing.

@Override
public MethodCallExpr buildExpressionWithIndexing(DrlxParseSuccess drlxParseResult) {
    if (drlxParseResult instanceof MultipleDrlxParseSuccess) {
        MultipleDrlxParseSuccess multi = (MultipleDrlxParseSuccess) drlxParseResult;
        MethodCallExpr exprDSL = new MethodCallExpr(null, multi.getOperator() == BinaryExpr.Operator.OR ? EXPR_OR_CALL : EXPR_AND_CALL);
        for (DrlxParseSuccess child : multi.getResults()) {
            MethodCallExpr childExpr = buildExpressionWithIndexing(child);
            childExpr.setScope(exprDSL);
            exprDSL = childExpr;
            if (child instanceof SingleDrlxParseSuccess && child.getExprBinding() != null) {
                SingleDrlxParseSuccess singleDrlxChild = (SingleDrlxParseSuccess) child;
                context.addDeclaration(child.getExprBinding(), singleDrlxChild.getLeftExprRawClass());
                Expression dslExpr = buildBinding(singleDrlxChild);
                context.addExpression(dslExpr);
            }
        }
        return new MethodCallExpr(exprDSL, multi.getOperator() == BinaryExpr.Operator.OR ? EXPR_END_OR_CALL : EXPR_END_AND_CALL);
    }
    return buildSingleExpressionWithIndexing((SingleDrlxParseSuccess) drlxParseResult);
}
Also used : SingleDrlxParseSuccess(org.drools.modelcompiler.builder.generator.drlxparse.SingleDrlxParseSuccess) MultipleDrlxParseSuccess(org.drools.modelcompiler.builder.generator.drlxparse.MultipleDrlxParseSuccess) Expression(com.github.javaparser.ast.expr.Expression) TypedExpression(org.drools.modelcompiler.builder.generator.TypedExpression) DrlxParseSuccess(org.drools.modelcompiler.builder.generator.drlxparse.DrlxParseSuccess) MultipleDrlxParseSuccess(org.drools.modelcompiler.builder.generator.drlxparse.MultipleDrlxParseSuccess) SingleDrlxParseSuccess(org.drools.modelcompiler.builder.generator.drlxparse.SingleDrlxParseSuccess) MethodCallExpr(com.github.javaparser.ast.expr.MethodCallExpr)

Aggregations

Expression (com.github.javaparser.ast.expr.Expression)1 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)1 TypedExpression (org.drools.modelcompiler.builder.generator.TypedExpression)1 DrlxParseSuccess (org.drools.modelcompiler.builder.generator.drlxparse.DrlxParseSuccess)1 MultipleDrlxParseSuccess (org.drools.modelcompiler.builder.generator.drlxparse.MultipleDrlxParseSuccess)1 SingleDrlxParseSuccess (org.drools.modelcompiler.builder.generator.drlxparse.SingleDrlxParseSuccess)1