nixd
Loading...
Searching...
No Matches
AttrSetClient.h
Go to the documentation of this file.
1#pragma once
2
5
7
8#include <thread>
9
10namespace nixd {
11
13
14 llvm::unique_function<void(const EvalExprParams &Params,
16 EvalExpr;
17
18 llvm::unique_function<void(const AttrPathInfoParams &Params,
20 AttrPathInfo;
21
22 llvm::unique_function<void(
23 const AttrPathCompleteParams &Params,
25 AttrPathComplete;
26
27 llvm::unique_function<void(const AttrPathInfoParams &Params,
29 OptionInfo;
30
31 llvm::unique_function<void(const AttrPathCompleteParams &Params,
33 OptionComplete;
34
35 llvm::unique_function<void(std::nullptr_t)> Exit;
36
37public:
38 AttrSetClient(std::unique_ptr<lspserver::InboundPort> In,
39 std::unique_ptr<lspserver::OutboundPort> Out);
40
41 /// \brief Request eval some expression.
42 /// The expression should be evaluted to attrset.
43 void evalExpr(const EvalExprParams &Params,
45 return EvalExpr(Params, std::move(Reply));
46 }
47
48 void attrpathInfo(const AttrPathInfoParams &Params,
50 AttrPathInfo(Params, std::move(Reply));
51 }
52
55 AttrPathComplete(Params, std::move(Reply));
56 }
57
58 void optionInfo(const AttrPathInfoParams &Params,
60 OptionInfo(Params, std::move(Reply));
61 }
62
65 OptionComplete(Params, std::move(Reply));
66 }
67
68 void exit() { Exit(nullptr); }
69
70 /// Get executable path for launching the server.
71 /// \returns null terminated string.
72 static const char *getExe();
73};
74
76 StreamProc Proc;
77 AttrSetClient Client;
78 std::thread Input;
79
80public:
81 /// \brief Check if the process is still alive
82 /// \returns nullptr if it has been dead.
85 Client.exit();
86 Client.closeInbound();
87 Input.join();
88 }
89
90 /// \see StreamProc::StreamProc
91 AttrSetClientProc(const std::function<int()> &Action);
92};
93
94} // namespace nixd
Types used in nixpkgs provider.
void closeInbound()
Close the inbound port.
Definition LSPServer.h:91
AttrSetClient * client()
Check if the process is still alive.
AttrSetClientProc(const std::function< int()> &Action)
static const char * getExe()
void optionInfo(const AttrPathInfoParams &Params, lspserver::Callback< OptionInfoResponse > Reply)
AttrSetClient(std::unique_ptr< lspserver::InboundPort > In, std::unique_ptr< lspserver::OutboundPort > Out)
void attrpathInfo(const AttrPathInfoParams &Params, lspserver::Callback< AttrPathInfoResponse > Reply)
void attrpathComplete(const AttrPathCompleteParams &Params, lspserver::Callback< AttrPathCompleteResponse > Reply)
void optionComplete(const AttrPathCompleteParams &Params, lspserver::Callback< OptionCompleteResponse > Reply)
void evalExpr(const EvalExprParams &Params, lspserver::Callback< EvalExprResponse > Reply)
Request eval some expression. The expression should be evaluted to attrset.
llvm::unique_function< void(llvm::Expected< T >)> Callback
Definition Function.h:14
std::string EvalExprParams
Definition AttrSet.h:38
Selector AttrPathInfoParams
Definition AttrSet.h:47