Search in sources :

Example 1 with ModifyStatement

use of org.drools.mvel.parser.ast.expr.ModifyStatement in project drools by kiegroup.

the class PreprocessPhase method modifyPreprocessor.

private PreprocessPhaseResult modifyPreprocessor(ModifyStatement modifyStatement) {
    PreprocessPhaseResult result = new PreprocessedResult();
    final Expression scope = modifyStatement.getModifyObject();
    modifyStatement.findAll(AssignExpr.class).replaceAll(assignExpr -> assignToFieldAccess(result, scope, assignExpr));
    // Do not use findAll as we should only process top level expressions
    modifyStatement.getExpressions().replaceAll(e -> addScopeToMethodCallExpr(result, scope, e));
    NodeList<Statement> statements = wrapToExpressionStmt(modifyStatement.getExpressions());
    // delete modify statement and replace its own block of statements
    modifyStatement.replace(new BlockStmt(statements));
    return result;
}
Also used : Expression(com.github.javaparser.ast.expr.Expression) WithStatement(org.drools.mvel.parser.ast.expr.WithStatement) ModifyStatement(org.drools.mvel.parser.ast.expr.ModifyStatement) Statement(com.github.javaparser.ast.stmt.Statement) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) AssignExpr(com.github.javaparser.ast.expr.AssignExpr)

Aggregations

AssignExpr (com.github.javaparser.ast.expr.AssignExpr)1 Expression (com.github.javaparser.ast.expr.Expression)1 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)1 Statement (com.github.javaparser.ast.stmt.Statement)1 ModifyStatement (org.drools.mvel.parser.ast.expr.ModifyStatement)1 WithStatement (org.drools.mvel.parser.ast.expr.WithStatement)1