nixd
Loading...
Searching...
No Matches
AttrSet.cpp
Go to the documentation of this file.
2
3using namespace nixd;
4using namespace llvm::json;
5
7 return Object{
8 {"Description", Params.Description},
9 {"Name", Params.Name},
10 };
11}
12
13bool nixd::fromJSON(const Value &Params, OptionType &R, Path P) {
14 ObjectMapper O(Params, P);
15 return O //
16 && O.mapOptional("Description", R.Description) //
17 && O.mapOptional("Name", R.Name);
18}
19
21 return Object{
22 {"Description", Params.Description},
23 {"Declarations", Params.Declarations},
24 {"Definitions", Params.Definitions},
25 {"Example", Params.Example},
26 {"Default", Params.Default},
27 {"Type", Params.Type},
28 };
29}
30bool nixd::fromJSON(const Value &Params, OptionDescription &R, Path P) {
31 ObjectMapper O(Params, P);
32 return O //
33 && O.mapOptional("Description", R.Description) //
34 && O.mapOptional("Declarations", R.Declarations) //
35 && O.mapOptional("Definitions", R.Definitions) //
36 && O.mapOptional("Example", R.Example) //
37 && O.mapOptional("Default", R.Default) //
38 && O.mapOptional("Type", R.Type) //
39 ;
40}
41
43 return Object{
44 {"Name", Params.Name},
45 {"Description", Params.Description},
46 };
47}
48bool nixd::fromJSON(const Value &Params, OptionField &R, Path P) {
49 ObjectMapper O(Params, P);
50 return O //
51 && O.mapOptional("Description", R.Description) //
52 && O.mapOptional("Name", R.Name) //
53 ;
54}
55
57 return Object{
58 {"Items", Params.Items},
59 {"IsIncomplete", Params.IsIncomplete},
60 };
61}
62
63bool nixd::fromJSON(const Value &Params, OptionCompleteResponse &R, Path P) {
64 // Accept responses from workers predating the completion metadata envelope.
65 if (Params.getAsArray())
66 return llvm::json::fromJSON(Params, R.Items, P);
67
68 ObjectMapper O(Params, P);
69 return O && O.map("Items", R.Items) &&
70 O.mapOptional("IsIncomplete", R.IsIncomplete);
71}
72
74 return Object{
75 {"Name", Params.Name},
76 {"PName", Params.PName},
77 {"Version", Params.Version},
78 {"Description", Params.Description},
79 {"LongDescription", Params.LongDescription},
80 {"Position", Params.Position},
81 {"Homepage", Params.Homepage},
82 };
83}
84
85bool nixd::fromJSON(const llvm::json::Value &Params, PackageDescription &R,
86 llvm::json::Path P) {
87 ObjectMapper O(Params, P);
88 return O //
89 && O.map("Name", R.Name) //
90 && O.map("PName", R.PName) //
91 && O.map("Version", R.Version) //
92 && O.map("Description", R.Description) //
93 && O.map("LongDescription", R.LongDescription) //
94 && O.map("Position", R.Position) //
95 && O.map("Homepage", R.Homepage) //
96 ;
97}
98
100 return Object{
101 {"Type", Params.Type},
102 {"Location", Params.Location},
103 };
104}
105
106bool nixd::fromJSON(const llvm::json::Value &Params, ValueMeta &R,
107 llvm::json::Path P) {
108 ObjectMapper O(Params, P);
109 return O //
110 && O.map("Type", R.Type) //
111 && O.mapOptional("Location", R.Location) //
112 ;
113}
114
116 return Object{
117 {"Meta", Params.Meta},
118 {"PackageDesc", Params.PackageDesc},
119 {"ValueDesc", Params.ValueDesc},
120 };
121}
122
123bool nixd::fromJSON(const llvm::json::Value &Params, AttrPathInfoResponse &R,
124 llvm::json::Path P) {
125 ObjectMapper O(Params, P);
126 return O //
127 && O.map("Meta", R.Meta) //
128 && O.mapOptional("PackageDesc", R.PackageDesc) //
129 && O.mapOptional("ValueDesc", R.ValueDesc) //
130 ;
131}
132
134 return Object{{"Scope", Params.Scope}, {"Prefix", Params.Prefix}};
135}
136bool nixd::fromJSON(const llvm::json::Value &Params, AttrPathCompleteParams &R,
137 llvm::json::Path P) {
138 ObjectMapper O(Params, P);
139 return O //
140 && O.map("Scope", R.Scope) //
141 && O.map("Prefix", R.Prefix) //
142 ;
143}
144
146 return Object{
147 {"Items", Params.Items},
148 {"IsIncomplete", Params.IsIncomplete},
149 };
150}
151
152bool nixd::fromJSON(const Value &Params, AttrPathCompleteResponse &R, Path P) {
153 // Accept responses from workers predating the completion metadata envelope.
154 if (Params.getAsArray())
155 return llvm::json::fromJSON(Params, R.Items, P);
156
157 ObjectMapper O(Params, P);
158 return O && O.map("Items", R.Items) &&
159 O.mapOptional("IsIncomplete", R.IsIncomplete);
160}
161
162llvm::json::Value nixd::toJSON(const ValueDescription &Params) {
163 return Object{
164 {"arity", Params.Arity},
165 {"doc", Params.Doc},
166 {"args", Params.Args},
167 };
168}
169bool nixd::fromJSON(const llvm::json::Value &Params, ValueDescription &R,
170 llvm::json::Path P) {
171
172 ObjectMapper O(Params, P);
173 return O //
174 && O.map("arity", R.Arity) //
175 && O.map("doc", R.Doc) //
176 && O.map("args", R.Args);
177}
Types used in nixpkgs provider.
std::string Path
Definition Path.h:24
bool fromJSON(const llvm::json::Value &Params, Configuration::Diagnostic &R, llvm::json::Path P)
llvm::json::Value toJSON(const PackageDescription &Params)
Definition AttrSet.cpp:73
std::string Prefix
Search for packages prefixed with this "prefix".
Definition AttrSet.h:110
std::vector< std::string > Items
Definition AttrSet.h:118
std::optional< ValueDescription > ValueDesc
Definition AttrSet.h:100
ValueMeta Meta
General value description.
Definition AttrSet.h:95
PackageDescription PackageDesc
Package description of the attribute path, if available.
Definition AttrSet.h:98
std::vector< OptionField > Items
Definition AttrSet.h:160
std::vector< lspserver::Location > Definitions
Definition AttrSet.h:138
std::optional< std::string > Description
Definition AttrSet.h:136
std::optional< std::string > Example
Definition AttrSet.h:139
std::optional< OptionType > Type
Definition AttrSet.h:141
std::vector< lspserver::Location > Declarations
Definition AttrSet.h:137
std::optional< std::string > Default
Definition AttrSet.h:140
std::optional< OptionDescription > Description
Definition AttrSet.h:150
std::string Name
Definition AttrSet.h:149
std::optional< std::string > Description
Definition AttrSet.h:127
std::optional< std::string > Name
Definition AttrSet.h:128
std::optional< std::string > Name
Definition AttrSet.h:51
std::optional< std::string > Version
Definition AttrSet.h:53
std::optional< std::string > PName
Definition AttrSet.h:52
std::optional< std::string > Description
Definition AttrSet.h:54
std::optional< std::string > LongDescription
Definition AttrSet.h:55
std::optional< std::string > Position
Definition AttrSet.h:56
std::optional< std::string > Homepage
Definition AttrSet.h:57
Using nix's ":doc" method to retrieve value's additional information.
Definition AttrSet.h:83
std::int64_t Arity
Definition AttrSet.h:85
std::vector< std::string > Args
Definition AttrSet.h:86
std::string Doc
Definition AttrSet.h:84
General metadata of all nix::Values.
Definition AttrSet.h:65
std::optional< lspserver::Location > Location
Location of the value.
Definition AttrSet.h:75
int Type
Type of this value.
Definition AttrSet.h:67