Search in sources :

Example 1 with DeclarativeInvokerDescr

use of org.drools.drl.ast.descr.DeclarativeInvokerDescr in project drools by kiegroup.

the class AccumulateInline method parseAccumulatePattern.

void parseAccumulatePattern() {
    PatternDescr pattern = accumulateDescr.getInputPattern();
    if (pattern == null || pattern.getSource() == null) {
        return;
    }
    PatternSourceDescr sourceDescr = pattern.getSource();
    if (sourceDescr instanceof FromDescr) {
        DeclarativeInvokerDescr invokerDescr = ((FromDescr) sourceDescr).getDataSource();
        String mvelBlock = addCurlyBracesToBlock(addSemicolon(invokerDescr.getText()));
        CompiledBlockResult fromCodeCompilationResult = mvelCompiler.compileStatement(mvelBlock);
        BlockStmt fromBlock = fromCodeCompilationResult.statementResults();
        for (Statement stmt : fromBlock.getStatements()) {
            stmt.findAll(NameExpr.class).stream().map(Node::toString).filter(context::hasDeclaration).forEach(usedExternalDeclarations::add);
        }
    }
}
Also used : PatternDescr(org.drools.drl.ast.descr.PatternDescr) StaticJavaParser.parseStatement(com.github.javaparser.StaticJavaParser.parseStatement) Statement(com.github.javaparser.ast.stmt.Statement) PatternSourceDescr(org.drools.drl.ast.descr.PatternSourceDescr) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) Node(com.github.javaparser.ast.Node) FromDescr(org.drools.drl.ast.descr.FromDescr) CompiledBlockResult(org.drools.mvelcompiler.CompiledBlockResult) DeclarativeInvokerDescr(org.drools.drl.ast.descr.DeclarativeInvokerDescr)

Aggregations

StaticJavaParser.parseStatement (com.github.javaparser.StaticJavaParser.parseStatement)1 Node (com.github.javaparser.ast.Node)1 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)1 Statement (com.github.javaparser.ast.stmt.Statement)1 DeclarativeInvokerDescr (org.drools.drl.ast.descr.DeclarativeInvokerDescr)1 FromDescr (org.drools.drl.ast.descr.FromDescr)1 PatternDescr (org.drools.drl.ast.descr.PatternDescr)1 PatternSourceDescr (org.drools.drl.ast.descr.PatternSourceDescr)1 CompiledBlockResult (org.drools.mvelcompiler.CompiledBlockResult)1