use of org.wso2.ballerinalang.compiler.semantics.analyzer.SymbolEnter 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);
}
}
Aggregations