use of org.drools.mvel.parser.ast.expr.DrlNameExpr in project drools by kiegroup.
the class PreprocessPhase method assignToFieldAccess.
private AssignExpr assignToFieldAccess(PreprocessPhaseResult result, Expression scope, AssignExpr assignExpr) {
DrlNameExpr originalFieldAccess = (DrlNameExpr) assignExpr.getTarget();
String propertyName = originalFieldAccess.getName().asString();
result.addUsedBinding(printNode(scope));
FieldAccessExpr fieldAccessWithScope = new FieldAccessExpr(scope, propertyName);
assignExpr.setTarget(fieldAccessWithScope);
return assignExpr;
}
use of org.drools.mvel.parser.ast.expr.DrlNameExpr in project drools by kiegroup.
the class PreprocessPhase method addScopeToMethodCallExpr.
private Statement addScopeToMethodCallExpr(PreprocessPhaseResult result, Expression scope, Statement e) {
if (e != null && e.isExpressionStmt()) {
Expression expression = e.asExpressionStmt().getExpression();
if (expression.isMethodCallExpr()) {
MethodCallExpr mcExpr = expression.asMethodCallExpr();
MethodCallExpr rootMcExpr = findRootScope(mcExpr);
if (rootMcExpr == null) {
return e;
}
Expression enclosed = new EnclosedExpr(scope);
rootMcExpr.setScope(enclosed);
if (scope.isNameExpr() || scope instanceof DrlNameExpr) {
// some classes such "AtomicInteger" have a setter called "set"
result.addUsedBinding(printNode(scope));
}
return new ExpressionStmt(mcExpr);
}
}
return e;
}
use of org.drools.mvel.parser.ast.expr.DrlNameExpr in project drools by kiegroup.
the class AccumulateVisitor method parseFirstParameter.
private Optional<NewBinding> parseFirstParameter(PatternDescr basePattern, BaseDescr input, AccumulateDescr.AccumulateFunctionCallDescr function, MethodCallExpr functionDSL, String bindingId) {
final String accumulateFunctionParameterStr = function.getParams()[0];
final Expression accumulateFunctionParameter = DrlxParseUtil.parseExpression(accumulateFunctionParameterStr).getExpr();
if (accumulateFunctionParameter instanceof BinaryExpr) {
return binaryExprParameter(basePattern, function, functionDSL, bindingId, accumulateFunctionParameterStr);
}
if (parameterNeedsConvertionToMethodCallExpr(accumulateFunctionParameter)) {
return methodCallExprParameter(basePattern, input, function, functionDSL, bindingId, accumulateFunctionParameter);
}
if (accumulateFunctionParameter instanceof DrlNameExpr) {
nameExprParameter(basePattern, function, functionDSL, bindingId, accumulateFunctionParameter);
} else if (accumulateFunctionParameter instanceof LiteralExpr) {
literalExprParameter(basePattern, function, functionDSL, bindingId, accumulateFunctionParameter);
} else {
context.addCompilationError(new InvalidExpressionErrorResult("Invalid expression " + accumulateFunctionParameterStr, Optional.of(context.getRuleDescr())));
throw new AccumulateParsingFailedException();
}
return Optional.empty();
}
Aggregations