aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/cppcompletionassistprocessor.h
blob: 4e172cc0338112b2804f1d624662ec84b3b8ca5f (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
// 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 "cppeditor_global.h"

#include <texteditor/codeassist/iassistprocessor.h>
#include <texteditor/snippets/snippetassistcollector.h>

#include <functional>

QT_BEGIN_NAMESPACE
class QTextDocument;
QT_END_NAMESPACE

namespace CPlusPlus { struct LanguageFeatures; }

namespace CppEditor {

class CPPEDITOR_EXPORT CppCompletionAssistProcessor : public TextEditor::IAssistProcessor
{
public:
    explicit CppCompletionAssistProcessor(int snippetItemOrder = 0);

    static const QStringList preprocessorCompletions();

protected:
    void addSnippets();

    using DotAtIncludeCompletionHandler = std::function<void(int &startPosition, unsigned *kind)>;
    static void startOfOperator(QTextDocument *textDocument,
                                int positionInDocument,
                                unsigned *kind,
                                int &start,
                                const CPlusPlus::LanguageFeatures &languageFeatures,
                                bool adjustForQt5SignalSlotCompletion = false,
                                DotAtIncludeCompletionHandler dotAtIncludeCompletionHandler
                                    = DotAtIncludeCompletionHandler());

    int m_positionForProposal = -1;
    QList<TextEditor::AssistProposalItemInterface *> m_completions;
    TextEditor::IAssistProposal *m_hintProposal = nullptr;

private:
    TextEditor::SnippetAssistCollector m_snippetCollector;
};

} // namespace CppEditor