use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangPackageBuilder method startAnnotationDef.
public void startAnnotationDef(DiagnosticPos pos) {
BLangAnnotation annotNode = (BLangAnnotation) TreeBuilder.createAnnotationNode();
annotNode.pos = pos;
attachAnnotations(annotNode);
attachDocumentations(annotNode);
attachDeprecatedNode(annotNode);
this.annotationStack.add(annotNode);
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addUnionType.
public void addUnionType(DiagnosticPos pos, Set<Whitespace> ws) {
BLangType rhsTypeNode = (BLangType) this.typeNodeStack.pop();
BLangType lhsTypeNode = (BLangType) this.typeNodeStack.pop();
BLangUnionTypeNode unionTypeNode;
if (rhsTypeNode.getKind() == NodeKind.UNION_TYPE_NODE) {
unionTypeNode = (BLangUnionTypeNode) rhsTypeNode;
unionTypeNode.memberTypeNodes.add(0, lhsTypeNode);
this.typeNodeStack.push(unionTypeNode);
return;
} else {
unionTypeNode = (BLangUnionTypeNode) TreeBuilder.createUnionTypeNode();
unionTypeNode.memberTypeNodes.add(lhsTypeNode);
unionTypeNode.memberTypeNodes.add(rhsTypeNode);
}
unionTypeNode.pos = pos;
unionTypeNode.addWS(ws);
this.typeNodeStack.push(unionTypeNode);
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangPackageBuilder method generateBasicVarNode.
private VariableNode generateBasicVarNode(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean exprAvailable) {
BLangVariable var = (BLangVariable) TreeBuilder.createVariableNode();
var.pos = pos;
IdentifierNode name = this.createIdentifier(identifier);
var.setName(name);
var.addWS(ws);
var.setTypeNode(this.typeNodeStack.pop());
if (exprAvailable) {
var.setInitialExpression(this.exprNodeStack.pop());
}
return var;
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangPackageBuilder method createTernaryExpr.
public void createTernaryExpr(DiagnosticPos pos, Set<Whitespace> ws) {
BLangTernaryExpr ternaryExpr = (BLangTernaryExpr) TreeBuilder.createTernaryExpressionNode();
ternaryExpr.pos = pos;
ternaryExpr.addWS(ws);
ternaryExpr.elseExpr = (BLangExpression) exprNodeStack.pop();
ternaryExpr.thenExpr = (BLangExpression) exprNodeStack.pop();
ternaryExpr.expr = (BLangExpression) exprNodeStack.pop();
if (ternaryExpr.expr.getKind() == NodeKind.TERNARY_EXPR) {
// Re-organizing ternary expression tree if there nested ternary expressions.
BLangTernaryExpr root = (BLangTernaryExpr) ternaryExpr.expr;
BLangTernaryExpr parent = root;
while (parent.elseExpr.getKind() == NodeKind.TERNARY_EXPR) {
parent = (BLangTernaryExpr) parent.elseExpr;
}
ternaryExpr.expr = parent.elseExpr;
parent.elseExpr = ternaryExpr;
ternaryExpr = root;
}
addExpressionNode(ternaryExpr);
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addWorkerSendStmt.
public void addWorkerSendStmt(DiagnosticPos pos, Set<Whitespace> ws, String workerName, boolean isForkJoinSend) {
BLangWorkerSend workerSendNode = (BLangWorkerSend) TreeBuilder.createWorkerSendNode();
workerSendNode.setWorkerName(this.createIdentifier(workerName));
exprNodeListStack.pop().forEach(expr -> workerSendNode.exprs.add((BLangExpression) expr));
workerSendNode.addWS(commaWsStack.pop());
workerSendNode.isForkJoinSend = isForkJoinSend;
workerSendNode.pos = pos;
workerSendNode.addWS(ws);
addStmtToCurrentBlock(workerSendNode);
}
Aggregations