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:
faumaray committed 2026-12-05 19:21:23 +03:00
1 parent a5b9f34c9e
commit 62d6ad01e8
13 files changed
+224 -5

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
#pragma once
#include <compare>
#include <cstddef>
#include <cstdint>
#include <string>
#include <string_view>
#include <vector>
namespace vls::features::document_links {
struct Position {
std::uint32_t line{}, character{};
auto operator<=>(const Position &) const = default;
};
struct Range {
Position start, end;
auto operator<=>(const Range &) const = default;
};
// A quoted include resolved lexically against the document's directory.
struct Link {
Range range; // the spelling inside the quotes
std::string path;
auto operator<=>(const Link &) const = default;
};
struct Limits {
std::size_t links{256};
std::size_t pathBytes{4096};
std::size_t scanBytes{8 * 1024 * 1024};
};
// Quoted include directives in TEXT resolved from DOCUMENT_PATH's directory.
// Angle includes are skipped because their search roots are unknown, and a
// directive without a terminated spelling on its line is skipped. The result
// is bounded; existence on disk is the caller's check.
[[nodiscard]] std::vector<Link> includes(std::string_view text, std::string_view document_path,
const Limits & = Limits{});
} // namespace vls::features::document_links