forked from qt-creator/qt-creator
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:
@@ -285,7 +285,7 @@ private:
|
||||
|
||||
QPointer<QTextDocument> m_document;
|
||||
QPointer<Client> m_client;
|
||||
MessageId m_currentRequest;
|
||||
Utils::optional<MessageId> m_currentRequest;
|
||||
int m_pos = -1;
|
||||
};
|
||||
|
||||
@@ -353,15 +353,15 @@ IAssistProposal *LanguageClientCompletionAssistProcessor::perform(const AssistIn
|
||||
|
||||
bool LanguageClientCompletionAssistProcessor::running()
|
||||
{
|
||||
return m_currentRequest.isValid();
|
||||
return m_currentRequest.has_value();
|
||||
}
|
||||
|
||||
void LanguageClientCompletionAssistProcessor::cancel()
|
||||
{
|
||||
if (running()) {
|
||||
m_client->cancelRequest(m_currentRequest);
|
||||
m_client->cancelRequest(m_currentRequest.value());
|
||||
m_client->removeAssistProcessor(this);
|
||||
m_currentRequest = MessageId();
|
||||
m_currentRequest.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ void LanguageClientCompletionAssistProcessor::handleCompletionResponse(
|
||||
{
|
||||
// We must report back to the code assistant under all circumstances
|
||||
qCDebug(LOGLSPCOMPLETION) << QTime::currentTime() << " : got completions";
|
||||
m_currentRequest = MessageId();
|
||||
m_currentRequest.reset();
|
||||
QTC_ASSERT(m_client, setAsyncProposalAvailable(nullptr); return);
|
||||
if (auto error = response.error())
|
||||
m_client->log(error.value());
|
||||
|
||||
@@ -57,7 +57,9 @@ private:
|
||||
|
||||
QString FunctionHintProposalModel::text(int index) const
|
||||
{
|
||||
return m_sigis.signatures().size() > index ? m_sigis.signatures().at(index).label() : QString();
|
||||
if (index < 0 || m_sigis.signatures().size() >= index)
|
||||
return {};
|
||||
return m_sigis.signatures().at(index).label();
|
||||
}
|
||||
|
||||
class FunctionHintProcessor : public IAssistProcessor
|
||||
@@ -65,7 +67,7 @@ class FunctionHintProcessor : public IAssistProcessor
|
||||
public:
|
||||
explicit FunctionHintProcessor(Client *client) : m_client(client) {}
|
||||
IAssistProposal *perform(const AssistInterface *interface) override;
|
||||
bool running() override { return m_currentRequest.isValid(); }
|
||||
bool running() override { return m_currentRequest.has_value(); }
|
||||
bool needsRestart() const override { return true; }
|
||||
void cancel() override;
|
||||
|
||||
@@ -73,7 +75,7 @@ private:
|
||||
void handleSignatureResponse(const SignatureHelpRequest::Response &response);
|
||||
|
||||
QPointer<Client> m_client;
|
||||
MessageId m_currentRequest;
|
||||
Utils::optional<MessageId> m_currentRequest;
|
||||
int m_pos = -1;
|
||||
};
|
||||
|
||||
@@ -95,15 +97,15 @@ IAssistProposal *FunctionHintProcessor::perform(const AssistInterface *interface
|
||||
void FunctionHintProcessor::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 FunctionHintProcessor::handleSignatureResponse(const SignatureHelpRequest::Response &response)
|
||||
{
|
||||
m_currentRequest = MessageId();
|
||||
m_currentRequest.reset();
|
||||
if (auto error = response.error())
|
||||
m_client->log(error.value());
|
||||
m_client->removeAssistProcessor(this);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user