forked from qt-creator/qt-creator
LanguageClient: export FunctionHint code assist
Change-Id: I57a819b11bb2eb44662c98862643146a686a8c06 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -81,25 +81,10 @@ QString FunctionHintProposalModel::text(int index) const
|
||||
+ label.mid(end).toHtmlEscaped();
|
||||
}
|
||||
|
||||
class FunctionHintProcessor : public IAssistProcessor
|
||||
{
|
||||
public:
|
||||
explicit FunctionHintProcessor(Client *client, const ProposalHandler &proposalHandler)
|
||||
: m_client(client), m_proposalHandler(proposalHandler) {}
|
||||
IAssistProposal *perform(const AssistInterface *interface) override;
|
||||
bool running() override { return m_currentRequest.has_value(); }
|
||||
bool needsRestart() const override { return true; }
|
||||
void cancel() override;
|
||||
|
||||
private:
|
||||
void handleSignatureResponse(const SignatureHelpRequest::Response &response);
|
||||
void processProposal(TextEditor::IAssistProposal *proposal);
|
||||
|
||||
QPointer<Client> m_client;
|
||||
const ProposalHandler m_proposalHandler;
|
||||
Utils::optional<MessageId> m_currentRequest;
|
||||
int m_pos = -1;
|
||||
};
|
||||
FunctionHintProcessor::FunctionHintProcessor(Client *client, const ProposalHandler &proposalHandler)
|
||||
: m_client(client)
|
||||
, m_proposalHandler(proposalHandler)
|
||||
{}
|
||||
|
||||
IAssistProposal *FunctionHintProcessor::perform(const AssistInterface *interface)
|
||||
{
|
||||
|
@@ -25,9 +25,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "languageclient_global.h"
|
||||
|
||||
#include <languageserverprotocol/languagefeatures.h>
|
||||
#include <texteditor/codeassist/completionassistprovider.h>
|
||||
#include <texteditor/codeassist/iassistprocessor.h>
|
||||
#include <utils/optional.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
namespace TextEditor { class IAssistProposal; }
|
||||
|
||||
namespace LanguageClient {
|
||||
@@ -36,7 +42,7 @@ class Client;
|
||||
|
||||
using ProposalHandler = std::function<void(TextEditor::IAssistProposal *)>;
|
||||
|
||||
class FunctionHintAssistProvider : public TextEditor::CompletionAssistProvider
|
||||
class LANGUAGECLIENT_EXPORT FunctionHintAssistProvider : public TextEditor::CompletionAssistProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -61,4 +67,24 @@ private:
|
||||
Client *m_client = nullptr; // not owned
|
||||
};
|
||||
|
||||
class LANGUAGECLIENT_EXPORT FunctionHintProcessor : public TextEditor::IAssistProcessor
|
||||
{
|
||||
public:
|
||||
explicit FunctionHintProcessor(Client *client, const ProposalHandler &proposalHandler);
|
||||
TextEditor::IAssistProposal *perform(const TextEditor::AssistInterface *interface) override;
|
||||
bool running() override { return m_currentRequest.has_value(); }
|
||||
bool needsRestart() const override { return true; }
|
||||
void cancel() override;
|
||||
|
||||
private:
|
||||
void handleSignatureResponse(
|
||||
const LanguageServerProtocol::SignatureHelpRequest::Response &response);
|
||||
void processProposal(TextEditor::IAssistProposal *proposal);
|
||||
|
||||
QPointer<Client> m_client;
|
||||
const ProposalHandler m_proposalHandler;
|
||||
Utils::optional<LanguageServerProtocol::MessageId> m_currentRequest;
|
||||
int m_pos = -1;
|
||||
};
|
||||
|
||||
} // namespace LanguageClient
|
||||
|
Reference in New Issue
Block a user