11#include <boost/asio/post.hpp>
29 llvm::StringRef Src) {
35 for (
const auto *
Use : Def.uses()) {
39 .kind = DocumentHighlightKind::Read,
43 const Node &Syntax = *Def.syntax();
46 .kind = DocumentHighlightKind::Write,
55void Controller::onDocumentHighlight(
62 if (std::shared_ptr<nixf::Node> AST = getAST(*
TU,
Reply)) [[
likely]] {
65 Reply(
error(
"cannot find corresponding node on given position"));
69 const auto &
PM = *
TU->parentMap();
70 const auto &VLA = *
TU->variableLookup();
72 }
catch (std::exception &E) {
73 elog(
"textDocument/documentHighlight failed: {0}", E.what());
74 return Reply(std::vector<DocumentHighlight>{});
79 boost::asio::post(Pool, std::move(
Action));
Convert between LSP and nixf types.
Lookup variable names, from it's parent scope.
const Node * descend(PositionRange Range) const
Descendant node that contains the given range.
LexerCursorRange range() const
Whether current platform treats paths case insensitively.
llvm::unique_function< void(llvm::Expected< T >)> Callback
llvm::Error error(std::error_code EC, const char *Fmt, Ts &&...Vals)
void elog(const char *Fmt, Ts &&...Vals)
bool fromJSON(const llvm::json::Value &Params, Configuration::Diagnostic &R, llvm::json::Path P)
nixf::Position toNixfPosition(const lspserver::Position &P)
const nixf::Definition & findDefinition(const nixf::Node &N, const nixf::ParentMapAnalysis &PMA, const nixf::VariableLookupAnalysis &VLA)
Heuristically find definition on some node.
lspserver::Range toLSPRange(llvm::StringRef Code, const nixf::LexerCursorRange &R)
Range range
The range this highlight applies to.