nixd
Toggle main menu visibility
Loading...
Searching...
No Matches
nixd
include
nixd
Eval
AttrSetClient.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
nixd/Protocol/AttrSet.h
"
4
#include "
nixd/Support/StreamProc.h
"
5
6
#include <
lspserver/LSPServer.h
>
7
8
#include <thread>
9
10
namespace
nixd
{
11
12
class
AttrSetClient
:
public
lspserver::LSPServer
{
13
14
llvm::unique_function<void(
const
EvalExprParams
&Params,
15
lspserver::Callback<EvalExprResponse>
Reply)>
16
EvalExpr;
17
18
llvm::unique_function<void(
const
AttrPathInfoParams
&Params,
19
lspserver::Callback<AttrPathInfoResponse>
Reply)>
20
AttrPathInfo;
21
22
llvm::unique_function<void(
23
const
AttrPathCompleteParams
&Params,
24
lspserver::Callback<AttrPathCompleteResponse>
Reply)>
25
AttrPathComplete;
26
27
llvm::unique_function<void(
const
AttrPathInfoParams
&Params,
28
lspserver::Callback<OptionInfoResponse>
Reply)>
29
OptionInfo;
30
31
llvm::unique_function<void(
const
AttrPathCompleteParams
&Params,
32
lspserver::Callback<OptionCompleteResponse>
Reply)>
33
OptionComplete;
34
35
llvm::unique_function<void(std::nullptr_t)> Exit;
36
37
public
:
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,
44
lspserver::Callback<EvalExprResponse>
Reply) {
45
return
EvalExpr(Params, std::move(Reply));
46
}
47
48
void
attrpathInfo
(
const
AttrPathInfoParams
&Params,
49
lspserver::Callback<AttrPathInfoResponse>
Reply) {
50
AttrPathInfo(Params, std::move(Reply));
51
}
52
53
void
attrpathComplete
(
const
AttrPathCompleteParams
&Params,
54
lspserver::Callback<AttrPathCompleteResponse>
Reply) {
55
AttrPathComplete(Params, std::move(Reply));
56
}
57
58
void
optionInfo
(
const
AttrPathInfoParams
&Params,
59
lspserver::Callback<OptionInfoResponse>
Reply) {
60
OptionInfo(Params, std::move(Reply));
61
}
62
63
void
optionComplete
(
const
AttrPathCompleteParams
&Params,
64
lspserver::Callback<OptionCompleteResponse>
Reply) {
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
75
class
AttrSetClientProc
{
76
StreamProc
Proc;
77
AttrSetClient
Client;
78
std::thread Input;
79
80
public
:
81
/// \brief Check if the process is still alive
82
/// \returns nullptr if it has been dead.
83
AttrSetClient
*
client
();
84
~AttrSetClientProc
() {
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
AttrSet.h
Types used in nixpkgs provider.
LSPServer.h
StreamProc.h
lspserver::LSPServer
Definition
LSPServer.h:17
nixd::AttrSetClientProc::~AttrSetClientProc
~AttrSetClientProc()
Definition
AttrSetClient.h:84
nixd::AttrSetClientProc::client
AttrSetClient * client()
Check if the process is still alive.
Definition
AttrSetClient.cpp:36
nixd::AttrSetClientProc::AttrSetClientProc
AttrSetClientProc(const std::function< int()> &Action)
Definition
AttrSetClient.cpp:32
nixd::AttrSetClient
Definition
AttrSetClient.h:12
nixd::AttrSetClient::getExe
static const char * getExe()
Definition
AttrSetClient.cpp:26
nixd::AttrSetClient::optionInfo
void optionInfo(const AttrPathInfoParams &Params, lspserver::Callback< OptionInfoResponse > Reply)
Definition
AttrSetClient.h:58
nixd::AttrSetClient::AttrSetClient
AttrSetClient(std::unique_ptr< lspserver::InboundPort > In, std::unique_ptr< lspserver::OutboundPort > Out)
Definition
AttrSetClient.cpp:10
nixd::AttrSetClient::attrpathInfo
void attrpathInfo(const AttrPathInfoParams &Params, lspserver::Callback< AttrPathInfoResponse > Reply)
Definition
AttrSetClient.h:48
nixd::AttrSetClient::exit
void exit()
Definition
AttrSetClient.h:68
nixd::AttrSetClient::attrpathComplete
void attrpathComplete(const AttrPathCompleteParams &Params, lspserver::Callback< AttrPathCompleteResponse > Reply)
Definition
AttrSetClient.h:53
nixd::AttrSetClient::optionComplete
void optionComplete(const AttrPathCompleteParams &Params, lspserver::Callback< OptionCompleteResponse > Reply)
Definition
AttrSetClient.h:63
nixd::AttrSetClient::evalExpr
void evalExpr(const EvalExprParams &Params, lspserver::Callback< EvalExprResponse > Reply)
Request eval some expression. The expression should be evaluted to attrset.
Definition
AttrSetClient.h:43
lspserver::Callback
llvm::unique_function< void(llvm::Expected< T >)> Callback
Definition
Function.h:14
nixd
Definition
CommandLine/Configuration.h:9
nixd::EvalExprParams
std::string EvalExprParams
Definition
AttrSet.h:39
nixd::AttrPathInfoParams
Selector AttrPathInfoParams
Definition
AttrSet.h:48
nixd::AttrPathCompleteParams
Definition
AttrSet.h:107
nixd::StreamProc
Definition
StreamProc.h:10
Generated by
1.17.0