forked from qt-creator/qt-creator
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:
@@ -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_state == Initialized, return);
|
||||
if (sendUpdates == SendDocUpdates::Send)
|
||||
sendPostponedDocumentUpdates(Schedule::Delayed);
|
||||
sendPostponedDocumentUpdates(semanticTokensSchedule);
|
||||
if (Utils::optional<ResponseHandler> responseHandler = message.responseHandler())
|
||||
m_responseHandlers[responseHandler->id] = responseHandler->callback;
|
||||
QString error;
|
||||
@@ -749,7 +750,7 @@ void Client::documentContentsSaved(TextEditor::TextDocument *document)
|
||||
TextDocumentIdentifier(DocumentUri::fromFilePath(document->filePath())));
|
||||
if (includeText)
|
||||
params.setText(document->plainText());
|
||||
sendMessage(DidSaveTextDocumentNotification(params));
|
||||
sendMessage(DidSaveTextDocumentNotification(params), SendDocUpdates::Send, Schedule::Now);
|
||||
}
|
||||
|
||||
void Client::documentWillSave(Core::IDocument *document)
|
||||
|
@@ -102,7 +102,8 @@ public:
|
||||
|
||||
enum class SendDocUpdates { Send, Ignore };
|
||||
void sendMessage(const LanguageServerProtocol::JsonRpcMessage &message,
|
||||
SendDocUpdates sendUpdates = SendDocUpdates::Send);
|
||||
SendDocUpdates sendUpdates = SendDocUpdates::Send,
|
||||
Schedule semanticTokensSchedule = Schedule::Delayed);
|
||||
|
||||
void cancelRequest(const LanguageServerProtocol::MessageId &id);
|
||||
|
||||
|
Reference in New Issue
Block a user