Serve type hierarchy from observer class facts
Occurrences carry their result type uid, decoded types are retained per editor entry, and a bounded core selects direct bases and inverse subtypes. The server advertises typeHierarchyProvider and serves prepareTypeHierarchy, supertypes and subtypes. Registered feature tests cover the selection; a real stdio session prepared DerivedA and returned Base as supertype and DerivedA/DerivedB as subtypes of Base.
This commit is contained in:
1 parent
b1c8a4a625
commit
86b9923532
14 files changed
+357
-15
No files matched your search
+22
-7
@@ -332,6 +332,8 @@ DispatchResult Server::handle(std::string_view body) {
|
||||
}
|
||||
if (diagnostics_ && diagnostics_->supports_occurrences())
|
||||
capabilities.emplace("callHierarchyProvider", Json{true});
|
||||
if (diagnostics_ && diagnostics_->supports_occurrences())
|
||||
capabilities.emplace("typeHierarchyProvider", Json{true});
|
||||
if (diagnostics_ && diagnostics_->supports_occurrences()) {
|
||||
capabilities.emplace("codeLensProvider",
|
||||
Json{Json::Object{{"resolveProvider", Json{false}}}});
|
||||
@@ -434,7 +436,8 @@ DispatchResult Server::handle(std::string_view body) {
|
||||
return reply(id, "result", std::move(result));
|
||||
}
|
||||
if (*method == "textDocument/hover" || *method == "textDocument/definition" ||
|
||||
*method == "textDocument/signatureHelp" || *method == "textDocument/documentHighlight") {
|
||||
*method == "textDocument/signatureHelp" || *method == "textDocument/documentHighlight" ||
|
||||
*method == "textDocument/prepareTypeHierarchy") {
|
||||
if (!diagnostics_ || !diagnostics_->supports_occurrences())
|
||||
return error(id, -32601, "Method not found");
|
||||
const auto *uri = as_string(member(member(params, "textDocument"), "uri"));
|
||||
@@ -451,12 +454,13 @@ DispatchResult Server::handle(std::string_view body) {
|
||||
return error(id, -32602, "Expected textDocument.uri and a bounded position");
|
||||
const Void::LanguageServer::Documents::Position selected{
|
||||
static_cast<std::uint32_t>(*line_value), static_cast<std::uint32_t>(*character_value)};
|
||||
auto result = *method == "textDocument/hover" ? diagnostics_->hover(*uri, selected)
|
||||
: *method == "textDocument/definition"
|
||||
? diagnostics_->definition(*uri, selected)
|
||||
: *method == "textDocument/signatureHelp"
|
||||
? diagnostics_->signature_help(*uri, selected)
|
||||
: diagnostics_->document_highlights(*uri, selected);
|
||||
auto result =
|
||||
*method == "textDocument/hover" ? diagnostics_->hover(*uri, selected)
|
||||
: *method == "textDocument/definition" ? diagnostics_->definition(*uri, selected)
|
||||
: *method == "textDocument/signatureHelp" ? diagnostics_->signature_help(*uri, selected)
|
||||
: *method == "textDocument/documentHighlight"
|
||||
? diagnostics_->document_highlights(*uri, selected)
|
||||
: diagnostics_->prepare_type_hierarchy(*uri, selected);
|
||||
return reply(id, "result", std::move(result));
|
||||
}
|
||||
if (*method == "completionItem/resolve") {
|
||||
@@ -595,6 +599,17 @@ DispatchResult Server::handle(std::string_view body) {
|
||||
*uri, {static_cast<std::uint32_t>(*line_value),
|
||||
static_cast<std::uint32_t>(*character_value)}));
|
||||
}
|
||||
if (*method == "typeHierarchy/supertypes" || *method == "typeHierarchy/subtypes") {
|
||||
if (!diagnostics_ || !diagnostics_->supports_occurrences())
|
||||
return error(id, -32601, "Method not found");
|
||||
const auto *item = member(params, "item");
|
||||
if (!item)
|
||||
return error(id, -32602, "Expected a type hierarchy item");
|
||||
return reply(id, "result",
|
||||
*method == "typeHierarchy/supertypes"
|
||||
? diagnostics_->type_hierarchy_supertypes(*item)
|
||||
: diagnostics_->type_hierarchy_subtypes(*item));
|
||||
}
|
||||
if (*method == "callHierarchy/outgoingCalls") {
|
||||
if (!diagnostics_ || !diagnostics_->supports_occurrences())
|
||||
return error(id, -32601, "Method not found");
|
||||
|
||||
Reference in new issue
Block a user