CppLanguageServer: Add "get_parameters_hint" capability

Given a call site, the C++ language server can now return the declared
parameters of the called function, as well as the index of the
parameter that the cursor is currently at.
This commit is contained in:
Itamar 2021-07-03 11:55:54 +03:00 committed by Andreas Kling
parent 232013c05b
commit 32be65a8b4
Notes: sideshowbarker 2024-07-18 10:30:05 +09:00
9 changed files with 181 additions and 2 deletions

View file

@ -33,6 +33,17 @@ void ServerConnection::declaration_location(const GUI::AutocompleteProvider::Pro
m_current_language_client->declaration_found(location.file, location.line, location.column);
}
void ServerConnection::parameters_hint_result(Vector<String> const& params, int argument_index)
{
if (!m_current_language_client) {
dbgln("Language Server connection has no attached language client");
return;
}
VERIFY(argument_index >= 0);
m_current_language_client->parameters_hint_result(params, static_cast<size_t>(argument_index));
}
void ServerConnection::die()
{
VERIFY(m_wrapper);
@ -112,6 +123,14 @@ void LanguageClient::search_declaration(const String& path, size_t line, size_t
m_connection_wrapper.connection()->async_find_declaration(GUI::AutocompleteProvider::ProjectLocation { path, line, column });
}
void LanguageClient::get_parameters_hint(const String& path, size_t line, size_t column)
{
if (!m_connection_wrapper.connection())
return;
set_active_client();
m_connection_wrapper.connection()->async_get_parameters_hint(GUI::AutocompleteProvider::ProjectLocation { path, line, column });
}
void LanguageClient::declaration_found(const String& file, size_t line, size_t column) const
{
if (!on_declaration_found) {
@ -121,6 +140,15 @@ void LanguageClient::declaration_found(const String& file, size_t line, size_t c
on_declaration_found(file, line, column);
}
void LanguageClient::parameters_hint_result(Vector<String> const& params, size_t argument_index) const
{
if (!on_function_parameters_hint_result) {
dbgln("on_function_parameters_hint_result callback is not set");
return;
}
on_function_parameters_hint_result(params, argument_index);
}
void ServerConnectionInstances::set_instance_for_language(const String& language_name, NonnullOwnPtr<ServerConnectionWrapper>&& connection_wrapper)
{
s_instance_for_language.set(language_name, move(connection_wrapper));