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.
This commit is contained in:
1 parent
12a71ff692
commit
130cb57a7f
12 files changed
+360
-10
No files matched your search
@@ -0,0 +1,47 @@
|
||||
#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
|
||||
@@ -54,6 +54,9 @@ class EditorDiagnostics {
|
||||
Documents::Range range) const;
|
||||
// Semantic tokens for the document's proven occurrences, delta-encoded.
|
||||
[[nodiscard]] Void::LanguageServer::Protocol::Json semantic_tokens(std::string_view uri) const;
|
||||
// Parameter-type hints from the compiler signature, within the range.
|
||||
[[nodiscard]] Void::LanguageServer::Protocol::Json inlay_hints(std::string_view uri,
|
||||
Documents::Range range) const;
|
||||
|
||||
struct NavigationReply {
|
||||
Void::LanguageServer::Protocol::Json result;
|
||||
|
||||
Reference in new issue
Block a user