LSP: fix codeassists running check

Since MessageId is always valid (needs to be fixed separately)
use an optional to store whether we have a request running.

Change-Id: I7a1f136a09d776b33509bc914247d11076abeaa5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2020-05-14 08:15:39 +02:00
parent 32d29f5a11
commit f3407bb0ca
3 changed files with 18 additions and 16 deletions

View File

@@ -84,7 +84,7 @@ class LanguageClientQuickFixAssistProcessor : public IAssistProcessor
{
public:
explicit LanguageClientQuickFixAssistProcessor(Client *client) : m_client(client) {}
bool running() override { return m_currentRequest.isValid(); }
bool running() override { return m_currentRequest.has_value(); }
IAssistProposal *perform(const AssistInterface *interface) override;
void cancel() override;
@@ -93,7 +93,7 @@ private:
QSharedPointer<const AssistInterface> m_assistInterface;
Client *m_client = nullptr; // not owned
MessageId m_currentRequest;
Utils::optional<MessageId> m_currentRequest;
};
IAssistProposal *LanguageClientQuickFixAssistProcessor::perform(const AssistInterface *interface)
@@ -131,16 +131,16 @@ IAssistProposal *LanguageClientQuickFixAssistProcessor::perform(const AssistInte
void LanguageClientQuickFixAssistProcessor::cancel()
{
if (running()) {
m_client->cancelRequest(m_currentRequest);
m_client->cancelRequest(m_currentRequest.value());
m_client->removeAssistProcessor(this);
m_currentRequest = MessageId();
m_currentRequest.reset();
}
}
void LanguageClientQuickFixAssistProcessor::handleCodeActionResponse(
const CodeActionRequest::Response &response)
{
m_currentRequest = MessageId();
m_currentRequest.reset();
if (const Utils::optional<CodeActionRequest::Response::Error> &error = response.error())
m_client->log(*error);
QuickFixOperations ops;