forked from qt-creator/qt-creator
LanguageClient: export completion assistant
Change-Id: I2baaf14e9d60fb70e1ba84c1043a89db2db97c3d Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -34,7 +34,6 @@
|
|||||||
#include <texteditor/codeassist/assistproposalitem.h>
|
#include <texteditor/codeassist/assistproposalitem.h>
|
||||||
#include <texteditor/codeassist/genericproposal.h>
|
#include <texteditor/codeassist/genericproposal.h>
|
||||||
#include <texteditor/codeassist/genericproposalmodel.h>
|
#include <texteditor/codeassist/genericproposalmodel.h>
|
||||||
#include <texteditor/codeassist/iassistprocessor.h>
|
|
||||||
#include <texteditor/snippets/snippet.h>
|
#include <texteditor/snippets/snippet.h>
|
||||||
#include <texteditor/snippets/snippetassistcollector.h>
|
#include <texteditor/snippets/snippetassistcollector.h>
|
||||||
#include <texteditor/texteditorsettings.h>
|
#include <texteditor/texteditorsettings.h>
|
||||||
@@ -322,36 +321,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class LanguageClientCompletionAssistProcessor final : public IAssistProcessor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
LanguageClientCompletionAssistProcessor(Client *client,
|
|
||||||
const CompletionItemsTransformer &itemsTransformer,
|
|
||||||
const CompletionApplyHelper &applyHelper,
|
|
||||||
const ProposalHandler &proposalHandler,
|
|
||||||
const QString &snippetsGroup);
|
|
||||||
~LanguageClientCompletionAssistProcessor() override;
|
|
||||||
IAssistProposal *perform(const AssistInterface *interface) override;
|
|
||||||
bool running() override;
|
|
||||||
bool needsRestart() const override { return true; }
|
|
||||||
void cancel() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void handleCompletionResponse(const CompletionRequest::Response &response);
|
|
||||||
|
|
||||||
QPointer<QTextDocument> m_document;
|
|
||||||
Utils::FilePath m_filePath;
|
|
||||||
QPointer<Client> m_client;
|
|
||||||
Utils::optional<MessageId> m_currentRequest;
|
|
||||||
QMetaObject::Connection m_postponedUpdateConnection;
|
|
||||||
const CompletionItemsTransformer m_itemsTransformer;
|
|
||||||
const CompletionApplyHelper m_applyHelper;
|
|
||||||
const ProposalHandler m_proposalHandler;
|
|
||||||
const QString m_snippetsGroup;
|
|
||||||
int m_pos = -1;
|
|
||||||
int m_basePos = -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
LanguageClientCompletionAssistProcessor::LanguageClientCompletionAssistProcessor(Client *client,
|
LanguageClientCompletionAssistProcessor::LanguageClientCompletionAssistProcessor(Client *client,
|
||||||
const CompletionItemsTransformer &itemsTransformer, const CompletionApplyHelper &applyHelper,
|
const CompletionItemsTransformer &itemsTransformer, const CompletionApplyHelper &applyHelper,
|
||||||
const ProposalHandler &proposalHandler, const QString &snippetsGroup)
|
const ProposalHandler &proposalHandler, const QString &snippetsGroup)
|
||||||
|
@@ -25,8 +25,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "languageclient_global.h"
|
||||||
|
|
||||||
#include <languageserverprotocol/completion.h>
|
#include <languageserverprotocol/completion.h>
|
||||||
#include <texteditor/codeassist/completionassistprovider.h>
|
#include <texteditor/codeassist/completionassistprovider.h>
|
||||||
|
#include <texteditor/codeassist/iassistprocessor.h>
|
||||||
|
|
||||||
#include <utils/optional.h>
|
#include <utils/optional.h>
|
||||||
|
|
||||||
@@ -49,7 +52,8 @@ using CompletionApplyHelper = std::function<void(
|
|||||||
TextEditor::TextDocumentManipulatorInterface &, QChar)>;
|
TextEditor::TextDocumentManipulatorInterface &, QChar)>;
|
||||||
using ProposalHandler = std::function<void(TextEditor::IAssistProposal *)>;
|
using ProposalHandler = std::function<void(TextEditor::IAssistProposal *)>;
|
||||||
|
|
||||||
class LanguageClientCompletionAssistProvider : public TextEditor::CompletionAssistProvider
|
class LANGUAGECLIENT_EXPORT LanguageClientCompletionAssistProvider
|
||||||
|
: public TextEditor::CompletionAssistProvider
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -80,4 +84,35 @@ private:
|
|||||||
Client *m_client = nullptr; // not owned
|
Client *m_client = nullptr; // not owned
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class LANGUAGECLIENT_EXPORT LanguageClientCompletionAssistProcessor
|
||||||
|
: public TextEditor::IAssistProcessor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LanguageClientCompletionAssistProcessor(Client *client,
|
||||||
|
const CompletionItemsTransformer &itemsTransformer,
|
||||||
|
const CompletionApplyHelper &applyHelper,
|
||||||
|
const ProposalHandler &proposalHandler,
|
||||||
|
const QString &snippetsGroup);
|
||||||
|
~LanguageClientCompletionAssistProcessor() override;
|
||||||
|
TextEditor::IAssistProposal *perform(const TextEditor::AssistInterface *interface) override;
|
||||||
|
bool running() override;
|
||||||
|
bool needsRestart() const override { return true; }
|
||||||
|
void cancel() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void handleCompletionResponse(const LanguageServerProtocol::CompletionRequest::Response &response);
|
||||||
|
|
||||||
|
QPointer<QTextDocument> m_document;
|
||||||
|
Utils::FilePath m_filePath;
|
||||||
|
QPointer<Client> m_client;
|
||||||
|
Utils::optional<LanguageServerProtocol::MessageId> m_currentRequest;
|
||||||
|
QMetaObject::Connection m_postponedUpdateConnection;
|
||||||
|
const CompletionItemsTransformer m_itemsTransformer;
|
||||||
|
const CompletionApplyHelper m_applyHelper;
|
||||||
|
const ProposalHandler m_proposalHandler;
|
||||||
|
const QString m_snippetsGroup;
|
||||||
|
int m_pos = -1;
|
||||||
|
int m_basePos = -1;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace LanguageClient
|
} // namespace LanguageClient
|
||||||
|
Reference in New Issue
Block a user