2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2019 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2019-05-17 14:37:06 +02:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2021-09-17 11:52:32 +02:00
|
|
|
#include "languageclient_global.h"
|
|
|
|
|
|
|
|
|
|
#include <languageserverprotocol/languagefeatures.h>
|
2019-05-17 14:37:06 +02:00
|
|
|
#include <texteditor/codeassist/completionassistprovider.h>
|
2021-09-17 11:52:32 +02:00
|
|
|
#include <texteditor/codeassist/iassistprocessor.h>
|
2019-05-17 14:37:06 +02:00
|
|
|
|
2021-09-17 11:52:32 +02:00
|
|
|
#include <QPointer>
|
|
|
|
|
|
2022-08-26 10:30:00 +02:00
|
|
|
#include <optional>
|
|
|
|
|
|
2021-06-18 16:30:03 +02:00
|
|
|
namespace TextEditor { class IAssistProposal; }
|
|
|
|
|
|
2019-05-17 14:37:06 +02:00
|
|
|
namespace LanguageClient {
|
|
|
|
|
|
|
|
|
|
class Client;
|
|
|
|
|
|
2021-09-17 11:52:32 +02:00
|
|
|
class LANGUAGECLIENT_EXPORT FunctionHintAssistProvider : public TextEditor::CompletionAssistProvider
|
2019-05-17 14:37:06 +02:00
|
|
|
{
|
2019-09-10 08:03:36 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
2019-05-17 14:37:06 +02:00
|
|
|
public:
|
|
|
|
|
explicit FunctionHintAssistProvider(Client *client);
|
|
|
|
|
|
2021-09-15 07:04:12 +02:00
|
|
|
TextEditor::IAssistProcessor *createProcessor(const TextEditor::AssistInterface *) const override;
|
2019-05-17 14:37:06 +02:00
|
|
|
RunType runType() const override;
|
|
|
|
|
|
|
|
|
|
int activationCharSequenceLength() const override;
|
|
|
|
|
bool isActivationCharSequence(const QString &sequence) const override;
|
|
|
|
|
bool isContinuationChar(const QChar &c) const override;
|
|
|
|
|
|
2022-08-26 10:30:00 +02:00
|
|
|
void setTriggerCharacters(const std::optional<QList<QString>> &triggerChars);
|
2021-06-18 16:30:03 +02:00
|
|
|
|
2019-05-17 14:37:06 +02:00
|
|
|
private:
|
|
|
|
|
QList<QString> m_triggerChars;
|
|
|
|
|
int m_activationCharSequenceLength = 0;
|
|
|
|
|
Client *m_client = nullptr; // not owned
|
|
|
|
|
};
|
|
|
|
|
|
2021-09-17 11:52:32 +02:00
|
|
|
class LANGUAGECLIENT_EXPORT FunctionHintProcessor : public TextEditor::IAssistProcessor
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-09-15 11:35:19 +02:00
|
|
|
explicit FunctionHintProcessor(Client *client);
|
2021-09-17 11:52:32 +02:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
QPointer<Client> m_client;
|
2022-08-26 10:30:00 +02:00
|
|
|
std::optional<LanguageServerProtocol::MessageId> m_currentRequest;
|
2021-09-17 11:52:32 +02:00
|
|
|
int m_pos = -1;
|
|
|
|
|
};
|
|
|
|
|
|
2019-05-17 14:37:06 +02:00
|
|
|
} // namespace LanguageClient
|