7#include <boost/asio/post.hpp>
17 std::lock_guard
_(TUsLock);
23 std::optional<int64_t> Version) {
24 auto Action = [
this,
File = std::string(
File), Version]() {
26 std::shared_ptr<const std::string> Src = Draft->Contents;
27 assert(Draft &&
"Added document is not in the store?");
29 std::vector<nixf::Diagnostic> Diagnostics;
30 std::shared_ptr<nixf::Node> AST =
34 std::lock_guard G(TUsLock);
35 publishDiagnostics(
File, Version, *Src, Diagnostics);
36 TUs.insert_or_assign(
File,
37 std::make_shared<NixTU>(std::move(Diagnostics),
38 std::move(AST), std::nullopt,
43 auto VLA = std::make_unique<nixf::VariableLookupAnalysis>(Diagnostics);
46 publishDiagnostics(
File, Version, *Src, Diagnostics);
49 std::lock_guard G(TUsLock);
51 File, std::make_shared<NixTU>(std::move(Diagnostics), std::move(AST),
52 std::nullopt, std::move(VLA), Src));
59void Controller::createWorkDoneProgress(
62 CreateWorkDoneProgress(Params, [](llvm::Expected<std::nullptr_t> Reply) {
64 elog(
"create workdone progress error: {0}", Reply.takeError());
69 std::unique_ptr<lspserver::OutboundPort> Out)
70 :
LSPServer(std::move(In), std::move(Out)) {
80 &Controller::onDocumentDidOpen);
82 &Controller::onDocumentDidChange);
85 &Controller::onDocumentDidClose);
89 &Controller::onDefinition);
91 &Controller::onDocumentSymbol);
93 &Controller::onSemanticTokens);
96 &Controller::onCompletion);
98 &Controller::onCompletionItemResolve);
100 &Controller::onReferences);
102 &Controller::onDocumentHighlight);
104 &Controller::onDocumentLink);
106 &Controller::onCodeAction);
111 &Controller::onPrepareRename);
115 &Controller::onDidChangeConfiguration);
118 "workspace/configuration");
121 "textDocument/publishDiagnostics");
122 CreateWorkDoneProgress =
124 "window/workDoneProgress/create");
125 BeginWorkDoneProgress =
127 ReportWorkDoneProgress =
129 EndWorkDoneProgress =
Lookup variable names, from it's parent scope.
std::optional< Draft > getDraft(PathRef File) const
void removeDraft(PathRef File)
Remove the draft from the store.
llvm::unique_function< void(const ParamTy &, Callback< ResponseTy >)> mkOutMethod(llvm::StringRef Method, OutboundPort *O=nullptr)
llvm::unique_function< void(const T &)> mkOutNotifiction(llvm::StringRef Method, OutboundPort *O=nullptr)
Controller(std::unique_ptr< lspserver::InboundPort > In, std::unique_ptr< lspserver::OutboundPort > Out)
Whether current platform treats paths case insensitively.
void elog(const char *Fmt, Ts &&...Vals)
std::shared_ptr< Node > parse(std::string_view Src, std::vector< Diagnostic > &Diags)
Parse a string.
void addMethod(llvm::StringRef Method, ThisT *This, void(ThisT::*Handler)(const Param &, Callback< Result >))
void addNotification(llvm::StringLiteral Method, ThisT *This, void(ThisT::*Handler)(const Param &))