Search in sources :

Example 71 with DiagnosticPos

use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos 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 72 with DiagnosticPos

use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addWhileStmt.

public void addWhileStmt(DiagnosticPos pos, Set<Whitespace> ws) {
    BLangWhile whileNode = (BLangWhile) TreeBuilder.createWhileNode();
    whileNode.setCondition(exprNodeStack.pop());
    whileNode.pos = pos;
    whileNode.addWS(ws);
    BLangBlockStmt whileBlock = (BLangBlockStmt) this.blockNodeStack.pop();
    whileBlock.pos = pos;
    whileNode.setBody(whileBlock);
    addStmtToCurrentBlock(whileNode);
}
Also used : BLangBlockStmt(org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt) BLangWhile(org.wso2.ballerinalang.compiler.tree.statements.BLangWhile)

Example 73 with DiagnosticPos

use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.

the class BLangPackageBuilder method startServiceDef.

public void startServiceDef(DiagnosticPos pos) {
    BLangService serviceNode = (BLangService) TreeBuilder.createServiceNode();
    serviceNode.pos = pos;
    attachAnnotations(serviceNode);
    attachDocumentations(serviceNode);
    attachDeprecatedNode(serviceNode);
    serviceNodeStack.push(serviceNode);
    startEndpointDeclarationScope(serviceNode.endpoints);
}
Also used : BLangService(org.wso2.ballerinalang.compiler.tree.BLangService)

Example 74 with DiagnosticPos

use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.

the class BLangPackageBuilder method createXMLPILiteral.

public void createXMLPILiteral(DiagnosticPos pos, Set<Whitespace> ws, String targetQName, Stack<String> precedingTextFragments, String endingText) {
    List<BLangExpression> dataExprs = getExpressionsInTemplate(pos, ws, precedingTextFragments, endingText, NodeKind.LITERAL);
    addLiteralValue(pos, ws, TypeTags.STRING, targetQName);
    BLangXMLProcInsLiteral xmlProcInsLiteral = (BLangXMLProcInsLiteral) TreeBuilder.createXMLProcessingIntsructionLiteralNode();
    xmlProcInsLiteral.pos = pos;
    xmlProcInsLiteral.dataFragments = dataExprs;
    xmlProcInsLiteral.target = (BLangLiteral) exprNodeStack.pop();
    ;
    addExpressionNode(xmlProcInsLiteral);
}
Also used : BLangXMLProcInsLiteral(org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLProcInsLiteral) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Example 75 with DiagnosticPos

use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.

the class BLangPackageBuilder method getExpressionsInTemplate.

// Private methods
private List<BLangExpression> getExpressionsInTemplate(DiagnosticPos pos, Set<Whitespace> ws, Stack<String> precedingTextFragments, String endingText, NodeKind targetStrExprKind) {
    List<BLangExpression> expressions = new ArrayList<>();
    endingText = endingText == null ? "" : StringEscapeUtils.unescapeJava(endingText);
    addLiteralValue(pos, ws, TypeTags.STRING, endingText);
    expressions.add((BLangExpression) exprNodeStack.pop());
    while (!precedingTextFragments.empty()) {
        expressions.add((BLangExpression) exprNodeStack.pop());
        String textFragment = precedingTextFragments.pop();
        textFragment = textFragment == null ? "" : StringEscapeUtils.unescapeJava(textFragment);
        addLiteralValue(pos, ws, TypeTags.STRING, textFragment);
        expressions.add((BLangExpression) exprNodeStack.pop());
    }
    Collections.reverse(expressions);
    return expressions;
}
Also used : ArrayList(java.util.ArrayList) BLangXMLQuotedString(org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQuotedString) 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