Search in sources :

Example 1 with NodeWithSimpleName

use of org.drools.javaparser.ast.nodeTypes.NodeWithSimpleName in project drools by kiegroup.

the class DrlxParseUtil method createExpressionCall.

private static Expression createExpressionCall(Expression expr, Deque<ParsedMethod> expressions) {
    if (expr instanceof NodeWithSimpleName) {
        NodeWithSimpleName fae = (NodeWithSimpleName) expr;
        expressions.push(new ParsedMethod(expr, fae.getName().asString()));
    }
    if (expr instanceof NodeWithOptionalScope) {
        final NodeWithOptionalScope<?> exprWithScope = (NodeWithOptionalScope) expr;
        exprWithScope.getScope().map((Expression scope) -> createExpressionCall(scope, expressions));
    } else if (expr instanceof FieldAccessExpr) {
        // Cannot recurse over getScope() as FieldAccessExpr doesn't support the NodeWithOptionalScope,
        // it will support a new interface to traverse among scopes called NodeWithTraversableScope so
        // we can merge this and the previous branch
        createExpressionCall(((FieldAccessExpr) expr).getScope(), expressions);
    }
    return expr;
}
Also used : NodeWithSimpleName(org.drools.javaparser.ast.nodeTypes.NodeWithSimpleName) Expression(org.drools.javaparser.ast.expr.Expression) DrlxExpression(org.drools.javaparser.ast.drlx.expr.DrlxExpression) NodeWithOptionalScope(org.drools.javaparser.ast.nodeTypes.NodeWithOptionalScope) FieldAccessExpr(org.drools.javaparser.ast.expr.FieldAccessExpr)

Aggregations

DrlxExpression (org.drools.javaparser.ast.drlx.expr.DrlxExpression)1 Expression (org.drools.javaparser.ast.expr.Expression)1 FieldAccessExpr (org.drools.javaparser.ast.expr.FieldAccessExpr)1 NodeWithOptionalScope (org.drools.javaparser.ast.nodeTypes.NodeWithOptionalScope)1 NodeWithSimpleName (org.drools.javaparser.ast.nodeTypes.NodeWithSimpleName)1