7#include <llvm/ADT/StringRef.h>
8#include <llvm/Support/Error.h>
9#include <llvm/Support/JSON.h>
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 &)>
67 template <
class ParamTy,
class ResponseTy>
76 llvm::Expected<llvm::json::Value>
Response)
mutable {
87 LSPServer(std::unique_ptr<InboundPort> In, std::unique_ptr<OutboundPort> Out)
88 : In(std::
move(In)), Out(std::
move(Out)){};
LSPServer(std::unique_ptr< InboundPort > In, std::unique_ptr< OutboundPort > Out)
llvm::unique_function< void(const ParamTy &, Callback< ResponseTy >) mkOutMethod)(llvm::StringRef Method, OutboundPort *O=nullptr)
void closeInbound()
Close the inbound port.
void switchStreamStyle(JSONStreamStyle Style)
llvm::unique_function< void(const T &) mkOutNotifiction)(llvm::StringRef Method, OutboundPort *O=nullptr)
void notify(llvm::StringRef Method, llvm::json::Value Params)
void call(llvm::StringRef Method, llvm::json::Value Params, llvm::json::Value ID)
Whether current platform treats paths case insensitively.
llvm::unique_function< void(llvm::Expected< T >)> Callback
bool fromJSON(const llvm::json::Value &, URIForFile &, llvm::json::Path)
void log(const char *Fmt, Ts &&...Vals)