1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:27:35 +00:00

HackStudio: Support searching symbol declarations in the Locator

The Locator now keeps a cache of the declared symbol in a document.
The language client updates that cache whenever it gets an update from
the language server about declared symbols.

This allows searching for symbol declarations in the Locator, in
addition to file names.

Closes #5478
This commit is contained in:
Itamar 2021-02-27 09:50:02 +02:00 committed by Andreas Kling
parent a94b5376bc
commit 54bc9114b3
16 changed files with 140 additions and 30 deletions

View file

@ -25,6 +25,8 @@
*/
#include "LanguageClient.h"
#include "HackStudio.h"
#include "Locator.h"
#include <AK/String.h>
#include <AK/Vector.h>
#include <DevTools/HackStudio/LanguageServers/LanguageServerEndpoint.h>
@ -50,11 +52,6 @@ void ServerConnection::handle(const Messages::LanguageClient::DeclarationLocatio
m_language_client->declaration_found(message.location().file, message.location().line, message.location().column);
}
void ServerConnection::handle(const Messages::LanguageClient::DeclarationList& message)
{
(void)message;
}
void ServerConnection::die()
{
dbgln("ServerConnection::die()");
@ -158,6 +155,10 @@ void ServerConnection::remove_instance_for_project(const String& project_path)
auto key = LexicalPath { project_path }.string();
s_instances_for_projects.remove(key);
}
void ServerConnection::handle(const Messages::LanguageClient::DeclarationsInDocument& message)
{
locator().set_declared_symbols(message.filename(), message.declarations());
}
void LanguageClient::search_declaration(const String& path, size_t line, size_t column)
{
@ -173,7 +174,6 @@ void LanguageClient::declaration_found(const String& file, size_t line, size_t c
dbgln("on_declaration_found callback is not set");
return;
}
dbgln("calling on_declaration_found");
on_declaration_found(file, line, column);
}