Search in sources :

Example 1 with BLangValueType

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

the class BLangPackageBuilder method addValueType.

public void addValueType(DiagnosticPos pos, Set<Whitespace> ws, String typeName) {
    BLangValueType typeNode = (BLangValueType) TreeBuilder.createValueTypeNode();
    typeNode.addWS(ws);
    typeNode.pos = pos;
    typeNode.typeKind = (TreeUtils.stringToTypeKind(typeName));
    addType(typeNode);
}
Also used : BLangValueType(org.wso2.ballerinalang.compiler.tree.types.BLangValueType)

Example 2 with BLangValueType

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

the class ParameterContextHolder method buildContext.

/**
 * Build a readable parameter model from a Ballerina <code>VariableNode</code>.
 *
 * @param parameter {@code VariableNode} with parameter definition
 * @return built Parameter context model
 */
public static ParameterContextHolder buildContext(VariableNode parameter) {
    ParameterContextHolder context = new ParameterContextHolder();
    TypeNode type = parameter.getTypeNode();
    if (type instanceof BLangValueType) {
        context.type = ((BLangValueType) parameter.getTypeNode()).getTypeKind().typeName();
    } else if (type instanceof BLangUserDefinedType) {
        context.type = ((BLangUserDefinedType) parameter.getTypeNode()).getTypeName().getValue();
    }
    // Ignore Connection and InRequest parameters
    if (context.isIgnoredType(context.type)) {
        return null;
    }
    context.name = parameter.getName().toString();
    context.defaultValue = context.getDefaultValue(context.type, context.name);
    // examples are not yet supported
    context.example = "";
    return context;
}
Also used : BLangValueType(org.wso2.ballerinalang.compiler.tree.types.BLangValueType) TypeNode(org.ballerinalang.model.tree.types.TypeNode) BLangUserDefinedType(org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType)

Example 3 with BLangValueType

use of org.wso2.ballerinalang.compiler.tree.types.BLangValueType 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

BLangValueType (org.wso2.ballerinalang.compiler.tree.types.BLangValueType)3 TypeNode (org.ballerinalang.model.tree.types.TypeNode)2 BLangUserDefinedType (org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType)2 BLangBuiltInRefTypeNode (org.wso2.ballerinalang.compiler.tree.types.BLangBuiltInRefTypeNode)1