| 62 | } |
| 63 | |
| 64 | void LanguageServer::SendRequest(std::string_view method, std::shared_ptr<lsp::Serializable> param) { |
| 65 | auto json = nlohmann::json::object(); |
| 66 | json["jsonrpc"] = "2.0"; |
| 67 | json["method"] = method; |
| 68 | json["id"] = GetRequestId(); |
| 69 | if (param) { |
| 70 | json["params"] = param->Serialize(); |
| 71 | } else { |
| 72 | json["params"] = nullptr; |
| 73 | } |
| 74 | if (_session) { |
| 75 | auto dumpResult = json.dump(); |
| 76 | std::string message = util::format("Content-Length:{}\r\n\r\n", dumpResult.size()); |
| 77 | |
| 78 | message.append(dumpResult); |
| 79 | _session->Send(std::move(message)); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | int LanguageServer::Run() { |
| 84 | if (_session) { |