7#include <boost/asio/post.hpp>
15 Store.removeDraft(
File);
17 std::lock_guard
_(TUsLock);
20 publishDiagnostics(
File, std::nullopt,
"", {});
24 std::optional<int64_t> Version) {
25 auto Action = [
this,
File = std::string(
File), Version]() {
26 auto Draft = Store.getDraft(
File);
27 std::shared_ptr<const std::string> Src = Draft->Contents;
28 assert(Draft &&
"Added document is not in the store?");
30 std::vector<nixf::Diagnostic> Diagnostics;
31 std::shared_ptr<nixf::Node> AST =
35 std::lock_guard G(TUsLock);
36 publishDiagnostics(
File, Version, *Src, Diagnostics);
37 TUs.insert_or_assign(
File,
38 std::make_shared<NixTU>(std::move(Diagnostics),
39 std::move(AST), std::nullopt,
44 auto VLA = std::make_unique<nixf::VariableLookupAnalysis>(Diagnostics);
47 publishDiagnostics(
File, Version, *Src, Diagnostics);
50 std::lock_guard G(TUsLock);
52 File, std::make_shared<NixTU>(std::move(Diagnostics), std::move(AST),
53 std::nullopt, std::move(VLA), Src));
60void Controller::createWorkDoneProgress(
62 if (ClientCaps.WorkDoneProgress)
63 CreateWorkDoneProgress(Params, [](llvm::Expected<std::nullptr_t> Reply) {
65 elog(
"create workdone progress error: {0}", Reply.takeError());
70 std::unique_ptr<lspserver::OutboundPort> Out)
71 :
LSPServer(std::move(In), std::move(Out)) {
74 Registry.addMethod(
"initialize",
this, &Controller::onInitialize);
75 Registry.addNotification(
"initialized",
this, &Controller::onInitialized);
77 Registry.addMethod(
"shutdown",
this, &Controller::onShutdown);
80 Registry.addNotification(
"textDocument/didOpen",
this,
81 &Controller::onDocumentDidOpen);
82 Registry.addNotification(
"textDocument/didChange",
this,
83 &Controller::onDocumentDidChange);
85 Registry.addNotification(
"textDocument/didClose",
this,
86 &Controller::onDocumentDidClose);
89 Registry.addMethod(
"textDocument/definition",
this,
90 &Controller::onDefinition);
91 Registry.addMethod(
"textDocument/documentSymbol",
this,
92 &Controller::onDocumentSymbol);
93 Registry.addMethod(
"textDocument/semanticTokens/full",
this,
94 &Controller::onSemanticTokens);
95 Registry.addMethod(
"textDocument/inlayHint",
this, &Controller::onInlayHint);
96 Registry.addMethod(
"textDocument/completion",
this,
97 &Controller::onCompletion);
98 Registry.addMethod(
"completionItem/resolve",
this,
99 &Controller::onCompletionItemResolve);
100 Registry.addMethod(
"textDocument/references",
this,
101 &Controller::onReferences);
102 Registry.addMethod(
"textDocument/documentHighlight",
this,
103 &Controller::onDocumentHighlight);
104 Registry.addMethod(
"textDocument/documentLink",
this,
105 &Controller::onDocumentLink);
106 Registry.addMethod(
"textDocument/codeAction",
this,
107 &Controller::onCodeAction);
108 Registry.addMethod(
"textDocument/hover",
this, &Controller::onHover);
109 Registry.addMethod(
"textDocument/formatting",
this, &Controller::onFormat);
110 Registry.addMethod(
"textDocument/rename",
this, &Controller::onRename);
111 Registry.addMethod(
"textDocument/prepareRename",
this,
112 &Controller::onPrepareRename);
115 Registry.addNotification(
"workspace/didChangeConfiguration",
this,
116 &Controller::onDidChangeConfiguration);
119 "workspace/configuration");
122 "textDocument/publishDiagnostics");
123 CreateWorkDoneProgress =
125 "window/workDoneProgress/create");
126 BeginWorkDoneProgress =
128 ReportWorkDoneProgress =
130 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.