10#include <boost/asio/post.hpp>
14using namespace llvm::json;
18 Callback<std::vector<CodeAction>> Reply) {
21 auto Action = [Reply = std::move(Reply),
File,
Range,
this]()
mutable {
22 if (
auto TU = getTU(
File, Reply)) {
23 std::vector<nixf::Diagnostic> Diagnostics = TU->diagnostics();
24 std::vector<CodeAction> Actions;
25 Actions.reserve(Diagnostics.size());
27 auto DRange =
toLSPRange(TU->src(), D.range());
33 std::vector<TextEdit> Edits;
34 Edits.reserve(F.edits().size());
38 .newText = std::string(TE.newText()),
41 using Changes = std::map<std::string, std::vector<TextEdit>>;
44 {std::move(FileURI), std::move(Edits)},
49 .edit = std::move(WE),
53 Reply(std::move(Actions));
56 boost::asio::post(Pool, std::move(Action));
Convert between LSP and nixf types.
Whether current platform treats paths case insensitively.
llvm::unique_function< void(llvm::Expected< T >)> Callback
lspserver::Range toLSPRange(llvm::StringRef Code, const nixf::LexerCursorRange &R)
Range range
The range for which the command was invoked.
TextDocumentIdentifier textDocument
The document in which the command was invoked.
std::string title
A short, human-readable, title for this code action.
static const llvm::StringLiteral QUICKFIX_KIND
bool overlap(const Range &RHS) const
URIForFile uri
The text document's URI.
static URIForFile canonicalize(llvm::StringRef AbsPath, llvm::StringRef TUPath)
llvm::StringRef file() const
Retrieves absolute path to the file.
std::optional< std::map< std::string, std::vector< TextEdit > > > changes
Holds changes to existing resources.