use of org.wso2.ballerinalang.compiler.tree.BLangService in project ballerina by ballerina-lang.
the class TreeVisitor method visit.
public void visit(BLangService serviceNode) {
if (!ScopeResolverConstants.getResolverByClass(cursorPositionResolver).isCursorBeforeNode(serviceNode.getPosition(), serviceNode, this, this.documentServiceContext)) {
BSymbol serviceSymbol = serviceNode.symbol;
SymbolEnv serviceEnv = SymbolEnv.createPkgLevelSymbolEnv(serviceNode, serviceSymbol.scope, symbolEnv);
// Reset the previous node
this.setPreviousNode(null);
if (!(serviceNode.resources.isEmpty() && serviceNode.vars.isEmpty() && serviceNode.endpoints.isEmpty())) {
// Visit the endpoints
serviceNode.endpoints.forEach(bLangEndpoint -> this.acceptNode(bLangEndpoint, serviceEnv));
// Since the service does not contains a block statement, we consider the block owner only.
// Here it is service
this.blockOwnerStack.push(serviceNode);
serviceNode.vars.forEach(v -> {
this.cursorPositionResolver = ServiceScopeResolver.class;
this.acceptNode(v, serviceEnv);
});
serviceNode.resources.forEach(r -> {
this.cursorPositionResolver = ServiceScopeResolver.class;
this.acceptNode(r, serviceEnv);
});
if (terminateVisitor) {
this.acceptNode(null, null);
}
this.blockOwnerStack.pop();
} else {
this.isCursorWithinBlock(serviceNode.getPosition(), serviceEnv);
}
}
}
use of org.wso2.ballerinalang.compiler.tree.BLangService 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.tree.BLangService in project ballerina by ballerina-lang.
the class SymbolEnter method defineServiceMembers.
private void defineServiceMembers(List<BLangService> services, SymbolEnv pkgEnv) {
services.forEach(service -> {
SymbolEnv serviceEnv = SymbolEnv.createServiceEnv(service, service.symbol.scope, pkgEnv);
service.vars.forEach(varDef -> defineNode(varDef.var, serviceEnv));
defineServiceInitFunction(service, serviceEnv);
service.resources.stream().peek(action -> action.flagSet.add(Flag.PUBLIC)).forEach(resource -> defineNode(resource, serviceEnv));
});
}
use of org.wso2.ballerinalang.compiler.tree.BLangService in project ballerina by ballerina-lang.
the class SymbolEnter method defineServiceInitFunction.
private void defineServiceInitFunction(BLangService service, SymbolEnv conEnv) {
BLangFunction initFunction = createInitFunction(service.pos, service.getName().getValue(), Names.INIT_FUNCTION_SUFFIX);
// Add service level variables to the init function
service.vars.stream().filter(f -> f.var.expr != null).forEachOrdered(v -> initFunction.body.addStatement(createAssignmentStmt(v.var)));
addInitReturnStatement(initFunction.body);
service.initFunction = initFunction;
defineNode(service.initFunction, conEnv);
// service.symbol.initFunctionSymbol = service.initFunction.symbol;
}
use of org.wso2.ballerinalang.compiler.tree.BLangService in project ballerina by ballerina-lang.
the class TaintAnalyzer method visit.
public void visit(BLangService serviceNode) {
BSymbol serviceSymbol = serviceNode.symbol;
SymbolEnv serviceEnv = SymbolEnv.createPkgLevelSymbolEnv(serviceNode, serviceSymbol.scope, env);
serviceNode.vars.forEach(var -> analyzeNode(var, serviceEnv));
analyzeNode(serviceNode.initFunction, serviceEnv);
serviceNode.resources.forEach(resource -> analyzeNode(resource, serviceEnv));
}
Aggregations