use of org.wso2.carbon.apimgt.api.model.Identifier in project ballerina by ballerina-lang.
the class SiddhiQueryBuilder method visit.
@Override
public void visit(BLangSelectExpression selectExpression) {
BLangExpression expr = (BLangExpression) selectExpression.getExpression();
selectExpr = new StringBuilder();
addVarRefToClauseBuilder(expr, selectExpr);
String identifier = selectExpression.getIdentifier();
if (identifier != null) {
selectExpr.append(" as ").append(identifier);
}
}
use of org.wso2.carbon.apimgt.api.model.Identifier in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addConstVariable.
public void addConstVariable(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean publicVar, boolean safeAssignment) {
BLangVariable var = (BLangVariable) this.generateBasicVarNode(pos, ws, identifier, true);
var.flagSet.add(Flag.CONST);
if (publicVar) {
var.flagSet.add(Flag.PUBLIC);
}
var.docTag = DocTag.VARIABLE;
var.safeAssignment = safeAssignment;
attachAnnotations(var);
attachDocumentations(var);
attachDeprecatedNode(var);
this.compUnit.addTopLevelNode(var);
}
use of org.wso2.carbon.apimgt.api.model.Identifier in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addReturnParam.
public BLangVariable addReturnParam(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean exprAvailable, int annotCount) {
BLangVariable var = (BLangVariable) this.generateBasicVarNode(pos, ws, identifier, exprAvailable);
attachAnnotations(var, annotCount);
var.pos = pos;
this.varStack.push(var);
return var;
}
use of org.wso2.carbon.apimgt.api.model.Identifier 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.carbon.apimgt.api.model.Identifier 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