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