use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BServiceSymbol in project ballerina by ballerina-lang.
the class SemanticAnalyzer method handleServiceEndpointBinds.
private void handleServiceEndpointBinds(BLangService serviceNode, BServiceSymbol serviceSymbol) {
for (BLangSimpleVarRef ep : serviceNode.boundEndpoints) {
typeChecker.checkExpr(ep, env);
if (ep.symbol == null || (ep.symbol.tag & SymTag.ENDPOINT) != SymTag.ENDPOINT) {
dlog.error(ep.pos, DiagnosticCode.ENDPOINT_INVALID_TYPE, ep.variableName);
continue;
}
final BEndpointVarSymbol epSym = (BEndpointVarSymbol) ep.symbol;
if ((epSym.tag & SymTag.ENDPOINT) == SymTag.ENDPOINT) {
if (epSym.registrable) {
serviceSymbol.boundEndpoints.add(epSym);
if (serviceNode.endpointType == null) {
serviceNode.endpointType = (BStructType) epSym.type;
serviceNode.endpointClientType = endpointSPIAnalyzer.getClientType((BStructSymbol) serviceNode.endpointType.tsymbol);
}
// TODO : Validate serviceType endpoint type with bind endpoint types.
} else {
dlog.error(ep.pos, DiagnosticCode.ENDPOINT_NOT_SUPPORT_REGISTRATION, epSym);
}
} else {
dlog.error(ep.pos, DiagnosticCode.ENDPOINT_INVALID_TYPE, epSym);
}
}
if (serviceNode.endpointType == null) {
dlog.error(serviceNode.pos, DiagnosticCode.SERVICE_INVALID_ENDPOINT_TYPE, serviceNode.name);
}
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BServiceSymbol in project ballerina by ballerina-lang.
the class EndpointDesugar method rewriteService.
private void rewriteService(BLangService service, SymbolEnv pkgEnv) {
final BServiceSymbol serviceSymbol = (BServiceSymbol) service.symbol;
if (serviceSymbol.boundEndpoints.isEmpty()) {
return;
}
final BSymbol enclosingSymbol = pkgEnv.enclPkg.symbol;
final BSymbol varSymbol = pkgEnv.enclPkg.startFunction.symbol;
final BLangBlockStmt startBlock = pkgEnv.enclPkg.startFunction.body;
serviceSymbol.boundEndpoints.forEach(endpointVarSymbol -> {
final BLangBlockStmt generateCode = generateServiceRegistered(endpointVarSymbol, service, pkgEnv, enclosingSymbol, varSymbol);
ASTBuilderUtil.prependStatements(generateCode, startBlock);
});
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BServiceSymbol in project ballerina by ballerina-lang.
the class SymbolEnter method visit.
@Override
public void visit(BLangService serviceNode) {
BServiceSymbol serviceSymbol = Symbols.createServiceSymbol(Flags.asMask(serviceNode.flagSet), names.fromIdNode(serviceNode.name), env.enclPkg.symbol.pkgID, serviceNode.type, env.scope.owner);
serviceNode.symbol = serviceSymbol;
serviceNode.symbol.type = new BServiceType(serviceSymbol);
defineSymbol(serviceNode.pos, serviceSymbol);
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BServiceSymbol in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangService serviceNode) {
BServiceSymbol serviceSymbol = (BServiceSymbol) serviceNode.symbol;
SymbolEnv serviceEnv = SymbolEnv.createServiceEnv(serviceNode, serviceSymbol.scope, env);
handleServiceTypeStruct(serviceNode);
handleServiceEndpointBinds(serviceNode, serviceSymbol);
serviceNode.annAttachments.forEach(a -> {
a.attachmentPoint = new BLangAnnotationAttachmentPoint(BLangAnnotationAttachmentPoint.AttachmentPoint.SERVICE);
this.analyzeDef(a, serviceEnv);
});
serviceNode.docAttachments.forEach(doc -> analyzeDef(doc, serviceEnv));
serviceNode.vars.forEach(v -> this.analyzeDef(v, serviceEnv));
serviceNode.endpoints.forEach(e -> {
symbolEnter.defineNode(e, serviceEnv);
analyzeDef(e, serviceEnv);
});
this.analyzeDef(serviceNode.initFunction, serviceEnv);
serviceNode.resources.forEach(r -> this.analyzeDef(r, serviceEnv));
}
Aggregations