Search in sources :

Example 81 with DiagnosticPos

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

the class BLangPackageBuilder method addAnonStructType.

public void addAnonStructType(DiagnosticPos pos, Set<Whitespace> ws) {
    // Generate a name for the anonymous struct
    String genName = anonymousModelHelper.getNextAnonymousStructKey(pos.src.pkgID);
    IdentifierNode anonStructGenName = createIdentifier(genName);
    // Create an anonymous struct and add it to the list of structs in the current package.
    BLangStruct structNode = populateStructNode(pos, ws, anonStructGenName, true);
    this.compUnit.addTopLevelNode(structNode);
    addType(createUserDefinedType(pos, ws, (BLangIdentifier) TreeBuilder.createIdentifierNode(), structNode.name));
}
Also used : IdentifierNode(org.ballerinalang.model.tree.IdentifierNode) BLangStruct(org.wso2.ballerinalang.compiler.tree.BLangStruct) BLangXMLQuotedString(org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQuotedString) BLangIdentifier(org.wso2.ballerinalang.compiler.tree.BLangIdentifier)

Example 82 with DiagnosticPos

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

the class BLangPackageBuilder method createUserDefinedType.

private BLangUserDefinedType createUserDefinedType(DiagnosticPos pos, Set<Whitespace> ws, BLangIdentifier pkgAlias, BLangIdentifier name) {
    BLangUserDefinedType userDefinedType = (BLangUserDefinedType) TreeBuilder.createUserDefinedTypeNode();
    userDefinedType.pos = pos;
    userDefinedType.addWS(ws);
    userDefinedType.pkgAlias = pkgAlias;
    userDefinedType.typeName = name;
    return userDefinedType;
}
Also used : BLangUserDefinedType(org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType)

Example 83 with DiagnosticPos

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

the class BLangPackageBuilder method addXMLNSDeclaration.

public void addXMLNSDeclaration(DiagnosticPos pos, Set<Whitespace> ws, String namespaceUri, String prefix, boolean isTopLevel) {
    BLangXMLNS xmlns = (BLangXMLNS) TreeBuilder.createXMLNSNode();
    BLangIdentifier prefixIdentifer = (BLangIdentifier) TreeBuilder.createIdentifierNode();
    prefixIdentifer.pos = pos;
    prefixIdentifer.value = prefix;
    addLiteralValue(pos, removeNthFromStart(ws, 1), TypeTags.STRING, namespaceUri);
    xmlns.namespaceURI = (BLangLiteral) exprNodeStack.pop();
    xmlns.prefix = prefixIdentifer;
    xmlns.pos = pos;
    xmlns.addWS(ws);
    if (isTopLevel) {
        this.compUnit.addTopLevelNode(xmlns);
        return;
    }
    BLangXMLNSStatement xmlnsStmt = (BLangXMLNSStatement) TreeBuilder.createXMLNSDeclrStatementNode();
    xmlnsStmt.xmlnsDecl = xmlns;
    xmlnsStmt.pos = pos;
    addStmtToCurrentBlock(xmlnsStmt);
}
Also used : BLangXMLNS(org.wso2.ballerinalang.compiler.tree.BLangXMLNS) BLangXMLNSStatement(org.wso2.ballerinalang.compiler.tree.statements.BLangXMLNSStatement) BLangIdentifier(org.wso2.ballerinalang.compiler.tree.BLangIdentifier)

Example 84 with DiagnosticPos

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

the class BLangPackageBuilder method addForkJoinStmt.

public void addForkJoinStmt(DiagnosticPos pos, Set<Whitespace> ws) {
    BLangForkJoin forkJoin = (BLangForkJoin) this.forkJoinNodesStack.pop();
    forkJoin.pos = pos;
    forkJoin.addWS(ws);
    this.addStmtToCurrentBlock(forkJoin);
}
Also used : BLangForkJoin(org.wso2.ballerinalang.compiler.tree.statements.BLangForkJoin)

Example 85 with DiagnosticPos

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

the class BLangPackageBuilder method endStreamingInputNode.

public void endStreamingInputNode(String alias, DiagnosticPos pos, Set<Whitespace> ws) {
    BLangStreamingInput streamingInput = (BLangStreamingInput) this.streamingInputStack.peek();
    streamingInput.pos = pos;
    streamingInput.addWS(ws);
    if (this.whereClauseStack.size() == 2) {
        streamingInput.setAfterStreamingCondition(this.whereClauseStack.pop());
        streamingInput.setBeforeStreamingCondition(this.whereClauseStack.pop());
    } else if (this.whereClauseStack.size() == 1) {
        if (streamingInput.isWindowTraversedAfterWhere()) {
            streamingInput.setBeforeStreamingCondition(this.whereClauseStack.pop());
        } else {
            streamingInput.setAfterStreamingCondition(this.whereClauseStack.pop());
        }
    }
    if (!this.windowClausesStack.empty()) {
        streamingInput.setWindowClause(this.windowClausesStack.pop());
    }
    streamingInput.setStreamReference(this.exprNodeStack.pop());
    streamingInput.setAlias(alias);
}
Also used : BLangStreamingInput(org.wso2.ballerinalang.compiler.tree.clauses.BLangStreamingInput)

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