summaryrefslogtreecommitdiff
path: root/src/plugins/languageclient/languageclientfunctionhint.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/languageclient/languageclientfunctionhint.cpp')
-rw-r--r--src/plugins/languageclient/languageclientfunctionhint.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/plugins/languageclient/languageclientfunctionhint.cpp b/src/plugins/languageclient/languageclientfunctionhint.cpp
index e49f5fc99c..37635799e8 100644
--- a/src/plugins/languageclient/languageclientfunctionhint.cpp
+++ b/src/plugins/languageclient/languageclientfunctionhint.cpp
@@ -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);