Search in sources :

Example 61 with DiagnosticPos

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

the class BLangPackageBuilder method addEnumerator.

public void addEnumerator(DiagnosticPos pos, Set<Whitespace> ws, String name) {
    BLangEnumerator enumerator = (BLangEnumerator) TreeBuilder.createEnumeratorNode();
    enumerator.pos = pos;
    enumerator.addWS(ws);
    enumerator.name = (BLangIdentifier) createIdentifier(name);
    enumeratorList.add(enumerator);
}
Also used : BLangEnumerator(org.wso2.ballerinalang.compiler.tree.BLangEnum.BLangEnumerator)

Example 62 with DiagnosticPos

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

the class BLangPackageBuilder method endTableQueryNode.

public void endTableQueryNode(boolean isJoinClauseAvailable, boolean isSelectClauseAvailable, boolean isOrderByClauseAvailable, DiagnosticPos pos, Set<Whitespace> ws) {
    BLangTableQuery tableQuery = (BLangTableQuery) this.tableQueriesStack.peek();
    tableQuery.pos = pos;
    tableQuery.addWS(ws);
    tableQuery.setStreamingInput(this.streamingInputStack.pop());
    if (isJoinClauseAvailable) {
        tableQuery.setJoinStreamingInput(this.joinStreamingInputsStack.pop());
    }
    if (isSelectClauseAvailable) {
        tableQuery.setSelectClause(this.selectClausesStack.pop());
    }
    if (isOrderByClauseAvailable) {
        tableQuery.setOrderByClause(this.orderByClauseStack.pop());
    }
}
Also used : BLangTableQuery(org.wso2.ballerinalang.compiler.tree.clauses.BLangTableQuery)

Example 63 with DiagnosticPos

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

the class BLangPackageBuilder method createXMLQuotedLiteral.

public void createXMLQuotedLiteral(DiagnosticPos pos, Set<Whitespace> ws, Stack<String> precedingTextFragments, String endingText, QuoteType quoteType) {
    List<BLangExpression> templateExprs = getExpressionsInTemplate(pos, ws, precedingTextFragments, endingText, NodeKind.LITERAL);
    BLangXMLQuotedString quotedString = (BLangXMLQuotedString) TreeBuilder.createXMLQuotedStringNode();
    quotedString.pos = pos;
    quotedString.quoteType = quoteType;
    quotedString.textFragments = templateExprs;
    addExpressionNode(quotedString);
}
Also used : BLangXMLQuotedString(org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQuotedString) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Example 64 with DiagnosticPos

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

the class BLangPackageBuilder method endTypeDefinition.

public void endTypeDefinition(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean publicStruct) {
    // TODO only adding object type for now
    if (!this.objectStack.isEmpty()) {
        BLangObject objectNode = (BLangObject) this.objectStack.pop();
        objectNode.pos = pos;
        objectNode.setName(this.createIdentifier(identifier));
        if (publicStruct) {
            objectNode.flagSet.add(Flag.PUBLIC);
        }
        objectNode.isAnonymous = false;
        // Create an user defined type with object type
        TypeNode objectType = createUserDefinedType(pos, ws, (BLangIdentifier) TreeBuilder.createIdentifierNode(), objectNode.name);
        // Create and add receiver to attached functions
        BLangVariable receiver = (BLangVariable) TreeBuilder.createVariableNode();
        receiver.pos = pos;
        IdentifierNode name = createIdentifier(Names.SELF.getValue());
        receiver.setName(name);
        receiver.addWS(ws);
        receiver.docTag = DocTag.RECEIVER;
        receiver.setTypeNode(objectType);
        // Cache receiver to add to init function in symbolEnter
        objectNode.receiver = receiver;
        objectNode.functions.forEach(f -> f.setReceiver(receiver));
        this.compUnit.addTopLevelNode(objectNode);
    }
}
Also used : BLangObject(org.wso2.ballerinalang.compiler.tree.BLangObject) IdentifierNode(org.ballerinalang.model.tree.IdentifierNode) BLangTupleTypeNode(org.wso2.ballerinalang.compiler.tree.types.BLangTupleTypeNode) TypeNode(org.ballerinalang.model.tree.types.TypeNode) BLangUnionTypeNode(org.wso2.ballerinalang.compiler.tree.types.BLangUnionTypeNode) BLangFunctionTypeNode(org.wso2.ballerinalang.compiler.tree.types.BLangFunctionTypeNode) BLangBuiltInRefTypeNode(org.wso2.ballerinalang.compiler.tree.types.BLangBuiltInRefTypeNode) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Example 65 with DiagnosticPos

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

the class BLangPackageBuilder method addVariableDefStatement.

public void addVariableDefStatement(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean exprAvailable, boolean endpoint, boolean safeAssignment) {
    BLangVariable var = (BLangVariable) TreeBuilder.createVariableNode();
    BLangVariableDef varDefNode = (BLangVariableDef) TreeBuilder.createVariableDefinitionNode();
    // TODO : Remove endpoint logic from here.
    Set<Whitespace> wsOfSemiColon = null;
    if (endpoint) {
        var.addWS(endpointVarWs);
        var.addWS(endpointKeywordWs);
        endpointVarWs = null;
        endpointKeywordWs = null;
    } else {
        wsOfSemiColon = removeNthFromLast(ws, 0);
    }
    var.pos = pos;
    var.addWS(ws);
    var.setName(this.createIdentifier(identifier));
    var.setTypeNode(this.typeNodeStack.pop());
    var.safeAssignment = safeAssignment;
    if (exprAvailable) {
        var.setInitialExpression(this.exprNodeStack.pop());
    }
    varDefNode.pos = pos;
    varDefNode.setVariable(var);
    varDefNode.addWS(wsOfSemiColon);
    addStmtToCurrentBlock(varDefNode);
}
Also used : BLangVariableDef(org.wso2.ballerinalang.compiler.tree.statements.BLangVariableDef) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) Whitespace(org.ballerinalang.model.Whitespace)

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