nixd
Loading...
Searching...
No Matches
AttrSet.h
Go to the documentation of this file.
1/// \file
2/// \brief Types used in nixpkgs provider.
3
4#pragma once
5
6#include <optional>
7#include <string>
8#include <vector>
9
10#include <llvm/Support/JSON.h>
11#include <lspserver/Protocol.h>
12
13// https://github.com/NixOS/nix/issues/11136
14#ifdef __clang__
15#pragma clang diagnostic push
16#pragma clang diagnostic ignored "-Wdocumentation"
17#endif
18
19#include <nix/value.hh>
20
21#ifdef __clang__
22#pragma clang diagnostic pop
23#endif
24
25namespace nixd {
26
27namespace rpcMethod {
28
29constexpr inline std::string_view EvalExpr = "attrset/evalExpr";
30constexpr inline std::string_view AttrPathInfo = "attrset/attrpathInfo";
31constexpr inline std::string_view AttrPathComplete = "attrset/attrpathComplete";
32constexpr inline std::string_view OptionInfo = "attrset/optionInfo";
33constexpr inline std::string_view OptionComplete = "attrset/optionComplete";
34constexpr inline std::string_view Exit = "exit";
35
36} // namespace rpcMethod
37
38using EvalExprParams = std::string;
39using EvalExprResponse = std::optional<std::string>;
40
41/// \brief A list of strings that "select"s into a attribute set.
42using Selector = std::vector<std::string>;
43
46
48
50 std::optional<std::string> Name;
51 std::optional<std::string> PName;
52 std::optional<std::string> Version;
53 std::optional<std::string> Description;
54 std::optional<std::string> LongDescription;
55 std::optional<std::string> Position;
56 std::optional<std::string> Homepage;
57};
58
59llvm::json::Value toJSON(const PackageDescription &Params);
60bool fromJSON(const llvm::json::Value &Params, PackageDescription &R,
61 llvm::json::Path P);
62
63/// \brief General metadata of all `nix::Value`s
64struct ValueMeta {
65 /// \brief Type of this value.
66 int Type;
67
68 /// \brief Location of the value.
69 ///
70 /// This presence of this value is determined by the nix evaluator.
71 /// In nix 2.19.x and later:
72 /// 1. It is available only for attribute sets and lambdas.
73 /// 2. There is no practical "range" information, only the starting point.
74 std::optional<lspserver::Location> Location;
75};
76
77llvm::json::Value toJSON(const ValueMeta &Params);
78bool fromJSON(const llvm::json::Value &Params, ValueMeta &R,
79 llvm::json::Path P);
80
82 /// \brief General value description
84
85 /// \brief Package description of the attribute path, if available.
87};
88
89llvm::json::Value toJSON(const AttrPathInfoResponse &Params);
90bool fromJSON(const llvm::json::Value &Params, AttrPathInfoResponse &R,
91 llvm::json::Path P);
92
95 /// \brief Search for packages prefixed with this "prefix"
96 std::string Prefix;
97};
98
99llvm::json::Value toJSON(const AttrPathCompleteParams &Params);
100bool fromJSON(const llvm::json::Value &Params, AttrPathCompleteParams &R,
101 llvm::json::Path P);
102
103using AttrPathCompleteResponse = std::vector<std::string>;
104
106 std::optional<std::string> Description;
107 std::optional<std::string> Name;
108};
109
110llvm::json::Value toJSON(const OptionType &Params);
111bool fromJSON(const llvm::json::Value &Params, OptionType &R,
112 llvm::json::Path P);
113
115 std::optional<std::string> Description;
116 std::vector<lspserver::Location> Declarations;
117 std::vector<lspserver::Location> Definitions;
118 std::optional<std::string> Example;
119 std::optional<OptionType> Type;
120};
121
122llvm::json::Value toJSON(const OptionDescription &Params);
123bool fromJSON(const llvm::json::Value &Params, OptionDescription &R,
124 llvm::json::Path P);
125
127 std::string Name;
128 std::optional<OptionDescription> Description;
129};
130
131llvm::json::Value toJSON(const OptionField &Params);
132bool fromJSON(const llvm::json::Value &Params, OptionField &R,
133 llvm::json::Path P);
134
136
137using OptionCompleteResponse = std::vector<OptionField>;
138
139} // namespace nixd
constexpr std::string_view Exit
Definition AttrSet.h:34
constexpr std::string_view EvalExpr
Definition AttrSet.h:29
constexpr std::string_view OptionInfo
Definition AttrSet.h:32
constexpr std::string_view AttrPathInfo
Definition AttrSet.h:30
constexpr std::string_view OptionComplete
Definition AttrSet.h:33
constexpr std::string_view AttrPathComplete
Definition AttrSet.h:31
std::string EvalExprParams
Definition AttrSet.h:38
bool fromJSON(const llvm::json::Value &Params, Configuration::Diagnostic &R, llvm::json::Path P)
llvm::json::Value toJSON(const PackageDescription &Params)
Definition AttrSet.cpp:54
std::vector< std::string > AttrPathCompleteResponse
Definition AttrSet.h:103
Selector PackageInfoParams
Definition AttrSet.h:44
std::vector< std::string > Selector
A list of strings that "select"s into a attribute set.
Definition AttrSet.h:42
Selector AttrPathInfoParams
Definition AttrSet.h:47
std::vector< OptionField > OptionCompleteResponse
Definition AttrSet.h:137
Selector OptionInfoParams
Definition AttrSet.h:45
std::optional< std::string > EvalExprResponse
Definition AttrSet.h:39
std::string Prefix
Search for packages prefixed with this "prefix".
Definition AttrSet.h:96
ValueMeta Meta
General value description.
Definition AttrSet.h:83
PackageDescription PackageDesc
Package description of the attribute path, if available.
Definition AttrSet.h:86
std::vector< lspserver::Location > Definitions
Definition AttrSet.h:117
std::optional< std::string > Description
Definition AttrSet.h:115
std::optional< std::string > Example
Definition AttrSet.h:118
std::optional< OptionType > Type
Definition AttrSet.h:119
std::vector< lspserver::Location > Declarations
Definition AttrSet.h:116
std::optional< OptionDescription > Description
Definition AttrSet.h:128
std::string Name
Definition AttrSet.h:127
std::optional< std::string > Description
Definition AttrSet.h:106
std::optional< std::string > Name
Definition AttrSet.h:107
std::optional< std::string > Name
Definition AttrSet.h:50
std::optional< std::string > Version
Definition AttrSet.h:52
std::optional< std::string > PName
Definition AttrSet.h:51
std::optional< std::string > Description
Definition AttrSet.h:53
std::optional< std::string > LongDescription
Definition AttrSet.h:54
std::optional< std::string > Position
Definition AttrSet.h:55
std::optional< std::string > Homepage
Definition AttrSet.h:56
General metadata of all nix::Values.
Definition AttrSet.h:64
std::optional< lspserver::Location > Location
Location of the value.
Definition AttrSet.h:74
int Type
Type of this value.
Definition AttrSet.h:66