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));
}
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);
}
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);
}
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);
}
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();
}
Aggregations