Files
Language-Server/include/vls/features/InlayHints.hpp
T
faumaray 130cb57a7f Serve parameter inlay hints from occurrence signatures
A bounded core finds top-level argument starts (nested brackets,
literals and comments aware) and projects parameter-type hints from the
compiler signature, filtered to the requested range. The server
advertises inlayHintProvider and serves textDocument/inlayHint through
EditorDiagnostics. Registered tests cover splitting, filtering, short
signatures and bounds; a real stdio session returned the
std::string_view hint for the fnv1a64 argument. Refresh the parity
matrix.
2026-12-05 15:40:19 +03:00

48 lines
1.5 KiB
C++

#pragma once
#include <compare>
#include <cstddef>
#include <cstdint>
#include <span>
#include <string>
#include <string_view>
#include <vector>
namespace vls::features::inlay_hints {
struct Position {
std::uint32_t line{}, character{};
auto operator<=>(const Position &) const = default;
};
struct Range {
Position start, end;
auto operator<=>(const Range &) const = default;
};
struct Hint {
Position position;
std::string label;
std::uint32_t kind{}; // LSP InlayHintKind: 2 is Parameter
bool padding_left{}, padding_right{};
auto operator<=>(const Hint &) const = default;
};
struct Limits {
std::size_t arguments{16};
std::size_t hints{256};
std::size_t labelBytes{128};
};
// Byte offsets of the top-level argument starts of the call whose '(' follows
// CALLEE_END. Nested brackets, literals and comments do not split arguments.
[[nodiscard]] std::vector<std::size_t>
argument_starts(std::string_view text, std::size_t callee_end, const Limits & = Limits{});
// One parameter-type hint before each argument, taken from the compiler
// signature for that position. Hints outside the requested range are skipped;
// a signature without that parameter contributes nothing.
[[nodiscard]] std::vector<Hint> parameter_hints(std::span<const std::string> signatures,
std::string_view text, std::size_t callee_end,
Range requested, const Limits & = Limits{});
} // namespace vls::features::inlay_hints