forked from qt-creator/qt-creator
LanguageClient: cancel running semantic token request
... when we are about to send a new semantic token request. Change-Id: Ibd421dd29bf3ea0e2b502c227341ff03259b2370 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -88,6 +88,7 @@ void SemanticTokenSupport::reloadSemanticTokensImpl(TextDocument *textDocument,
|
|||||||
filePath,
|
filePath,
|
||||||
documentVersion = m_client->documentVersion(filePath)](
|
documentVersion = m_client->documentVersion(filePath)](
|
||||||
const SemanticTokensFullRequest::Response &response) {
|
const SemanticTokensFullRequest::Response &response) {
|
||||||
|
m_runningRequests.remove(filePath);
|
||||||
if (const auto error = response.error()) {
|
if (const auto error = response.error()) {
|
||||||
qCDebug(LOGLSPHIGHLIGHT)
|
qCDebug(LOGLSPHIGHLIGHT)
|
||||||
<< "received error" << error->code() << error->message() << "for" << filePath;
|
<< "received error" << error->code() << error->message() << "for" << filePath;
|
||||||
@@ -120,6 +121,10 @@ void SemanticTokenSupport::reloadSemanticTokensImpl(TextDocument *textDocument,
|
|||||||
request.setResponseCallback(responseCallback);
|
request.setResponseCallback(responseCallback);
|
||||||
qCDebug(LOGLSPHIGHLIGHT) << "Requesting all tokens for" << filePath << "with version"
|
qCDebug(LOGLSPHIGHLIGHT) << "Requesting all tokens for" << filePath << "with version"
|
||||||
<< m_client->documentVersion(filePath);
|
<< m_client->documentVersion(filePath);
|
||||||
|
MessageId &id = m_runningRequests[filePath];
|
||||||
|
if (id.isValid())
|
||||||
|
m_client->cancelRequest(id);
|
||||||
|
id = request.id();
|
||||||
m_client->sendMessage(request);
|
m_client->sendMessage(request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,6 +156,7 @@ void SemanticTokenSupport::updateSemanticTokensImpl(TextDocument *textDocument,
|
|||||||
request.setResponseCallback(
|
request.setResponseCallback(
|
||||||
[this, filePath, documentVersion, remainingRerequests](
|
[this, filePath, documentVersion, remainingRerequests](
|
||||||
const SemanticTokensFullDeltaRequest::Response &response) {
|
const SemanticTokensFullDeltaRequest::Response &response) {
|
||||||
|
m_runningRequests.remove(filePath);
|
||||||
if (const auto error = response.error()) {
|
if (const auto error = response.error()) {
|
||||||
qCDebug(LOGLSPHIGHLIGHT) << "received error" << error->code()
|
qCDebug(LOGLSPHIGHLIGHT) << "received error" << error->code()
|
||||||
<< error->message() << "for" << filePath;
|
<< error->message() << "for" << filePath;
|
||||||
@@ -168,6 +174,10 @@ void SemanticTokenSupport::updateSemanticTokensImpl(TextDocument *textDocument,
|
|||||||
});
|
});
|
||||||
qCDebug(LOGLSPHIGHLIGHT)
|
qCDebug(LOGLSPHIGHLIGHT)
|
||||||
<< "Requesting delta for" << filePath << "with version" << documentVersion;
|
<< "Requesting delta for" << filePath << "with version" << documentVersion;
|
||||||
|
MessageId &id = m_runningRequests[filePath];
|
||||||
|
if (id.isValid())
|
||||||
|
m_client->cancelRequest(id);
|
||||||
|
id = request.id();
|
||||||
m_client->sendMessage(request);
|
m_client->sendMessage(request);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -120,6 +120,7 @@ private:
|
|||||||
QStringList m_tokenTypeStrings;
|
QStringList m_tokenTypeStrings;
|
||||||
QStringList m_tokenModifierStrings;
|
QStringList m_tokenModifierStrings;
|
||||||
QSet<TextEditor::TextDocument *> m_docReloadQueue;
|
QSet<TextEditor::TextDocument *> m_docReloadQueue;
|
||||||
|
QHash<Utils::FilePath, LanguageServerProtocol::MessageId> m_runningRequests;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace LanguageClient
|
} // namespace LanguageClient
|
||||||
|
Reference in New Issue
Block a user