21#include <boost/asio/post.hpp>
23#include <llvm/ADT/StringRef.h>
24#include <llvm/Support/CommandLine.h>
31using namespace llvm::cl;
39class NixpkgsInlayHintsProvider {
45 std::optional<nixf::PositionRange>
Range;
47 std::vector<InlayHint> &Hints;
61 std::optional<lspserver::Range>
Range,
62 std::vector<InlayHint> &Hints, llvm::StringRef Src)
63 : NixpkgsProvider(NixpkgsProvider), VLA(VLA), PMA(PMA), Hints(Hints),
69 void dfs(
const Node *
N) {
72 if (
N->kind() == Node::NK_ExprVar) {
79 std::binary_semaphore Ready(0);
80 const std::string &Name =
static_cast<const ExprVar &
>(*N).
id().
name();
82 auto OnReply = [&Ready, &R](llvm::Expected<AttrPathInfoResponse>
Resp) {
97 .label =
": " + *Version,
98 .kind = InlayHintKind::Designator,
101 Hints.emplace_back(std::move(
H));
106 for (
const Node *
Ch :
N->children())
117 return Reply(std::vector<InlayHint>{});
123 if (std::shared_ptr<Node> AST = getAST(*
TU,
Reply)) [[
likely]] {
126 NixpkgsInlayHintsProvider
NP(*nixpkgsClient(), *
TU->variableLookup(),
134 boost::asio::post(Pool, std::move(
Action));
This file declares some common analysis (tree walk) on the AST.
Convert between LSP and nixf types.
void attrpathInfo(const AttrPathInfoParams &Params, lspserver::Callback< AttrPathInfoResponse > Reply)
const Identifier & id() const
const std::string & name() const
Whether current platform treats paths case insensitively.
llvm::unique_function< void(llvm::Expected< T >)> Callback
nixf::PositionRange toNixfRange(const lspserver::Range &P)
bool fromJSON(const llvm::json::Value &Params, Configuration::Diagnostic &R, llvm::json::Path P)
llvm::cl::OptionCategory NixdCategory
lspserver::Position toLSPPosition(llvm::StringRef Code, const nixf::LexerCursor &P)
bool havePackageScope(const nixf::Node &N, const nixf::VariableLookupAnalysis &VLA, const nixf::ParentMapAnalysis &PM)
Determine whether or not some node has enclosed "with pkgs; [ ]".
lspserver::Range toLSPRange(llvm::StringRef Code, const nixf::LexerCursorRange &R)
Position position
The position of this hint.
A parameter literal used in inlay hint requests.
bool contains(Position Pos) const
PackageDescription PackageDesc
Package description of the attribute path, if available.
std::optional< std::string > Version