1212std::mutex bpp::BashppServer::output_mutex;
1313std::mutex bpp::BashppServer::log_mutex;
1414
15+ const frozen::unordered_map<frozen::string, bpp::BashppServer::RequestHandler, 8 > bpp::BashppServer::request_handlers = {
16+ {frozen::string (" initialize" ), &BashppServer::handleInitialize},
17+ {frozen::string (" textDocument/definition" ), &BashppServer::handleDefinition},
18+ {frozen::string (" textDocument/completion" ), &BashppServer::handleCompletion},
19+ {frozen::string (" textDocument/hover" ), &BashppServer::handleHover},
20+ {frozen::string (" textDocument/documentSymbol" ), &BashppServer::handleDocumentSymbol},
21+ {frozen::string (" textDocument/rename" ), &BashppServer::handleRename},
22+ {frozen::string (" textDocument/references" ), &BashppServer::handleReferences},
23+ {frozen::string (" shutdown" ), &BashppServer::shutdown}
24+ };
25+
26+ const frozen::unordered_map<frozen::string, bpp::BashppServer::NotificationHandler, 4 > bpp::BashppServer::notification_handlers = {
27+ {" textDocument/didOpen" , &BashppServer::handleDidOpen},
28+ {" textDocument/didChange" , &BashppServer::handleDidChange},
29+ {" workspace/didChangeWatchedFiles" , &BashppServer::handleDidChangeWatchedFiles},
30+ {" textDocument/didClose" , &BashppServer::handleDidClose}
31+ };
32+
1533bpp::BashppServer::BashppServer () {
1634 log (" Bash++ Language Server initialized." );
1735 log (" Using " , thread_pool.getThreadCount (), " threads for processing requests." );
@@ -232,9 +250,9 @@ void bpp::BashppServer::processRequest(const GenericRequestMessage& request) {
232250 GenericResponseMessage response;
233251 response.id = request.id ;
234252 std::function<GenericResponseMessage (const GenericRequestMessage&)> request_handler = invalidRequestHandler;
235- auto it = request_handlers.find (request.method );
253+ auto it = request_handlers.find (frozen::string ( request.method . c_str ()) );
236254 if (it != request_handlers.end ()) {
237- request_handler = it->second ; // Set the handler to the appropriate function
255+ request_handler = std::bind ( it->second , this , std::placeholders::_1) ; // Bind the method to the current instance
238256 } else {
239257 log (" No handler found for request method: " , request.method );
240258 }
@@ -254,9 +272,9 @@ void bpp::BashppServer::processRequest(const GenericRequestMessage& request) {
254272
255273void bpp::BashppServer::processNotification (const GenericNotificationMessage& notification) {
256274 std::function<void (const GenericNotificationMessage&)> notification_handler = invalidNotificationHandler;
257- auto it = notification_handlers.find (notification.method );
275+ auto it = notification_handlers.find (frozen::string ( notification.method . c_str ()) );
258276 if (it != notification_handlers.end ()) {
259- notification_handler = it->second ; // Set the handler to the appropriate function
277+ notification_handler = std::bind ( it->second , this , std::placeholders::_1) ; // Bind the method to the current instance
260278 } else {
261279 log (" No handler found for notification method: " , notification.method );
262280 }
0 commit comments