Search in sources :

Example 86 with DiagnosticPos

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);
}
Also used : BLangAnnotation(org.wso2.ballerinalang.compiler.tree.BLangAnnotation)

Example 87 with DiagnosticPos

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);
}
Also used : BLangUnionTypeNode(org.wso2.ballerinalang.compiler.tree.types.BLangUnionTypeNode) BLangType(org.wso2.ballerinalang.compiler.tree.types.BLangType)

Example 88 with DiagnosticPos

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;
}
Also used : IdentifierNode(org.ballerinalang.model.tree.IdentifierNode) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Example 89 with DiagnosticPos

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);
}
Also used : BLangTernaryExpr(org.wso2.ballerinalang.compiler.tree.expressions.BLangTernaryExpr)

Example 90 with DiagnosticPos

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);
}
Also used : BLangWorkerSend(org.wso2.ballerinalang.compiler.tree.statements.BLangWorkerSend) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Aggregations

DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)56 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)33 BLangBlockStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt)22 BLangAssignment (org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment)17 ArrayList (java.util.ArrayList)15 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)14 Whitespace (org.ballerinalang.model.Whitespace)13 BLangVariableDef (org.wso2.ballerinalang.compiler.tree.statements.BLangVariableDef)12 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)11 BLangInvocation (org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation)11 IdentifierNode (org.ballerinalang.model.tree.IdentifierNode)9 SelectExpressionNode (org.ballerinalang.model.tree.clauses.SelectExpressionNode)9 ExpressionNode (org.ballerinalang.model.tree.expressions.ExpressionNode)9 BLangNameReference (org.wso2.ballerinalang.compiler.tree.BLangNameReference)9 BLangBinaryExpr (org.wso2.ballerinalang.compiler.tree.expressions.BLangBinaryExpr)9 BLangExpressionStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt)9 BLangIdentifier (org.wso2.ballerinalang.compiler.tree.BLangIdentifier)8 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)8 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)8 BLangXMLQuotedString (org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQuotedString)8