use of org.ballerinalang.model.tree.InvokableNode in project ballerina by ballerina-lang.
the class BLangPackageBuilder method endCallableUnitBody.
public void endCallableUnitBody(Set<Whitespace> ws) {
BlockNode block = this.blockNodeStack.pop();
InvokableNode invokableNode = this.invokableNodeStack.peek();
invokableNode.addWS(ws);
invokableNode.setBody(block);
}
use of org.ballerinalang.model.tree.InvokableNode in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addWorker.
public void addWorker(DiagnosticPos pos, Set<Whitespace> ws, String workerName) {
BLangWorker worker = (BLangWorker) this.invokableNodeStack.pop();
worker.setName(createIdentifier(workerName));
worker.pos = pos;
worker.addWS(ws);
worker.setBody(this.blockNodeStack.pop());
if (this.forkJoinNodesStack.empty()) {
InvokableNode invokableNode = this.invokableNodeStack.peek();
invokableNode.getParameters().forEach(worker::addParameter);
invokableNode.getReturnParameters().forEach(worker::addReturnParameter);
invokableNode.addWorker(worker);
invokableNode.addFlag(Flag.PARALLEL);
} else {
((BLangForkJoin) this.forkJoinNodesStack.peek()).workers.add(worker);
}
}
use of org.ballerinalang.model.tree.InvokableNode in project ballerina by ballerina-lang.
the class BLangPackageBuilder method endObjectInitParamList.
void endObjectInitParamList(Set<Whitespace> ws, boolean paramsAvail, boolean restParamAvail) {
InvokableNode invNode = this.invokableNodeStack.peek();
invNode.addWS(ws);
if (paramsAvail) {
this.varListStack.pop().forEach(variableNode -> {
((BLangVariable) variableNode).docTag = DocTag.PARAM;
invNode.addParameter(variableNode);
});
this.defaultableParamsList.forEach(variableDef -> {
BLangVariableDef varDef = (BLangVariableDef) variableDef;
varDef.var.docTag = DocTag.PARAM;
invNode.addDefaultableParameter(varDef);
});
this.defaultableParamsList = new ArrayList<>();
if (restParamAvail) {
invNode.setRestParameter(this.restParamStack.pop());
}
}
}
use of org.ballerinalang.model.tree.InvokableNode in project ballerina by ballerina-lang.
the class BLangPackageBuilder method endCallableUnitSignature.
public void endCallableUnitSignature(Set<Whitespace> ws, String identifier, boolean paramsAvail, boolean retParamsAvail, boolean restParamAvail) {
InvokableNode invNode = this.invokableNodeStack.peek();
invNode.setName(this.createIdentifier(identifier));
invNode.addWS(ws);
if (retParamsAvail) {
BLangVariable variableNode = (BLangVariable) this.varStack.pop();
variableNode.docTag = DocTag.RETURN;
invNode.addReturnParameter(variableNode);
}
if (paramsAvail) {
this.varListStack.pop().forEach(variableNode -> {
((BLangVariable) variableNode).docTag = DocTag.PARAM;
invNode.addParameter(variableNode);
});
this.defaultableParamsList.forEach(variableDef -> {
BLangVariableDef varDef = (BLangVariableDef) variableDef;
varDef.var.docTag = DocTag.PARAM;
invNode.addDefaultableParameter(varDef);
});
this.defaultableParamsList = new ArrayList<>();
if (restParamAvail) {
invNode.setRestParameter(this.restParamStack.pop());
}
}
}
Aggregations