summaryrefslogtreecommitdiff
path: root/src/plugins/texteditor/codeassist/iassistprocessor.h
blob: 09048ee4db0510bd301a3e63c90b3f3a5fb4a569 (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <texteditor/texteditor_global.h>

#include <functional>
#include <memory>

namespace TextEditor {

class AssistInterface;
class IAssistProposal;

class TEXTEDITOR_EXPORT IAssistProcessor
{
public:
    IAssistProcessor();
    virtual ~IAssistProcessor();

    IAssistProposal *start(std::unique_ptr<AssistInterface> &&interface);

    // Internal, used by CodeAssist
    using AsyncCompletionsAvailableHandler
        = std::function<void (IAssistProposal *proposal)>;
    void setAsyncCompletionAvailableHandler(const AsyncCompletionsAvailableHandler &handler);
    void setAsyncProposalAvailable(IAssistProposal *proposal);

    virtual bool running();
    virtual bool needsRestart() const;
    virtual void cancel();

#ifdef WITH_TESTS
    void setupAssistInterface(std::unique_ptr<AssistInterface> &&interface);
#endif

protected:
    virtual IAssistProposal *perform() = 0;
    AssistInterface *interface();
    const AssistInterface *interface() const;

private:
    AsyncCompletionsAvailableHandler m_asyncCompletionsAvailableHandler;
    std::unique_ptr<AssistInterface> m_interface;
};

} // TextEditor