File indexing completed on 2024-04-28 04:38:07

0001 /*
0002     SPDX-FileCopyrightText: 2013 Olivier de Gaalon <olivier.jg@gmail.com>
0003     SPDX-FileCopyrightText: 2013 Milian Wolff <mail@milianw.de>
0004     SPDX-FileCopyrightText: 2014 Kevin Funk <kfunk@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef KDEVCLANGSUPPORT_H
0010 #define KDEVCLANGSUPPORT_H
0011 
0012 #include <interfaces/iplugin.h>
0013 #include <language/interfaces/ilanguagesupport.h>
0014 #include <interfaces/ibuddydocumentfinder.h>
0015 
0016 #include <QVariantList>
0017 
0018 class ClangIndex;
0019 class ClangRefactoring;
0020 namespace KDevelop
0021 {
0022 class IDocument;
0023 }
0024 
0025 namespace KTextEditor
0026 {
0027 class View;
0028 class Document;
0029 }
0030 
0031 class ClangSupport : public KDevelop::IPlugin, public KDevelop::ILanguageSupport, public KDevelop::IBuddyDocumentFinder
0032 {
0033     Q_OBJECT
0034     Q_INTERFACES(KDevelop::ILanguageSupport)
0035 
0036 public:
0037     explicit ClangSupport(QObject *parent, const QVariantList& args = QVariantList());
0038     ~ClangSupport() override;
0039 
0040     /** Name Of the Language */
0041     QString name() const override;
0042 
0043     /** Parsejob used by background parser to parse given url */
0044     KDevelop::ParseJob *createParseJob(const KDevelop::IndexedString &url) override;
0045 
0046     /** the code highlighter */
0047     KDevelop::ICodeHighlighting* codeHighlighting() const override;
0048     KDevelop::BasicRefactoring* refactoring() const override;
0049     KDevelop::ICreateClassHelper* createClassHelper() const override;
0050 
0051     void createActionsForMainWindow(Sublime::MainWindow* window, QString& xmlFile, KActionCollection& actions) override;
0052     KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context, QWidget* parent) override;
0053 
0054     KTextEditor::Range specialLanguageObjectRange(const QUrl &url, const KTextEditor::Cursor& position) override;
0055     QPair<QUrl, KTextEditor::Cursor> specialLanguageObjectJumpCursor(const QUrl &url, const KTextEditor::Cursor& position) override;
0056     QPair<QWidget*, KTextEditor::Range> specialLanguageObjectNavigationWidget(const QUrl& url,
0057                                                                               const KTextEditor::Cursor& position) override;
0058 
0059     QString indentationSample() const override;
0060 
0061     ClangIndex* index();
0062 
0063     KDevelop::TopDUContext* standardContext(const QUrl &url, bool proxyContext = false) override;
0064 
0065     KDevelop::ConfigPage* configPage(int number, QWidget *parent) override;
0066 
0067     int configPages() const override;
0068 
0069     int suggestedReparseDelayForChange(KTextEditor::Document* doc, const KTextEditor::Range& changedRange,
0070                                        const QString& changedText, bool removal) const override;
0071 
0072     //BEGIN IBuddyDocumentFinder
0073 
0074     bool areBuddies(const QUrl &url1, const QUrl& url2) override;
0075     bool buddyOrder(const QUrl &url1, const QUrl& url2) override;
0076     QVector<QUrl> potentialBuddies(const QUrl& url) const override;
0077 
0078     //END IBuddyDocumentFinder
0079 
0080 private Q_SLOTS:
0081     void documentActivated(KDevelop::IDocument* doc);
0082     void disableKeywordCompletion(KTextEditor::View* view);
0083     void enableKeywordCompletion(KTextEditor::View* view);
0084 
0085 private:
0086     KDevelop::ICodeHighlighting *m_highlighting;
0087     ClangRefactoring *m_refactoring;
0088     QScopedPointer<ClangIndex> m_index;
0089 };
0090 
0091 #endif
0092