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
@@ -266,6 +266,8 @@ DispatchResult Server::handle(std::string_view body) {
|
||||
capabilities.emplace("selectionRangeProvider", Json{true});
|
||||
capabilities.emplace("foldingRangeProvider", Json{true});
|
||||
}
|
||||
if (diagnostics_ && diagnostics_->supports_occurrences())
|
||||
capabilities.emplace("inlayHintProvider", Json{true});
|
||||
if (diagnostics_ && diagnostics_->supports_occurrences())
|
||||
capabilities.emplace(
|
||||
"semanticTokensProvider",
|
||||
@@ -386,6 +388,32 @@ DispatchResult Server::handle(std::string_view body) {
|
||||
}
|
||||
return reply(id, "result", diagnostics_->selection_ranges(*uri, selected));
|
||||
}
|
||||
if (*method == "textDocument/inlayHint") {
|
||||
if (!diagnostics_ || !diagnostics_->supports_occurrences())
|
||||
return error(id, -32601, "Method not found");
|
||||
const auto *uri = as_string(member(member(params, "textDocument"), "uri"));
|
||||
const auto *range = member(params, "range");
|
||||
const auto *start = member(range, "start");
|
||||
const auto *end = member(range, "end");
|
||||
const auto coordinate = [](const Json *value,
|
||||
std::string_view key) -> std::optional<std::uint32_t> {
|
||||
const auto *field = member(value, key);
|
||||
const auto *number = field ? std::get_if<std::int64_t>(&field->value) : nullptr;
|
||||
if (!number || *number < 0 ||
|
||||
*number > Void::LanguageServer::Documents::kMaxPositionValue)
|
||||
return std::nullopt;
|
||||
return static_cast<std::uint32_t>(*number);
|
||||
};
|
||||
const auto start_line = coordinate(start, "line"),
|
||||
start_character = coordinate(start, "character");
|
||||
const auto end_line = coordinate(end, "line"), end_character = coordinate(end, "character");
|
||||
if (!uri || !Void::LanguageServer::Documents::client_uri_key(*uri) || !start_line ||
|
||||
!start_character || !end_line || !end_character)
|
||||
return error(id, -32602, "Expected textDocument.uri and a bounded range");
|
||||
return reply(id, "result",
|
||||
diagnostics_->inlay_hints(
|
||||
*uri, {{*start_line, *start_character}, {*end_line, *end_character}}));
|
||||
}
|
||||
if (*method == "textDocument/semanticTokens/full") {
|
||||
if (!diagnostics_ || !diagnostics_->supports_occurrences())
|
||||
return error(id, -32601, "Method not found");
|
||||
|
||||
Reference in new issue
Block a user