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