Search in sources :

Example 6 with ExpressionNode

use of org.wso2.charon3.core.utils.codeutils.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.charon3.core.utils.codeutils.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.charon3.core.utils.codeutils.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.charon3.core.utils.codeutils.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.charon3.core.utils.codeutils.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

SelectExpressionNode (org.ballerinalang.model.tree.clauses.SelectExpressionNode)16 ExpressionNode (org.ballerinalang.model.tree.expressions.ExpressionNode)16 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)11 BadRequestException (org.wso2.charon3.core.exceptions.BadRequestException)8 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 Map (java.util.Map)4 JSONObject (org.json.JSONObject)3 BLangInvocation (org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation)3 AbstractSCIMObject (org.wso2.charon3.core.objects.AbstractSCIMObject)3 AttributeSchema (org.wso2.charon3.core.schema.AttributeSchema)3 Iterator (java.util.Iterator)2 List (java.util.List)2 JSONArray (org.json.JSONArray)2 BLangNameReference (org.wso2.ballerinalang.compiler.tree.BLangNameReference)2 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)2 BLangVariableReference (org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference)2 NotImplementedException (org.wso2.charon3.core.exceptions.NotImplementedException)2