use of org.ballerinalang.model.tree.IdentifierNode in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addEndpointVariable.
public void addEndpointVariable(DiagnosticPos pos, Set<Whitespace> ws, String endpointName) {
BLangVariable var = (BLangVariable) TreeBuilder.createVariableNode();
var.pos = pos;
// endpointName has to be redefine at semantic analyze phase. So appending $ to make it work.
IdentifierNode name = this.createIdentifier("$" + endpointName);
var.setName(name);
var.addWS(ws);
// Type will be calculated at SymEnter phase.
if (varListStack.empty()) {
varListStack.push(new ArrayList<>());
}
varListStack.peek().add(0, var);
}
use of org.ballerinalang.model.tree.IdentifierNode in project ballerina by ballerina-lang.
the class BLangPackageBuilder method generateObjectVarNode.
private VariableNode generateObjectVarNode(DiagnosticPos pos, Set<Whitespace> ws, boolean isField, String identifier, boolean exprAvailable) {
BLangVariable var = (BLangVariable) TreeBuilder.createVariableNode();
var.pos = pos;
IdentifierNode name = this.createIdentifier(identifier);
var.setName(name);
var.addWS(ws);
var.isField = isField;
if (!isField) {
var.setTypeNode(this.typeNodeStack.pop());
}
if (exprAvailable) {
var.setInitialExpression(this.exprNodeStack.pop());
}
return var;
}
use of org.ballerinalang.model.tree.IdentifierNode in project ballerina by ballerina-lang.
the class BLangPackageBuilder method createIdentifier.
private IdentifierNode createIdentifier(String value) {
IdentifierNode node = TreeBuilder.createIdentifierNode();
if (value == null) {
return node;
}
if (value.startsWith(IDENTIFIER_LITERAL_PREFIX) && value.endsWith(IDENTIFIER_LITERAL_SUFFIX)) {
node.setValue(value.substring(2, value.length() - 1));
node.setLiteral(true);
} else {
node.setValue(value);
node.setLiteral(false);
}
return node;
}
use of org.ballerinalang.model.tree.IdentifierNode in project ballerina by ballerina-lang.
the class ASTBuilderUtil method createFunction.
static BLangFunction createFunction(DiagnosticPos pos, String name) {
final BLangFunction bLangFunction = (BLangFunction) TreeBuilder.createFunctionNode();
final IdentifierNode funcName = createIdentifier(pos, name);
bLangFunction.setName(funcName);
bLangFunction.flagSet = EnumSet.of(Flag.LAMBDA);
bLangFunction.pos = pos;
// Create body of the function
bLangFunction.body = createBlockStmt(pos);
return bLangFunction;
}
use of org.ballerinalang.model.tree.IdentifierNode in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addAnonObjectType.
public void addAnonObjectType(DiagnosticPos pos, Set<Whitespace> ws) {
// Generate a name for the anonymous struct
String genName = anonymousModelHelper.getNextAnonymousStructKey(pos.src.pkgID);
IdentifierNode anonStructGenName = createIdentifier(genName);
// Create an anonymous struct and add it to the list of structs in the current package.
BLangStruct structNode = populateStructNode(pos, ws, anonStructGenName, true);
this.compUnit.addTopLevelNode(structNode);
addType(createUserDefinedType(pos, ws, (BLangIdentifier) TreeBuilder.createIdentifierNode(), structNode.name));
}
Aggregations