Search in sources :

Example 1 with SrcErrorHandler

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

the class JavaDialect method addSrc.

@Override
public void addSrc(String resourceName, byte[] content) {
    src.add(resourceName, content);
    this.errorHandlers.put(resourceName, new SrcErrorHandler("Src compile error"));
    addClassName(resourceName);
}
Also used : SrcErrorHandler(org.drools.compiler.builder.impl.errors.SrcErrorHandler)

Example 2 with SrcErrorHandler

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

the class ProjectJavaCompiler method compileAll.

public List<KnowledgeBuilderResult> compileAll(ProjectClassLoader projectClassLoader, List<String> classList, MemoryResourceReader src) {
    List<KnowledgeBuilderResult> results = new ArrayList<KnowledgeBuilderResult>();
    if (classList.isEmpty()) {
        return results;
    }
    final String[] classes = new String[classList.size()];
    classList.toArray(classes);
    CompilationResult result = compiler.compile(classes, src, new ProjectResourceStore(projectClassLoader), projectClassLoader);
    if (result.getErrors().length > 0) {
        Map<String, ErrorHandler> errorHandlerMap = new HashMap<String, ErrorHandler>();
        for (int i = 0; i < result.getErrors().length; i++) {
            final CompilationProblem err = new CompilationProblemAdapter(result.getErrors()[i]);
            ErrorHandler handler = errorHandlerMap.get(err.getFileName());
            if (handler == null) {
                handler = new SrcErrorHandler("Src compile error");
                errorHandlerMap.put(err.getFileName(), handler);
            }
            handler.addError(err);
        }
        for (ErrorHandler handler : errorHandlerMap.values()) {
            if (handler.isInError()) {
                results.add(handler.getError());
            }
        }
    }
    return results;
}
Also used : SrcErrorHandler(org.drools.compiler.builder.impl.errors.SrcErrorHandler) ErrorHandler(org.drools.compiler.builder.impl.errors.ErrorHandler) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CompilationProblem(org.kie.internal.jci.CompilationProblem) SrcErrorHandler(org.drools.compiler.builder.impl.errors.SrcErrorHandler) CompilationResult(org.kie.memorycompiler.CompilationResult) KnowledgeBuilderResult(org.kie.internal.builder.KnowledgeBuilderResult) CompilationProblemAdapter(org.drools.compiler.kie.builder.impl.CompilationProblemAdapter)

Example 3 with SrcErrorHandler

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

the class JavaDialect method addSrc.

public void addSrc(String resourceName, byte[] content) {
    src.add(resourceName, content);
    this.errorHandlers.put(resourceName, new SrcErrorHandler("Src compile error"));
    addClassName(resourceName);
}
Also used : SrcErrorHandler(org.drools.compiler.builder.impl.errors.SrcErrorHandler)

Aggregations

SrcErrorHandler (org.drools.compiler.builder.impl.errors.SrcErrorHandler)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ErrorHandler (org.drools.compiler.builder.impl.errors.ErrorHandler)1 CompilationProblemAdapter (org.drools.compiler.kie.builder.impl.CompilationProblemAdapter)1 KnowledgeBuilderResult (org.kie.internal.builder.KnowledgeBuilderResult)1 CompilationProblem (org.kie.internal.jci.CompilationProblem)1 CompilationResult (org.kie.memorycompiler.CompilationResult)1