use of org.ballerinalang.model.tree.expressions.ExpressionNode in project ballerina by ballerina-lang.
the class SiddhiQueryBuilder method visit.
@Override
public void visit(BLangPatternStreamingEdgeInput patternStreamingEdgeInput) {
BLangExpression streamRef = (BLangExpression) patternStreamingEdgeInput.getStreamReference();
streamRef.accept(this);
streamIds.add(varRef);
varRef = "";
addInRefs(streamRef);
String alias = patternStreamingEdgeInput.getAliasIdentifier();
patternStreamingClause.append(alias).append(" = ").append(patternStreamingEdgeInput.getStreamReference());
WhereNode whereNode = patternStreamingEdgeInput.getWhereClause();
if (whereNode != null) {
((BLangWhere) whereNode).accept(this);
patternStreamingClause.append(" ").append(whereClause);
whereClause = new StringBuilder();
}
ExpressionNode expression = patternStreamingEdgeInput.getExpression();
if (expression != null) {
((BLangExpression) expression).accept(this);
patternStreamingClause.append(intRangeExpr.toString());
}
}
use of org.ballerinalang.model.tree.expressions.ExpressionNode in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addTupleDestructuringStatement.
public void addTupleDestructuringStatement(DiagnosticPos pos, Set<Whitespace> ws, boolean isVarsExist, boolean varDeclaration) {
BLangTupleDestructure stmt = (BLangTupleDestructure) TreeBuilder.createTupleDestructureStatementNode();
stmt.pos = pos;
stmt.addWS(ws);
if (isVarsExist) {
stmt.setDeclaredWithVar(varDeclaration);
stmt.expr = (BLangExpression) exprNodeStack.pop();
List<ExpressionNode> lExprList = exprNodeListStack.pop();
lExprList.forEach(expressionNode -> stmt.varRefs.add((BLangVariableReference) expressionNode));
}
// TODO: handle ParamList Destructue.
addStmtToCurrentBlock(stmt);
}
use of org.ballerinalang.model.tree.expressions.ExpressionNode in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addReturnStatement.
public void addReturnStatement(DiagnosticPos pos, Set<Whitespace> ws, boolean exprAvailable) {
BLangReturn retStmt = (BLangReturn) TreeBuilder.createReturnNode();
retStmt.pos = pos;
retStmt.addWS(ws);
if (exprAvailable) {
retStmt.addWS(commaWsStack.pop());
for (ExpressionNode expr : this.exprNodeListStack.pop()) {
retStmt.exprs.add((BLangExpression) expr);
}
}
addStmtToCurrentBlock(retStmt);
}
use of org.ballerinalang.model.tree.expressions.ExpressionNode in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addForeachStatement.
public void addForeachStatement(DiagnosticPos pos, Set<Whitespace> ws) {
BLangForeach foreach = (BLangForeach) TreeBuilder.createForeachNode();
foreach.addWS(ws);
foreach.pos = pos;
foreach.setCollection(exprNodeStack.pop());
foreach.addWS(commaWsStack.pop());
List<ExpressionNode> lExprList = exprNodeListStack.pop();
lExprList.forEach(expressionNode -> foreach.addVariable((BLangVariableReference) expressionNode));
BLangBlockStmt foreachBlock = (BLangBlockStmt) this.blockNodeStack.pop();
foreachBlock.pos = pos;
foreach.setBody(foreachBlock);
addStmtToCurrentBlock(foreach);
}
use of org.ballerinalang.model.tree.expressions.ExpressionNode in project ballerina by ballerina-lang.
the class BLangPackageBuilder method createInvocationNode.
public void createInvocationNode(DiagnosticPos pos, Set<Whitespace> ws, String invocation, boolean argsAvailable) {
BLangInvocation invocationNode = (BLangInvocation) TreeBuilder.createInvocationNode();
invocationNode.pos = pos;
invocationNode.addWS(ws);
invocationNode.addWS(invocationWsStack.pop());
if (argsAvailable) {
List<ExpressionNode> exprNodes = exprNodeListStack.pop();
exprNodes.forEach(exprNode -> invocationNode.argExprs.add((BLangExpression) exprNode));
invocationNode.addWS(commaWsStack.pop());
}
invocationNode.expr = (BLangVariableReference) exprNodeStack.pop();
invocationNode.name = (BLangIdentifier) createIdentifier(invocation);
invocationNode.pkgAlias = (BLangIdentifier) createIdentifier(null);
addExpressionNode(invocationNode);
}
Aggregations