7#include <boost/asio/post.hpp>
15 Store.removeDraft(
File);
17 std::lock_guard
_(TUsLock);
23 std::optional<int64_t> Version) {
24 auto Action = [
this,
File = std::string(
File), Version]() {
25 auto Draft = Store.getDraft(
File);
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(
61 if (ClientCaps.WorkDoneProgress)
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)) {
73 Registry.addMethod(
"initialize",
this, &Controller::onInitialize);
74 Registry.addNotification(
"initialized",
this, &Controller::onInitialized);
76 Registry.addMethod(
"shutdown",
this, &Controller::onShutdown);
79 Registry.addNotification(
"textDocument/didOpen",
this,
80 &Controller::onDocumentDidOpen);
81 Registry.addNotification(
"textDocument/didChange",
this,
82 &Controller::onDocumentDidChange);
84 Registry.addNotification(
"textDocument/didClose",
this,
85 &Controller::onDocumentDidClose);
88 Registry.addMethod(
"textDocument/definition",
this,
89 &Controller::onDefinition);
90 Registry.addMethod(
"textDocument/documentSymbol",
this,
91 &Controller::onDocumentSymbol);
92 Registry.addMethod(
"textDocument/semanticTokens/full",
this,
93 &Controller::onSemanticTokens);
94 Registry.addMethod(
"textDocument/inlayHint",
this, &Controller::onInlayHint);
95 Registry.addMethod(
"textDocument/completion",
this,
96 &Controller::onCompletion);
97 Registry.addMethod(
"completionItem/resolve",
this,
98 &Controller::onCompletionItemResolve);
99 Registry.addMethod(
"textDocument/references",
this,
100 &Controller::onReferences);
101 Registry.addMethod(
"textDocument/documentHighlight",
this,
102 &Controller::onDocumentHighlight);
103 Registry.addMethod(
"textDocument/documentLink",
this,
104 &Controller::onDocumentLink);
105 Registry.addMethod(
"textDocument/codeAction",
this,
106 &Controller::onCodeAction);
107 Registry.addMethod(
"textDocument/hover",
this, &Controller::onHover);
108 Registry.addMethod(
"textDocument/formatting",
this, &Controller::onFormat);
109 Registry.addMethod(
"textDocument/rename",
this, &Controller::onRename);
110 Registry.addMethod(
"textDocument/prepareRename",
this,
111 &Controller::onPrepareRename);
114 Registry.addNotification(
"workspace/didChangeConfiguration",
this,
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.
llvm::unique_function< void(const ParamTy &, Callback< ResponseTy >)> mkOutMethod(llvm::StringRef Method, OutboundPort *O=nullptr)
LSPServer(std::unique_ptr< InboundPort > In, std::unique_ptr< OutboundPort > Out)
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.