Search in sources :

Example 1 with IfNode

use of org.ballerinalang.model.tree.statements.IfNode in project ballerina by ballerina-lang.

the class BLangPackageBuilder method endIfElseNode.

public void endIfElseNode(Set<Whitespace> ws) {
    IfNode ifNode = ifElseStatementStack.pop();
    ifNode.addWS(ws);
    addStmtToCurrentBlock(ifNode);
}
Also used : IfNode(org.ballerinalang.model.tree.statements.IfNode)

Example 2 with IfNode

use of org.ballerinalang.model.tree.statements.IfNode in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addIfBlock.

public void addIfBlock(DiagnosticPos pos, Set<Whitespace> ws) {
    IfNode ifNode = ifElseStatementStack.peek();
    ((BLangIf) ifNode).pos = pos;
    ifNode.addWS(ws);
    ifNode.setCondition(exprNodeStack.pop());
    ifNode.setBody(blockNodeStack.pop());
}
Also used : IfNode(org.ballerinalang.model.tree.statements.IfNode)

Example 3 with IfNode

use of org.ballerinalang.model.tree.statements.IfNode in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addElseBlock.

public void addElseBlock(DiagnosticPos pos, Set<Whitespace> ws) {
    IfNode ifNode = ifElseStatementStack.peek();
    while (ifNode.getElseStatement() != null) {
        ifNode = (IfNode) ifNode.getElseStatement();
    }
    ifNode.addWS(ws);
    BlockNode elseBlock = blockNodeStack.pop();
    ((BLangBlockStmt) elseBlock).pos = pos;
    ifNode.setElseStatement(elseBlock);
}
Also used : BlockNode(org.ballerinalang.model.tree.statements.BlockNode) IfNode(org.ballerinalang.model.tree.statements.IfNode)

Example 4 with IfNode

use of org.ballerinalang.model.tree.statements.IfNode in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addElseIfBlock.

public void addElseIfBlock(DiagnosticPos pos, Set<Whitespace> ws) {
    IfNode elseIfNode = ifElseStatementStack.pop();
    ((BLangIf) elseIfNode).pos = pos;
    elseIfNode.setCondition(exprNodeStack.pop());
    elseIfNode.setBody(blockNodeStack.pop());
    Set<Whitespace> elseWS = removeNthFromStart(ws, 0);
    elseIfNode.addWS(ws);
    IfNode parentIfNode = ifElseStatementStack.peek();
    while (parentIfNode.getElseStatement() != null) {
        parentIfNode = (IfNode) parentIfNode.getElseStatement();
    }
    parentIfNode.addWS(elseWS);
    parentIfNode.setElseStatement(elseIfNode);
}
Also used : IfNode(org.ballerinalang.model.tree.statements.IfNode) Whitespace(org.ballerinalang.model.Whitespace)

Aggregations

IfNode (org.ballerinalang.model.tree.statements.IfNode)4 Whitespace (org.ballerinalang.model.Whitespace)1 BlockNode (org.ballerinalang.model.tree.statements.BlockNode)1