Bladeren bron

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.
Itamar 4 jaren geleden
bovenliggende
commit
5adfcd54d8

+ 6 - 0
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));

+ 1 - 1
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)
 {
 }