File indexing completed on 2024-05-05 04:39:24

0001 /*
0002     SPDX-FileCopyrightText: 2008 Aleix Pol <aleixpol@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef CMAKECODECOMPLETION_H
0008 #define CMAKECODECOMPLETION_H
0009 
0010 #include <language/duchain/duchainpointer.h>
0011 #include <language/duchain/declaration.h>
0012 
0013 #include <KTextEditor/CodeCompletionModel>
0014 
0015 #include <QStringList>
0016 
0017 class CMakeDocumentation;
0018 namespace KTextEditor { class Document; class Range; }
0019 
0020 class CMakeCodeCompletionModel : public KTextEditor::CodeCompletionModel
0021 {
0022         Q_OBJECT
0023     public:
0024         explicit CMakeCodeCompletionModel(QObject *parent);
0025 
0026         void completionInvoked(KTextEditor::View* view, const KTextEditor::Range& range, InvocationType invocationType) override;
0027         QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const override;
0028         void executeCompletionItem(KTextEditor::View* view, const KTextEditor::Range& word, const QModelIndex& index) const override;
0029     private:
0030         enum Type { Command, Variable, Macro, Path, Target };
0031         Type indexType(int row) const;
0032         static QVector<QString> s_commands;
0033         QList< KDevelop::IndexedDeclaration > m_declarations;
0034         bool m_inside;
0035         QStringList m_paths;
0036 };
0037 
0038 #endif