use of org.drools.modelcompiler.builder.generator.expressiontyper.TypedExpressionResult in project drools by kiegroup.
the class Query method createFromExpr.
private MethodCallExpr createFromExpr(String variableName, Expression expr) {
MethodCallExpr dslExpr = createDslTopLevelMethod(PATTERN_CALL);
dslExpr.addArgument(context.getVarExpr(variableName));
context.addExpression(dslExpr);
MethodCallExpr fromExpr = createDslTopLevelMethod(FROM_CALL);
LambdaExpr lambdaExpr = new LambdaExpr();
lambdaExpr.setEnclosingParameters(true);
TypedExpressionResult result = new ExpressionTyper(context).toTypedExpression(expr);
for (String usedDeclration : result.getExpressionTyperContext().getUsedDeclarations()) {
fromExpr.addArgument(context.getVarExpr(usedDeclration));
lambdaExpr.addParameter(new Parameter(context.getDelarationType(usedDeclration), usedDeclration));
}
fromExpr.addArgument(lambdaExpr);
if (result.getTypedExpression().isPresent()) {
lambdaExpr.setBody(new ExpressionStmt(result.getTypedExpression().get().getExpression()));
}
return fromExpr;
}
Aggregations