|
17 | 17 | #include <nlohmann/json.hpp> |
18 | 18 | #include <unistd.h> |
19 | 19 |
|
20 | | -#include <frozen/string.h> |
21 | | -#include <frozen/unordered_map.h> |
22 | | - |
23 | 20 | #include "ThreadPool.h" |
24 | 21 | #include "ProgramPool.h" |
25 | 22 |
|
@@ -276,33 +273,42 @@ class BashppServer { |
276 | 273 | using RequestHandler = GenericResponseMessage (BashppServer::*)(const GenericRequestMessage&); |
277 | 274 | using NotificationHandler = void (BashppServer::*)(const GenericNotificationMessage&); |
278 | 275 |
|
| 276 | + struct RequestHandlerEntry { |
| 277 | + std::string_view method_name; |
| 278 | + RequestHandler handler; |
| 279 | + }; |
| 280 | + struct NotificationHandlerEntry { |
| 281 | + std::string_view method_name; |
| 282 | + NotificationHandler handler; |
| 283 | + }; |
| 284 | + |
279 | 285 | /** |
280 | 286 | * @brief Maps request types to the functions that handle them. |
281 | 287 | * |
282 | 288 | */ |
283 | | - static constexpr frozen::unordered_map<frozen::string, RequestHandler, 8> request_handlers = { |
284 | | - {"initialize", &BashppServer::handleInitialize}, |
285 | | - {"textDocument/definition", &BashppServer::handleDefinition}, |
286 | | - {"textDocument/completion", &BashppServer::handleCompletion}, |
287 | | - {"textDocument/hover", &BashppServer::handleHover}, |
| 289 | + static constexpr std::array<RequestHandlerEntry, 8> request_handlers = {{ |
| 290 | + {"initialize", &BashppServer::handleInitialize}, |
| 291 | + {"textDocument/definition", &BashppServer::handleDefinition}, |
| 292 | + {"textDocument/completion", &BashppServer::handleCompletion}, |
| 293 | + {"textDocument/hover", &BashppServer::handleHover}, |
288 | 294 | {"textDocument/documentSymbol", &BashppServer::handleDocumentSymbol}, |
289 | | - {"textDocument/rename", &BashppServer::handleRename}, |
290 | | - {"textDocument/references", &BashppServer::handleReferences}, |
291 | | - {"shutdown", &BashppServer::shutdown} |
292 | | - }; |
| 295 | + {"textDocument/rename", &BashppServer::handleRename}, |
| 296 | + {"textDocument/references", &BashppServer::handleReferences}, |
| 297 | + {"shutdown", &BashppServer::shutdown} |
| 298 | + }}; |
293 | 299 |
|
294 | 300 | /** |
295 | 301 | * @brief Maps notification types to the functions that handle them. |
296 | 302 | * |
297 | 303 | */ |
298 | | - static constexpr frozen::unordered_map<frozen::string, NotificationHandler, 6> notification_handlers = { |
299 | | - {"textDocument/didOpen", &BashppServer::handleDidOpen}, |
300 | | - {"textDocument/didChange", &BashppServer::handleDidChange}, |
| 304 | + static constexpr std::array<NotificationHandlerEntry, 6> notification_handlers = {{ |
| 305 | + {"textDocument/didOpen", &BashppServer::handleDidOpen}, |
| 306 | + {"textDocument/didChange", &BashppServer::handleDidChange}, |
301 | 307 | {"workspace/didChangeWatchedFiles", &BashppServer::handleDidChangeWatchedFiles}, |
302 | | - {"textDocument/didSave", &BashppServer::handleDidSave}, |
303 | | - {"textDocument/didClose", &BashppServer::handleDidClose}, |
304 | | - {"exit", &BashppServer::exit} |
305 | | - }; |
| 308 | + {"textDocument/didSave", &BashppServer::handleDidSave}, |
| 309 | + {"textDocument/didClose", &BashppServer::handleDidClose}, |
| 310 | + {"exit", &BashppServer::exit} |
| 311 | + }}; |
306 | 312 | }; |
307 | 313 |
|
308 | 314 | } // namespace bpp |
0 commit comments