use of org.wso2.ballerinalang.compiler.tree.types.BLangBuiltInRefTypeNode 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.types.BLangBuiltInRefTypeNode in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addConstraintTypeWithTypeName.
public void addConstraintTypeWithTypeName(DiagnosticPos pos, Set<Whitespace> ws, String typeName) {
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 = (BLangType) this.typeNodeStack.pop();
constrainedType.pos = pos;
constrainedType.addWS(ws);
addType(constrainedType);
}
use of org.wso2.ballerinalang.compiler.tree.types.BLangBuiltInRefTypeNode in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addBuiltInReferenceType.
public void addBuiltInReferenceType(DiagnosticPos pos, Set<Whitespace> ws, String typeName) {
BLangBuiltInRefTypeNode refType = (BLangBuiltInRefTypeNode) TreeBuilder.createBuiltInReferenceTypeNode();
refType.typeKind = TreeUtils.stringToTypeKind(typeName);
refType.pos = pos;
refType.addWS(ws);
addType(refType);
}
use of org.wso2.ballerinalang.compiler.tree.types.BLangBuiltInRefTypeNode in project ballerina by ballerina-lang.
the class ParserUtils method getReceiverType.
/**
* Extract receiverType from the function receiver.
*
* @param receiver receiver
* @return receiverType
*/
private static String getReceiverType(VariableNode receiver) {
if (receiver == null) {
return null;
}
TypeNode typeNode = receiver.getTypeNode();
String receiverType = null;
if (typeNode instanceof BLangUserDefinedType) {
receiverType = ((BLangUserDefinedType) typeNode).getTypeName().getValue();
} else if (typeNode instanceof BLangBuiltInRefTypeNode) {
receiverType = ((BLangBuiltInRefTypeNode) typeNode).getTypeKind().typeName();
} else if (typeNode instanceof BLangValueType) {
receiverType = ((BLangValueType) typeNode).getTypeKind().typeName();
} else {
return null;
}
return receiverType;
}
Aggregations