Search in sources :

Example 6 with ExpressionNode

use of org.wso2.carbon.identity.core.model.ExpressionNode in project ballerina by ballerina-lang.

the class SiddhiQueryBuilder method visit.

@Override
public void visit(BLangGroupBy groupBy) {
    List<? extends ExpressionNode> varList = groupBy.getVariables();
    Iterator<? extends ExpressionNode> iterator = varList.iterator();
    groupByClause = new StringBuilder("group by ");
    BLangSimpleVarRef simpleVarRef = (BLangSimpleVarRef) iterator.next();
    addVarRefToClauseBuilder(simpleVarRef, groupByClause);
    while (iterator.hasNext()) {
        simpleVarRef = (BLangSimpleVarRef) iterator.next();
        groupByClause.append(", ");
        addVarRefToClauseBuilder(simpleVarRef, groupByClause);
    }
}
Also used : BLangSimpleVarRef(org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)

Example 7 with ExpressionNode

use of org.wso2.carbon.identity.core.model.ExpressionNode in project ballerina by ballerina-lang.

the class BLangPackageBuilder method createFunctionInvocation.

public void createFunctionInvocation(DiagnosticPos pos, Set<Whitespace> ws, boolean argsAvailable) {
    BLangInvocation invocationNode = (BLangInvocation) TreeBuilder.createInvocationNode();
    invocationNode.pos = pos;
    invocationNode.addWS(ws);
    if (argsAvailable) {
        List<ExpressionNode> exprNodes = exprNodeListStack.pop();
        exprNodes.forEach(exprNode -> invocationNode.argExprs.add((BLangExpression) exprNode));
        invocationNode.addWS(commaWsStack.pop());
    }
    BLangNameReference nameReference = nameReferenceStack.pop();
    invocationNode.name = (BLangIdentifier) nameReference.name;
    invocationNode.addWS(nameReference.ws);
    invocationNode.pkgAlias = (BLangIdentifier) nameReference.pkgAlias;
    addExpressionNode(invocationNode);
}
Also used : BLangNameReference(org.wso2.ballerinalang.compiler.tree.BLangNameReference) ExpressionNode(org.ballerinalang.model.tree.expressions.ExpressionNode) SelectExpressionNode(org.ballerinalang.model.tree.clauses.SelectExpressionNode) BLangInvocation(org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Example 8 with ExpressionNode

use of org.wso2.carbon.identity.core.model.ExpressionNode in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addThrowStmt.

public void addThrowStmt(DiagnosticPos poc, Set<Whitespace> ws) {
    ExpressionNode throwExpr = this.exprNodeStack.pop();
    BLangThrow throwNode = (BLangThrow) TreeBuilder.createThrowNode();
    throwNode.pos = poc;
    throwNode.addWS(ws);
    throwNode.expr = (BLangExpression) throwExpr;
    addStmtToCurrentBlock(throwNode);
}
Also used : BLangThrow(org.wso2.ballerinalang.compiler.tree.statements.BLangThrow) ExpressionNode(org.ballerinalang.model.tree.expressions.ExpressionNode) SelectExpressionNode(org.ballerinalang.model.tree.clauses.SelectExpressionNode)

Example 9 with ExpressionNode

use of org.wso2.carbon.identity.core.model.ExpressionNode in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addArrayInitExpr.

public void addArrayInitExpr(DiagnosticPos pos, Set<Whitespace> ws, boolean argsAvailable) {
    List<ExpressionNode> argExprList;
    BLangArrayLiteral arrayLiteral = (BLangArrayLiteral) TreeBuilder.createArrayLiteralNode();
    if (argsAvailable) {
        arrayLiteral.addWS(commaWsStack.pop());
        argExprList = exprNodeListStack.pop();
    } else {
        argExprList = new ArrayList<>(0);
    }
    arrayLiteral.exprs = argExprList.stream().map(expr -> (BLangExpression) expr).collect(Collectors.toList());
    arrayLiteral.pos = pos;
    arrayLiteral.addWS(ws);
    addExpressionNode(arrayLiteral);
}
Also used : ExpressionNode(org.ballerinalang.model.tree.expressions.ExpressionNode) SelectExpressionNode(org.ballerinalang.model.tree.clauses.SelectExpressionNode) BLangArrayLiteral(org.wso2.ballerinalang.compiler.tree.expressions.BLangArrayLiteral)

Example 10 with ExpressionNode

use of org.wso2.carbon.identity.core.model.ExpressionNode in project ballerina by ballerina-lang.

the class SqlQueryBuilder method visit.

@Override
public void visit(BLangGroupBy groupBy) {
    List<? extends ExpressionNode> varList = groupBy.getVariables();
    Iterator<? extends ExpressionNode> iterator = varList.iterator();
    groupByClause = new StringBuilder("group by ");
    BLangExpression expr = (BLangExpression) iterator.next();
    expr.accept(this);
    groupByClause.append(exprStack.pop());
    while (iterator.hasNext()) {
        expr = (BLangExpression) iterator.next();
        groupByClause.append(", ");
        expr.accept(this);
        groupByClause.append(exprStack.pop());
    }
}
Also used : BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Aggregations

ExpressionNode (org.ballerinalang.model.tree.expressions.ExpressionNode)21 ArrayList (java.util.ArrayList)16 SelectExpressionNode (org.ballerinalang.model.tree.clauses.SelectExpressionNode)16 ExpressionNode (org.wso2.carbon.identity.core.model.ExpressionNode)15 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)12 BadRequestException (org.wso2.charon3.core.exceptions.BadRequestException)8 ExpressionNode (org.wso2.charon3.core.utils.codeutils.ExpressionNode)7 Map (java.util.Map)6 IdentityException (org.wso2.carbon.identity.base.IdentityException)6 Attribute (org.wso2.charon3.core.attributes.Attribute)6 ComplexAttribute (org.wso2.charon3.core.attributes.ComplexAttribute)6 MultiValuedAttribute (org.wso2.charon3.core.attributes.MultiValuedAttribute)6 SimpleAttribute (org.wso2.charon3.core.attributes.SimpleAttribute)6 Connection (java.sql.Connection)5 KubernetesPluginException (org.ballerinax.kubernetes.exceptions.KubernetesPluginException)5 JSONObject (org.json.JSONObject)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 Test (org.testng.annotations.Test)5 Node (org.wso2.carbon.identity.core.model.Node)5 IdpSearchResult (org.wso2.carbon.idp.mgt.model.IdpSearchResult)5