Serve document links for quoted includes
A bounded core resolves quoted include directives from the document directory and reports the spelling range; the server advertises documentLinkProvider and serves textDocument/documentLink from snapshots, keeping only targets that exist on disk. Angle includes are skipped because their search roots are unknown. Registered feature tests cover resolution, indentation, line counting, skipping and bounds, and the exact-capability-set assertion was updated. A real stdio session linked extra.hpp and skipped <vector> and a missing file.
This commit is contained in:
1 parent
a5b9f34c9e
commit
62d6ad01e8
13 files changed
+224
-5
No files matched your search
@@ -2,11 +2,14 @@
|
||||
|
||||
#include <vls/DocumentSync.hpp>
|
||||
#include <vls/Json.hpp>
|
||||
#include <vls/features/DocumentLinks.hpp>
|
||||
#include <vls/semantic/EditorDiagnostics.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <condition_variable>
|
||||
#include <deque>
|
||||
#include <exception>
|
||||
#include <filesystem>
|
||||
#include <mutex>
|
||||
#include <ostream>
|
||||
#include <thread>
|
||||
@@ -305,6 +308,8 @@ DispatchResult Server::handle(std::string_view body) {
|
||||
Json{std::string{Void::LanguageServer::Documents::encoding_name(encoding)}}},
|
||||
{"textDocumentSync", Json{std::move(sync)}},
|
||||
{"workspace", Json{std::move(workspace)}}};
|
||||
capabilities.emplace("documentLinkProvider",
|
||||
Json{Json::Object{{"resolveProvider", Json{false}}}});
|
||||
if (diagnostics_) {
|
||||
capabilities.emplace("documentSymbolProvider", Json{true});
|
||||
capabilities.emplace("selectionRangeProvider", Json{true});
|
||||
@@ -441,6 +446,33 @@ DispatchResult Server::handle(std::string_view body) {
|
||||
}
|
||||
return reply(id, "result", diagnostics_->selection_ranges(*uri, selected));
|
||||
}
|
||||
if (*method == "textDocument/documentLink") {
|
||||
const auto *uri = as_string(member(member(params, "textDocument"), "uri"));
|
||||
if (!uri || !Void::LanguageServer::Documents::client_uri_key(*uri))
|
||||
return error(id, -32602, "Expected textDocument.uri");
|
||||
const auto snapshot = documents_.snapshot(*uri);
|
||||
if (!snapshot)
|
||||
return reply(id, "result", Json{Json::Array{}});
|
||||
const auto links = features::document_links::includes(
|
||||
snapshot->text, snapshot->identity.canonical_path.native());
|
||||
Json::Array result;
|
||||
for (const auto &link : links) {
|
||||
std::error_code error;
|
||||
if (!std::filesystem::exists(link.path, error))
|
||||
continue;
|
||||
const auto point = [](Void::LanguageServer::Documents::Position value) {
|
||||
return Json{
|
||||
Json::Object{{"line", Json{static_cast<std::int64_t>(value.line)}},
|
||||
{"character", Json{static_cast<std::int64_t>(value.character)}}}};
|
||||
};
|
||||
result.push_back(Json{Json::Object{
|
||||
{"range", Json{Json::Object{
|
||||
{"start", point({link.range.start.line, link.range.start.character})},
|
||||
{"end", point({link.range.end.line, link.range.end.character})}}}},
|
||||
{"target", Json{Void::LanguageServer::Documents::path_to_file_uri(link.path)}}}});
|
||||
}
|
||||
return reply(id, "result", Json{std::move(result)});
|
||||
}
|
||||
if (*method == "textDocument/codeLens") {
|
||||
if (!diagnostics_ || !diagnostics_->supports_occurrences())
|
||||
return error(id, -32601, "Method not found");
|
||||
|
||||
Reference in new issue
Block a user