use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addEnumerator.
public void addEnumerator(DiagnosticPos pos, Set<Whitespace> ws, String name) {
BLangEnumerator enumerator = (BLangEnumerator) TreeBuilder.createEnumeratorNode();
enumerator.pos = pos;
enumerator.addWS(ws);
enumerator.name = (BLangIdentifier) createIdentifier(name);
enumeratorList.add(enumerator);
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangPackageBuilder method endTableQueryNode.
public void endTableQueryNode(boolean isJoinClauseAvailable, boolean isSelectClauseAvailable, boolean isOrderByClauseAvailable, DiagnosticPos pos, Set<Whitespace> ws) {
BLangTableQuery tableQuery = (BLangTableQuery) this.tableQueriesStack.peek();
tableQuery.pos = pos;
tableQuery.addWS(ws);
tableQuery.setStreamingInput(this.streamingInputStack.pop());
if (isJoinClauseAvailable) {
tableQuery.setJoinStreamingInput(this.joinStreamingInputsStack.pop());
}
if (isSelectClauseAvailable) {
tableQuery.setSelectClause(this.selectClausesStack.pop());
}
if (isOrderByClauseAvailable) {
tableQuery.setOrderByClause(this.orderByClauseStack.pop());
}
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangPackageBuilder method createXMLQuotedLiteral.
public void createXMLQuotedLiteral(DiagnosticPos pos, Set<Whitespace> ws, Stack<String> precedingTextFragments, String endingText, QuoteType quoteType) {
List<BLangExpression> templateExprs = getExpressionsInTemplate(pos, ws, precedingTextFragments, endingText, NodeKind.LITERAL);
BLangXMLQuotedString quotedString = (BLangXMLQuotedString) TreeBuilder.createXMLQuotedStringNode();
quotedString.pos = pos;
quotedString.quoteType = quoteType;
quotedString.textFragments = templateExprs;
addExpressionNode(quotedString);
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangPackageBuilder method endTypeDefinition.
public void endTypeDefinition(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean publicStruct) {
// TODO only adding object type for now
if (!this.objectStack.isEmpty()) {
BLangObject objectNode = (BLangObject) this.objectStack.pop();
objectNode.pos = pos;
objectNode.setName(this.createIdentifier(identifier));
if (publicStruct) {
objectNode.flagSet.add(Flag.PUBLIC);
}
objectNode.isAnonymous = false;
// Create an user defined type with object type
TypeNode objectType = createUserDefinedType(pos, ws, (BLangIdentifier) TreeBuilder.createIdentifierNode(), objectNode.name);
// Create and add receiver to attached functions
BLangVariable receiver = (BLangVariable) TreeBuilder.createVariableNode();
receiver.pos = pos;
IdentifierNode name = createIdentifier(Names.SELF.getValue());
receiver.setName(name);
receiver.addWS(ws);
receiver.docTag = DocTag.RECEIVER;
receiver.setTypeNode(objectType);
// Cache receiver to add to init function in symbolEnter
objectNode.receiver = receiver;
objectNode.functions.forEach(f -> f.setReceiver(receiver));
this.compUnit.addTopLevelNode(objectNode);
}
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addVariableDefStatement.
public void addVariableDefStatement(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean exprAvailable, boolean endpoint, boolean safeAssignment) {
BLangVariable var = (BLangVariable) TreeBuilder.createVariableNode();
BLangVariableDef varDefNode = (BLangVariableDef) TreeBuilder.createVariableDefinitionNode();
// TODO : Remove endpoint logic from here.
Set<Whitespace> wsOfSemiColon = null;
if (endpoint) {
var.addWS(endpointVarWs);
var.addWS(endpointKeywordWs);
endpointVarWs = null;
endpointKeywordWs = null;
} else {
wsOfSemiColon = removeNthFromLast(ws, 0);
}
var.pos = pos;
var.addWS(ws);
var.setName(this.createIdentifier(identifier));
var.setTypeNode(this.typeNodeStack.pop());
var.safeAssignment = safeAssignment;
if (exprAvailable) {
var.setInitialExpression(this.exprNodeStack.pop());
}
varDefNode.pos = pos;
varDefNode.setVariable(var);
varDefNode.addWS(wsOfSemiColon);
addStmtToCurrentBlock(varDefNode);
}
Aggregations