use of org.ballerinalang.model.Whitespace 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.ballerinalang.model.Whitespace in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addTimeoutCause.
public void addTimeoutCause(Set<Whitespace> ws, String identifier) {
BLangForkJoin forkJoin = (BLangForkJoin) this.forkJoinNodesStack.peek();
forkJoin.timeoutBody = (BLangBlockStmt) this.blockNodeStack.pop();
forkJoin.timeoutExpression = (BLangExpression) this.exprNodeStack.pop();
Set<Whitespace> varWS = removeNthFromLast(ws, 3);
forkJoin.addWS(ws);
forkJoin.timeoutVariable = (BLangVariable) this.generateBasicVarNode((DiagnosticPos) this.typeNodeStack.peek().getPosition(), varWS, identifier, false);
}
use of org.ballerinalang.model.Whitespace in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addMatchStmtPattern.
public void addMatchStmtPattern(DiagnosticPos pos, Set<Whitespace> ws, String identifier) {
BLangMatchStmtPatternClause patternClause = (BLangMatchStmtPatternClause) TreeBuilder.createMatchStatementPattern();
patternClause.pos = pos;
Set<Whitespace> varDefWS = removeNthFromStart(ws, 0);
patternClause.addWS(ws);
// Create a variable node
identifier = identifier == null ? Names.IGNORE.value : identifier;
BLangVariable var = (BLangVariable) TreeBuilder.createVariableNode();
var.pos = pos;
var.setName(this.createIdentifier(identifier));
var.setTypeNode(this.typeNodeStack.pop());
var.addWS(varDefWS);
patternClause.variable = var;
patternClause.body = (BLangBlockStmt) blockNodeStack.pop();
patternClause.body.pos = pos;
this.matchStmtStack.peekFirst().patternClauses.add(patternClause);
}
use of org.ballerinalang.model.Whitespace in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addElseIfBlock.
public void addElseIfBlock(DiagnosticPos pos, Set<Whitespace> ws) {
IfNode elseIfNode = ifElseStatementStack.pop();
((BLangIf) elseIfNode).pos = pos;
elseIfNode.setCondition(exprNodeStack.pop());
elseIfNode.setBody(blockNodeStack.pop());
Set<Whitespace> elseWS = removeNthFromStart(ws, 0);
elseIfNode.addWS(ws);
IfNode parentIfNode = ifElseStatementStack.peek();
while (parentIfNode.getElseStatement() != null) {
parentIfNode = (IfNode) parentIfNode.getElseStatement();
}
parentIfNode.addWS(elseWS);
parentIfNode.setElseStatement(elseIfNode);
}
use of org.ballerinalang.model.Whitespace in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addVarToStruct.
public void addVarToStruct(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean exprAvailable, int annotCount, boolean isPrivate) {
Set<Whitespace> wsForSemiColon = removeNthFromLast(ws, 0);
BLangStruct structNode = (BLangStruct) this.structStack.peek();
structNode.addWS(wsForSemiColon);
BLangVariable field = addVar(pos, ws, identifier, exprAvailable, annotCount);
if (!isPrivate) {
field.flagSet.add(Flag.PUBLIC);
}
}
Aggregations