mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 07:27:45 +00:00
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:
parent
232013c05b
commit
32be65a8b4
9 changed files with 181 additions and 2 deletions
|
@ -118,4 +118,29 @@ void ClientConnection::find_declaration(GUI::AutocompleteProvider::ProjectLocati
|
|||
async_declaration_location(GUI::AutocompleteProvider::ProjectLocation { decl_location.value().file, decl_location.value().line, decl_location.value().column });
|
||||
}
|
||||
|
||||
void ClientConnection::get_parameters_hint(GUI::AutocompleteProvider::ProjectLocation const& location)
|
||||
{
|
||||
dbgln_if(LANGUAGE_SERVER_DEBUG, "GetFunctionParams: {} {}:{}", location.file, location.line, location.column);
|
||||
auto document = m_filedb.get(location.file);
|
||||
if (!document) {
|
||||
dbgln("file {} has not been opened", location.file);
|
||||
return;
|
||||
}
|
||||
|
||||
GUI::TextPosition identifier_position = { (size_t)location.line, (size_t)location.column };
|
||||
auto params = m_autocomplete_engine->get_function_params_hint(location.file, identifier_position);
|
||||
if (!params.has_value()) {
|
||||
dbgln("could not get parameters hint");
|
||||
return;
|
||||
}
|
||||
|
||||
dbgln_if(LANGUAGE_SERVER_DEBUG, "parameters hint:");
|
||||
for (auto& param : params->params) {
|
||||
dbgln_if(LANGUAGE_SERVER_DEBUG, "{}", param);
|
||||
}
|
||||
dbgln_if(LANGUAGE_SERVER_DEBUG, "Parameter index: {}", params->current_index);
|
||||
|
||||
async_parameters_hint_result(params->params, params->current_index);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue