Search in sources :

Example 1 with FunctionErrorHandler

use of org.drools.compiler.builder.impl.errors.FunctionErrorHandler in project drools by kiegroup.

the class JavaDialect method addFunction.

public void addFunction(final FunctionDescr functionDescr, final TypeResolver typeResolver, final Resource resource) {
    // logger.info( functionDescr + " : " + typeResolver );
    final String functionClassName = this.pkg.getName() + "." + StringUtils.ucFirst(functionDescr.getName());
    functionDescr.setClassName(functionClassName);
    this.pkg.addStaticImport(functionClassName + "." + functionDescr.getName());
    Function function = new Function(functionDescr.getNamespace(), functionDescr.getName(), ID);
    if (resource != null && ((InternalResource) resource).hasURL()) {
        function.setResource(resource);
    }
    this.pkg.addFunction(function);
    final String functionSrc = getFunctionBuilder().build(this.pkg, functionDescr, typeResolver, this.pkg.getDialectRuntimeRegistry().getLineMappings(), this.results);
    addClassCompileTask(functionClassName, functionDescr, functionSrc, this.src, new FunctionErrorHandler(functionDescr, "Function Compilation error"));
    final LineMappings mapping = new LineMappings(functionClassName);
    mapping.setStartLine(functionDescr.getLine());
    mapping.setOffset(functionDescr.getOffset());
    this.pkg.getDialectRuntimeRegistry().getLineMappings().put(functionClassName, mapping);
}
Also used : Function(org.drools.core.rule.Function) LineMappings(org.drools.core.rule.LineMappings) FunctionErrorHandler(org.drools.compiler.builder.impl.errors.FunctionErrorHandler)

Aggregations

FunctionErrorHandler (org.drools.compiler.builder.impl.errors.FunctionErrorHandler)1 Function (org.drools.core.rule.Function)1 LineMappings (org.drools.core.rule.LineMappings)1