use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangPackageBuilder method createFunctionInvocation.
public void createFunctionInvocation(DiagnosticPos pos, Set<Whitespace> ws, boolean argsAvailable) {
BLangInvocation invocationNode = (BLangInvocation) TreeBuilder.createInvocationNode();
invocationNode.pos = pos;
invocationNode.addWS(ws);
if (argsAvailable) {
List<ExpressionNode> exprNodes = exprNodeListStack.pop();
exprNodes.forEach(exprNode -> invocationNode.argExprs.add((BLangExpression) exprNode));
invocationNode.addWS(commaWsStack.pop());
}
BLangNameReference nameReference = nameReferenceStack.pop();
invocationNode.name = (BLangIdentifier) nameReference.name;
invocationNode.addWS(nameReference.ws);
invocationNode.pkgAlias = (BLangIdentifier) nameReference.pkgAlias;
addExpressionNode(invocationNode);
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addWhileStmt.
public void addWhileStmt(DiagnosticPos pos, Set<Whitespace> ws) {
BLangWhile whileNode = (BLangWhile) TreeBuilder.createWhileNode();
whileNode.setCondition(exprNodeStack.pop());
whileNode.pos = pos;
whileNode.addWS(ws);
BLangBlockStmt whileBlock = (BLangBlockStmt) this.blockNodeStack.pop();
whileBlock.pos = pos;
whileNode.setBody(whileBlock);
addStmtToCurrentBlock(whileNode);
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangPackageBuilder method startServiceDef.
public void startServiceDef(DiagnosticPos pos) {
BLangService serviceNode = (BLangService) TreeBuilder.createServiceNode();
serviceNode.pos = pos;
attachAnnotations(serviceNode);
attachDocumentations(serviceNode);
attachDeprecatedNode(serviceNode);
serviceNodeStack.push(serviceNode);
startEndpointDeclarationScope(serviceNode.endpoints);
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangPackageBuilder method createXMLPILiteral.
public void createXMLPILiteral(DiagnosticPos pos, Set<Whitespace> ws, String targetQName, Stack<String> precedingTextFragments, String endingText) {
List<BLangExpression> dataExprs = getExpressionsInTemplate(pos, ws, precedingTextFragments, endingText, NodeKind.LITERAL);
addLiteralValue(pos, ws, TypeTags.STRING, targetQName);
BLangXMLProcInsLiteral xmlProcInsLiteral = (BLangXMLProcInsLiteral) TreeBuilder.createXMLProcessingIntsructionLiteralNode();
xmlProcInsLiteral.pos = pos;
xmlProcInsLiteral.dataFragments = dataExprs;
xmlProcInsLiteral.target = (BLangLiteral) exprNodeStack.pop();
;
addExpressionNode(xmlProcInsLiteral);
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangPackageBuilder method getExpressionsInTemplate.
// Private methods
private List<BLangExpression> getExpressionsInTemplate(DiagnosticPos pos, Set<Whitespace> ws, Stack<String> precedingTextFragments, String endingText, NodeKind targetStrExprKind) {
List<BLangExpression> expressions = new ArrayList<>();
endingText = endingText == null ? "" : StringEscapeUtils.unescapeJava(endingText);
addLiteralValue(pos, ws, TypeTags.STRING, endingText);
expressions.add((BLangExpression) exprNodeStack.pop());
while (!precedingTextFragments.empty()) {
expressions.add((BLangExpression) exprNodeStack.pop());
String textFragment = precedingTextFragments.pop();
textFragment = textFragment == null ? "" : StringEscapeUtils.unescapeJava(textFragment);
addLiteralValue(pos, ws, TypeTags.STRING, textFragment);
expressions.add((BLangExpression) exprNodeStack.pop());
}
Collections.reverse(expressions);
return expressions;
}
Aggregations