ClangCodeModel: Get document symbols immediately

... when doing a decl/def switch via clangd.
The delay is fine for e.g. populating the outline, but shouldn't be used
when dealing with explicit user requests.

Change-Id: I0350ed6daf8220ec3b702a3876fbf0f726da8a67
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2021-09-14 17:00:16 +02:00
parent 4324f3e8c1
commit bcfe229f8b
8 changed files with 27 additions and 15 deletions

View File

@@ -94,7 +94,7 @@ Client::Client(BaseClientInterface *clientInterface)
m_documentUpdateTimer.setSingleShot(true);
m_documentUpdateTimer.setInterval(500);
connect(&m_documentUpdateTimer, &QTimer::timeout, this,
[this] { sendPostponedDocumentUpdates(SemanticTokensUpdateMode::Now); });
[this] { sendPostponedDocumentUpdates(Schedule::Now); });
m_contentHandler.insert(JsonRpcMessageHandler::jsonRpcMimeType(),
&JsonRpcMessageHandler::parseContent);
@@ -410,7 +410,7 @@ void Client::sendContent(const IContent &content, SendDocUpdates sendUpdates)
QTC_ASSERT(m_clientInterface, return);
QTC_ASSERT(m_state == Initialized, return);
if (sendUpdates == SendDocUpdates::Send)
sendPostponedDocumentUpdates(SemanticTokensUpdateMode::Delayed);
sendPostponedDocumentUpdates(Schedule::Delayed);
if (Utils::optional<ResponseHandler> responseHandler = content.responseHandler())
m_responseHandlers[responseHandler->id] = responseHandler->callback;
QString error;
@@ -1216,7 +1216,7 @@ void Client::resetAssistProviders(TextEditor::TextDocument *document)
document->setQuickFixAssistProvider(providers.quickFixAssistProvider);
}
void Client::sendPostponedDocumentUpdates(SemanticTokensUpdateMode semanticTokensUpdateMode)
void Client::sendPostponedDocumentUpdates(Schedule semanticTokensSchedule)
{
m_documentUpdateTimer.stop();
if (m_documentsToUpdate.empty())
@@ -1251,14 +1251,17 @@ void Client::sendPostponedDocumentUpdates(SemanticTokensUpdateMode semanticToken
if (currentWidget && currentWidget->textDocument() == update.document)
requestDocumentHighlights(currentWidget);
if (semanticTokensUpdateMode == SemanticTokensUpdateMode::Now) {
switch (semanticTokensSchedule) {
case Schedule::Now:
m_tokenSupport.updateSemanticTokens(update.document);
} else {
break;
case Schedule::Delayed:
QTimer::singleShot(m_documentUpdateTimer.interval(), this,
[this, doc = QPointer(update.document)] {
if (doc && m_documentsToUpdate.find(doc) == m_documentsToUpdate.end())
m_tokenSupport.updateSemanticTokens(doc);
});
break;
}
}
}