LanguageClient: Request semantic tokens right away on document save

There's a good argument to be made that a doument save should bypass the
usual waiting period for requesting new semantic tokens.

Fixes: QTCREATORBUG-27403
Change-Id: I8355147116bccdcbcd4f6689b4d9c7a282d324be
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2022-05-20 15:27:32 +02:00
parent b05fc053ef
commit 2c24dc03ac
2 changed files with 6 additions and 4 deletions

View File

@@ -482,12 +482,13 @@ void Client::openDocument(TextEditor::TextDocument *document)
} }
} }
void Client::sendMessage(const JsonRpcMessage &message, SendDocUpdates sendUpdates) void Client::sendMessage(const JsonRpcMessage &message, SendDocUpdates sendUpdates,
Schedule semanticTokensSchedule)
{ {
QTC_ASSERT(m_clientInterface, return); QTC_ASSERT(m_clientInterface, return);
QTC_ASSERT(m_state == Initialized, return); QTC_ASSERT(m_state == Initialized, return);
if (sendUpdates == SendDocUpdates::Send) if (sendUpdates == SendDocUpdates::Send)
sendPostponedDocumentUpdates(Schedule::Delayed); sendPostponedDocumentUpdates(semanticTokensSchedule);
if (Utils::optional<ResponseHandler> responseHandler = message.responseHandler()) if (Utils::optional<ResponseHandler> responseHandler = message.responseHandler())
m_responseHandlers[responseHandler->id] = responseHandler->callback; m_responseHandlers[responseHandler->id] = responseHandler->callback;
QString error; QString error;
@@ -749,7 +750,7 @@ void Client::documentContentsSaved(TextEditor::TextDocument *document)
TextDocumentIdentifier(DocumentUri::fromFilePath(document->filePath()))); TextDocumentIdentifier(DocumentUri::fromFilePath(document->filePath())));
if (includeText) if (includeText)
params.setText(document->plainText()); params.setText(document->plainText());
sendMessage(DidSaveTextDocumentNotification(params)); sendMessage(DidSaveTextDocumentNotification(params), SendDocUpdates::Send, Schedule::Now);
} }
void Client::documentWillSave(Core::IDocument *document) void Client::documentWillSave(Core::IDocument *document)

View File

@@ -102,7 +102,8 @@ public:
enum class SendDocUpdates { Send, Ignore }; enum class SendDocUpdates { Send, Ignore };
void sendMessage(const LanguageServerProtocol::JsonRpcMessage &message, void sendMessage(const LanguageServerProtocol::JsonRpcMessage &message,
SendDocUpdates sendUpdates = SendDocUpdates::Send); SendDocUpdates sendUpdates = SendDocUpdates::Send,
Schedule semanticTokensSchedule = Schedule::Delayed);
void cancelRequest(const LanguageServerProtocol::MessageId &id); void cancelRequest(const LanguageServerProtocol::MessageId &id);