blob: 01037606465d1ce6ae8aa63cd967d1d6a6d8c448 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// 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
#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 {
class Client;
class LANGUAGECLIENT_EXPORT FunctionHintAssistProvider : public TextEditor::CompletionAssistProvider
{
Q_OBJECT
public:
explicit FunctionHintAssistProvider(Client *client);
TextEditor::IAssistProcessor *createProcessor(const TextEditor::AssistInterface *) const override;
RunType runType() const override;
int activationCharSequenceLength() const override;
bool isActivationCharSequence(const QString &sequence) const override;
bool isContinuationChar(const QChar &c) const override;
void setTriggerCharacters(const Utils::optional<QList<QString>> &triggerChars);
private:
QList<QString> m_triggerChars;
int m_activationCharSequenceLength = 0;
Client *m_client = nullptr; // not owned
};
class LANGUAGECLIENT_EXPORT FunctionHintProcessor : public TextEditor::IAssistProcessor
{
public:
explicit FunctionHintProcessor(Client *client);
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;
Utils::optional<LanguageServerProtocol::MessageId> m_currentRequest;
int m_pos = -1;
};
} // namespace LanguageClient
|