✨ feat(lsp_server): add call snippets to completion resolve
This commit is contained in:
@@ -414,6 +414,7 @@ namespace lsp::provider::text_document
|
||||
|
||||
void AppendFunctions(const language::symbol::SymbolTable& table, const std::string& prefix, CompletionSource source, std::vector<SourcedCompletionItem>& out)
|
||||
{
|
||||
const auto module_name = GetModuleName(table);
|
||||
for (const auto& wrapper : table.all_definitions())
|
||||
{
|
||||
const auto& symbol = wrapper.get();
|
||||
@@ -431,6 +432,17 @@ namespace lsp::provider::text_document
|
||||
auto detail = BuildSignature(func->parameters, func->return_type);
|
||||
item.labelDetails = protocol::CompletionItemLabelDetails{ .detail = detail, .description = SourceTag(source) };
|
||||
}
|
||||
|
||||
protocol::LSPObject data;
|
||||
data["ctx"] = "call";
|
||||
data["kind"] = "function";
|
||||
data["name"] = symbol.name();
|
||||
if (!module_name.empty())
|
||||
{
|
||||
data["unit"] = module_name;
|
||||
}
|
||||
item.data = std::move(data);
|
||||
|
||||
out.push_back({ std::move(item), source });
|
||||
}
|
||||
}
|
||||
@@ -467,6 +479,13 @@ namespace lsp::provider::text_document
|
||||
{
|
||||
auto detail = BuildSignature(func->parameters, func->return_type);
|
||||
item.labelDetails = protocol::CompletionItemLabelDetails{ .detail = detail, .description = SourceTag(source) };
|
||||
|
||||
protocol::LSPObject data;
|
||||
data["ctx"] = "call";
|
||||
data["kind"] = "function";
|
||||
data["name"] = symbol.name();
|
||||
data["unit"] = module_name;
|
||||
item.data = std::move(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -819,6 +838,7 @@ namespace lsp::provider::text_document
|
||||
|
||||
void AppendClassMethods(const language::symbol::SymbolTable& table, const language::symbol::Class& cls, const std::string& prefix, CompletionSource source, std::vector<SourcedCompletionItem>& out)
|
||||
{
|
||||
const auto module_name = GetModuleName(table);
|
||||
auto scope_id = FindScopeOwnedBy(table, language::symbol::ScopeKind::kClass, cls.id);
|
||||
if (!scope_id)
|
||||
{
|
||||
@@ -857,6 +877,19 @@ namespace lsp::provider::text_document
|
||||
.detail = BuildSignature(method->parameters, method->return_type),
|
||||
.description = SourceTag(source)
|
||||
};
|
||||
|
||||
protocol::LSPObject data;
|
||||
data["ctx"] = "call";
|
||||
data["kind"] = "method";
|
||||
data["name"] = method->name;
|
||||
data["class"] = cls.name;
|
||||
if (!module_name.empty())
|
||||
{
|
||||
data["unit"] = module_name;
|
||||
}
|
||||
data["is_static"] = method->is_static;
|
||||
item.data = std::move(data);
|
||||
|
||||
out.push_back({ std::move(item), source });
|
||||
}
|
||||
}
|
||||
@@ -932,6 +965,13 @@ namespace lsp::provider::text_document
|
||||
CompletionSource source,
|
||||
std::vector<SourcedCompletionItem>& out)
|
||||
{
|
||||
const auto module_name = GetModuleName(table);
|
||||
std::string class_name;
|
||||
if (const auto* class_symbol = table.definition(class_id))
|
||||
{
|
||||
class_name = class_symbol->name();
|
||||
}
|
||||
|
||||
auto scope_id = FindScopeOwnedBy(table, language::symbol::ScopeKind::kClass, class_id);
|
||||
if (!scope_id)
|
||||
{
|
||||
@@ -979,6 +1019,22 @@ namespace lsp::provider::text_document
|
||||
.detail = BuildSignature(method->parameters, method->return_type),
|
||||
.description = SourceTag(source)
|
||||
};
|
||||
|
||||
protocol::LSPObject data;
|
||||
data["ctx"] = "call";
|
||||
data["kind"] = "method";
|
||||
data["name"] = method->name;
|
||||
if (!class_name.empty())
|
||||
{
|
||||
data["class"] = class_name;
|
||||
}
|
||||
if (!module_name.empty())
|
||||
{
|
||||
data["unit"] = module_name;
|
||||
}
|
||||
data["is_static"] = method->is_static;
|
||||
item.data = std::move(data);
|
||||
|
||||
out.push_back({ std::move(item), source });
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user