use of org.wso2.ballerinalang.compiler.tree.types.BLangType in project ballerina by ballerina-lang.
the class ParserUtils method createNewParameter.
/**
* Create new parameter.
*
* @param name parameter name
* @param type parameter type
* @return {Parameter} parameter
*/
private static Parameter createNewParameter(String name, String type, BLangType typeNode) {
Parameter parameter = new Parameter();
parameter.setType(type);
parameter.setName(name);
BType bType = typeNode.type;
if (bType instanceof BConnectorType) {
parameter.setPkgAlias(((BLangUserDefinedType) typeNode).pkgAlias.toString());
parameter.setConnector(true);
}
return parameter;
}
use of org.wso2.ballerinalang.compiler.tree.types.BLangType in project ballerina by ballerina-lang.
the class SymbolResolver method visit.
@Override
public void visit(BLangFunctionTypeNode functionTypeNode) {
List<BType> paramTypes = new ArrayList<>();
List<BType> retParamTypes = new ArrayList<>();
functionTypeNode.getParamTypeNode().forEach(t -> paramTypes.add(resolveTypeNode((BLangType) t, env)));
functionTypeNode.getReturnParamTypeNode().forEach(t -> retParamTypes.add(resolveTypeNode((BLangType) t, env)));
resultType = new BInvokableType(paramTypes, retParamTypes, null);
}
use of org.wso2.ballerinalang.compiler.tree.types.BLangType in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addTupleType.
public void addTupleType(DiagnosticPos pos, Set<Whitespace> ws, int members) {
BLangTupleTypeNode tupleTypeNode = (BLangTupleTypeNode) TreeBuilder.createTupleTypeNode();
for (int i = 0; i < members; i++) {
final BLangType member = (BLangType) this.typeNodeStack.pop();
tupleTypeNode.memberTypeNodes.add(0, member);
}
tupleTypeNode.pos = pos;
tupleTypeNode.addWS(ws);
this.typeNodeStack.push(tupleTypeNode);
}
use of org.wso2.ballerinalang.compiler.tree.types.BLangType in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addCatchClause.
public void addCatchClause(DiagnosticPos poc, Set<Whitespace> ws, String paramName) {
BLangVariable variableNode = (BLangVariable) TreeBuilder.createVariableNode();
variableNode.typeNode = (BLangType) this.typeNodeStack.pop();
variableNode.name = (BLangIdentifier) createIdentifier(paramName);
variableNode.pos = variableNode.typeNode.pos;
variableNode.addWS(removeNthFromLast(ws, 3));
BLangCatch catchNode = (BLangCatch) TreeBuilder.createCatchNode();
catchNode.pos = poc;
catchNode.addWS(ws);
catchNode.body = (BLangBlockStmt) this.blockNodeStack.pop();
catchNode.param = variableNode;
tryCatchFinallyNodesStack.peek().catchBlocks.add(catchNode);
}
use of org.wso2.ballerinalang.compiler.tree.types.BLangType in project ballerina by ballerina-lang.
the class BLangPackageBuilder method createTypeCastExpr.
public void createTypeCastExpr(DiagnosticPos pos, Set<Whitespace> ws) {
BLangTypeCastExpr typeCastNode = (BLangTypeCastExpr) TreeBuilder.createTypeCastNode();
typeCastNode.pos = pos;
typeCastNode.addWS(ws);
typeCastNode.expr = (BLangExpression) exprNodeStack.pop();
typeCastNode.typeNode = (BLangType) typeNodeStack.pop();
addExpressionNode(typeCastNode);
}
Aggregations