aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/codeassist/iassistprocessor.h
blob: 1835b906516dba48859b18253059ff51ba4341f0 (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
// Copyright (C) 2016 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 <texteditor/texteditor_global.h>

#include <functional>

namespace TextEditor {

class AssistInterface;
class IAssistProposal;

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

    virtual IAssistProposal *immediateProposal(const AssistInterface *) { return nullptr; }
    virtual IAssistProposal *perform(const AssistInterface *interface) = 0;

    void setAsyncProposalAvailable(IAssistProposal *proposal);

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

    virtual bool running() { return false; }
    virtual bool needsRestart() const { return false; }
    virtual void cancel() {}

private:
    AsyncCompletionsAvailableHandler m_asyncCompletionsAvailableHandler;
};

} // TextEditor