use of org.drools.core.base.mvel.MVELReturnValueExpression in project drools by kiegroup.
the class MVELReturnValueBuilder method build.
public void build(final RuleBuildContext context, final BoundIdentifiers usedIdentifiers, final Declaration[] previousDeclarations, final Declaration[] localDeclarations, final ReturnValueRestriction returnValueRestriction, final ReturnValueRestrictionDescr returnValueRestrictionDescr, final AnalysisResult analysis) {
boolean typesafe = context.isTypesafe();
try {
MVELDialect dialect = (MVELDialect) context.getDialect("mvel");
context.setTypesafe(((MVELAnalysisResult) analysis).isTypesafe());
MVELCompilationUnit unit = dialect.getMVELCompilationUnit((String) returnValueRestrictionDescr.getContent(), analysis, previousDeclarations, localDeclarations, null, context, "drools", KnowledgeHelper.class, false, MVELCompilationUnit.Scope.EXPRESSION);
MVELReturnValueExpression expr = new MVELReturnValueExpression(unit, context.getDialect().getId());
returnValueRestriction.setReturnValueExpression(expr);
MVELDialectRuntimeData data = (MVELDialectRuntimeData) context.getPkg().getDialectRuntimeRegistry().getDialectData("mvel");
data.addCompileable(returnValueRestriction, expr);
expr.compile(data, context.getRule());
} catch (final Exception e) {
DialectUtil.copyErrorLocation(e, context.getRuleDescr());
context.addError(new DescrBuildError(context.getParentDescr(), context.getRuleDescr(), null, "Unable to build expression for 'returnValue' : " + e.getMessage() + "'" + context.getRuleDescr().getSalience() + "'"));
} finally {
context.setTypesafe(typesafe);
}
}
Aggregations