Search in sources :

Example 16 with BLangUserDefinedType

use of org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType 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;
}
Also used : BLangValueType(org.wso2.ballerinalang.compiler.tree.types.BLangValueType) BLangBuiltInRefTypeNode(org.wso2.ballerinalang.compiler.tree.types.BLangBuiltInRefTypeNode) BLangBuiltInRefTypeNode(org.wso2.ballerinalang.compiler.tree.types.BLangBuiltInRefTypeNode) TypeNode(org.ballerinalang.model.tree.types.TypeNode) BLangUserDefinedType(org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType)

Aggregations

BLangUserDefinedType (org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType)12 TypeNode (org.ballerinalang.model.tree.types.TypeNode)4 BLangNameReference (org.wso2.ballerinalang.compiler.tree.BLangNameReference)4 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)4 IdentifierNode (org.ballerinalang.model.tree.IdentifierNode)3 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)3 BLangAnnotation (org.wso2.ballerinalang.compiler.tree.BLangAnnotation)3 BLangConnector (org.wso2.ballerinalang.compiler.tree.BLangConnector)3 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)3 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Documentable (org.ballerinalang.docgen.model.Documentable)2 Link (org.ballerinalang.docgen.model.Link)2 PackageName (org.ballerinalang.docgen.model.PackageName)2 Page (org.ballerinalang.docgen.model.Page)2 Flag (org.ballerinalang.model.elements.Flag)2 EnumNode (org.ballerinalang.model.tree.EnumNode)2 NodeKind (org.ballerinalang.model.tree.NodeKind)2 BStructType (org.wso2.ballerinalang.compiler.semantics.model.types.BStructType)2