19 std::unique_ptr<InboundPort> In;
20 std::unique_ptr<OutboundPort> Out;
22 bool onNotify(llvm::StringRef
Method, llvm::json::Value)
override;
23 bool onCall(llvm::StringRef
Method, llvm::json::Value Params,
24 llvm::json::Value ID)
override;
25 bool onReply(llvm::json::Value ID,
26 llvm::Expected<llvm::json::Value> Result)
override;
28 std::mutex PendingCallsLock;
35 std::map<int, Callback<llvm::json::Value>> PendingCalls;
40 static constexpr int MaxPendingCalls = 100;
47 void callMethod(llvm::StringRef
Method, llvm::json::Value Params,
49 llvm::json::Value ID(bindReply(std::move(CB)));
50 log(
"--> call {0}({1})",
Method, ID.getAsInteger());
57 llvm::unique_function<void(
const T &)>
61 return [=](
const T &Params) {
67 template <
class ParamTy,
class ResponseTy>
75 [=, Reply = std::move(Reply)](
76 llvm::Expected<llvm::json::Value> Response)
mutable {
78 return Reply(Response.takeError());
87 LSPServer(std::unique_ptr<InboundPort> In, std::unique_ptr<OutboundPort> Out)
88 : In(std::move(In)), Out(std::move(Out)) {};