Search in sources :

Example 1 with BLangNameReference

use of org.wso2.ballerinalang.compiler.tree.BLangNameReference in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addNameReference.

public void addNameReference(DiagnosticPos currentPos, Set<Whitespace> ws, String pkgName, String name) {
    IdentifierNode pkgNameNode = createIdentifier(pkgName);
    IdentifierNode nameNode = createIdentifier(name);
    nameReferenceStack.push(new BLangNameReference(currentPos, ws, pkgNameNode, nameNode));
}
Also used : BLangNameReference(org.wso2.ballerinalang.compiler.tree.BLangNameReference) IdentifierNode(org.ballerinalang.model.tree.IdentifierNode)

Example 2 with BLangNameReference

use of org.wso2.ballerinalang.compiler.tree.BLangNameReference 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 3 with BLangNameReference

use of org.wso2.ballerinalang.compiler.tree.BLangNameReference in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addEndpointType.

public void addEndpointType(DiagnosticPos pos, Set<Whitespace> ws) {
    BLangNameReference nameReference = nameReferenceStack.pop();
    BLangUserDefinedType constraintType = (BLangUserDefinedType) TreeBuilder.createUserDefinedTypeNode();
    constraintType.pos = pos;
    constraintType.pkgAlias = (BLangIdentifier) nameReference.pkgAlias;
    constraintType.typeName = (BLangIdentifier) nameReference.name;
    constraintType.addWS(nameReference.ws);
    addType(constraintType);
}
Also used : BLangNameReference(org.wso2.ballerinalang.compiler.tree.BLangNameReference) BLangUserDefinedType(org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType)

Example 4 with BLangNameReference

use of org.wso2.ballerinalang.compiler.tree.BLangNameReference in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addConstraintType.

public void addConstraintType(DiagnosticPos pos, Set<Whitespace> ws, String typeName) {
    BLangNameReference nameReference = nameReferenceStack.pop();
    BLangUserDefinedType constraintType = (BLangUserDefinedType) TreeBuilder.createUserDefinedTypeNode();
    constraintType.pos = pos;
    constraintType.pkgAlias = (BLangIdentifier) nameReference.pkgAlias;
    constraintType.typeName = (BLangIdentifier) nameReference.name;
    constraintType.addWS(nameReference.ws);
    Set<Whitespace> refTypeWS = removeNthFromLast(ws, 2);
    BLangBuiltInRefTypeNode refType = (BLangBuiltInRefTypeNode) TreeBuilder.createBuiltInReferenceTypeNode();
    refType.typeKind = TreeUtils.stringToTypeKind(typeName);
    refType.pos = pos;
    refType.addWS(refTypeWS);
    BLangConstrainedType constrainedType = (BLangConstrainedType) TreeBuilder.createConstrainedTypeNode();
    constrainedType.type = refType;
    constrainedType.constraint = constraintType;
    constrainedType.pos = pos;
    constrainedType.addWS(ws);
    addType(constrainedType);
}
Also used : BLangConstrainedType(org.wso2.ballerinalang.compiler.tree.types.BLangConstrainedType) BLangNameReference(org.wso2.ballerinalang.compiler.tree.BLangNameReference) BLangBuiltInRefTypeNode(org.wso2.ballerinalang.compiler.tree.types.BLangBuiltInRefTypeNode) BLangUserDefinedType(org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType) Whitespace(org.ballerinalang.model.Whitespace)

Example 5 with BLangNameReference

use of org.wso2.ballerinalang.compiler.tree.BLangNameReference in project ballerina by ballerina-lang.

the class BLangPackageBuilder method endServiceDef.

public void endServiceDef(DiagnosticPos pos, Set<Whitespace> ws, String serviceName, boolean constrained) {
    BLangService serviceNode = (BLangService) serviceNodeStack.pop();
    serviceNode.setName(createIdentifier(serviceName));
    if (constrained) {
        final BLangNameReference epName = nameReferenceStack.pop();
        serviceNode.setServiceTypeStruct(createUserDefinedType(pos, epName.ws, (BLangIdentifier) epName.pkgAlias, (BLangIdentifier) epName.name));
    }
    serviceNode.pos = pos;
    serviceNode.addWS(ws);
    this.compUnit.addTopLevelNode(serviceNode);
    endEndpointDeclarationScope();
}
Also used : BLangNameReference(org.wso2.ballerinalang.compiler.tree.BLangNameReference) BLangService(org.wso2.ballerinalang.compiler.tree.BLangService) BLangIdentifier(org.wso2.ballerinalang.compiler.tree.BLangIdentifier)

Aggregations

BLangNameReference (org.wso2.ballerinalang.compiler.tree.BLangNameReference)11 BLangInvocation (org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation)3 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)3 BLangUserDefinedType (org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType)3 Whitespace (org.ballerinalang.model.Whitespace)2 IdentifierNode (org.ballerinalang.model.tree.IdentifierNode)2 SelectExpressionNode (org.ballerinalang.model.tree.clauses.SelectExpressionNode)2 ExpressionNode (org.ballerinalang.model.tree.expressions.ExpressionNode)2 ServiceNode (org.ballerinalang.model.tree.ServiceNode)1 BLangAnnotationAttachment (org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment)1 BLangAnnotationAttachmentPoint (org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachmentPoint)1 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)1 BLangIdentifier (org.wso2.ballerinalang.compiler.tree.BLangIdentifier)1 BLangService (org.wso2.ballerinalang.compiler.tree.BLangService)1 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)1 BLangTypeInit (org.wso2.ballerinalang.compiler.tree.expressions.BLangTypeInit)1 BLangBuiltInRefTypeNode (org.wso2.ballerinalang.compiler.tree.types.BLangBuiltInRefTypeNode)1 BLangConstrainedType (org.wso2.ballerinalang.compiler.tree.types.BLangConstrainedType)1