summaryrefslogtreecommitdiff
path: root/Userland/DevTools
diff options
context:
space:
mode:
authorItamar <itamar8910@gmail.com>2021-04-10 17:35:55 +0300
committerAndreas Kling <kling@serenityos.org>2021-04-13 15:16:27 +0200
commit5adfcd54d814af3aae48a6dfef2ebb6576070aac (patch)
tree95a4d6c25ff193f62668467bee6d6b21c26a3377 /Userland/DevTools
parent667926df73881abfdaf4ef827ab90cb788de75ab (diff)
downloadserenity-5adfcd54d814af3aae48a6dfef2ebb6576070aac.zip
LanguageServers: Only notify client about updated declarations
If the declarations haven't changed since we last notified the client, then there's no need to do so.
Diffstat (limited to 'Userland/DevTools')
-rw-r--r--Userland/DevTools/HackStudio/LanguageServers/AutoCompleteEngine.cpp6
-rw-r--r--Userland/DevTools/HackStudio/LanguageServers/Cpp/ParserAutoComplete.cpp2
2 files changed, 7 insertions, 1 deletions
diff --git a/Userland/DevTools/HackStudio/LanguageServers/AutoCompleteEngine.cpp b/Userland/DevTools/HackStudio/LanguageServers/AutoCompleteEngine.cpp
index 718f69a96d..5e8d570805 100644
--- a/Userland/DevTools/HackStudio/LanguageServers/AutoCompleteEngine.cpp
+++ b/Userland/DevTools/HackStudio/LanguageServers/AutoCompleteEngine.cpp
@@ -41,6 +41,12 @@ AutoCompleteEngine::~AutoCompleteEngine()
void AutoCompleteEngine::set_declarations_of_document(const String& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations)
{
VERIFY(set_declarations_of_document_callback);
+
+ // Optimization - Only notify callback if declerations have changed
+ if (auto previous_declarations = m_all_declarations.get(filename); previous_declarations.has_value()) {
+ if (previous_declarations.value() == declarations)
+ return;
+ }
if (m_store_all_declarations)
m_all_declarations.set(filename, declarations);
set_declarations_of_document_callback(m_connection, filename, move(declarations));
diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/ParserAutoComplete.cpp b/Userland/DevTools/HackStudio/LanguageServers/Cpp/ParserAutoComplete.cpp
index dd402047f5..9f269c6659 100644
--- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/ParserAutoComplete.cpp
+++ b/Userland/DevTools/HackStudio/LanguageServers/Cpp/ParserAutoComplete.cpp
@@ -37,7 +37,7 @@
namespace LanguageServers::Cpp {
ParserAutoComplete::ParserAutoComplete(ClientConnection& connection, const FileDB& filedb)
- : AutoCompleteEngine(connection, filedb)
+ : AutoCompleteEngine(connection, filedb, true)
{
}