File indexing completed on 2024-04-21 15:25:28

0001 /*
0002     SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de>
0003     SPDX-FileCopyrightText: 2007 Piyush verma <piyush.verma@gmail.com>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 
0008 #ifndef KDEVPYTHONLANGUAGESUPPORT_H
0009 #define KDEVPYTHONLANGUAGESUPPORT_H
0010 
0011 #include <interfaces/iplugin.h>
0012 #include <interfaces/ilanguagecheck.h>
0013 #include <interfaces/ilanguagecheckprovider.h>
0014 #include <language/interfaces/ilanguagesupport.h>
0015 #include <language/duchain/topducontext.h>
0016 
0017 #include <QVariant>
0018 #include <QProcess>
0019 
0020 namespace KDevelop
0021 {
0022 class ParseJob;
0023 class IDocument;
0024 class ICodeHighlighting;
0025 }
0026 
0027 namespace Python
0028 {
0029 
0030 class Highlighting;
0031 class Refactoring;
0032 class StyleChecking;
0033 
0034 class LanguageSupport
0035     : public KDevelop::IPlugin
0036     , public KDevelop::ILanguageSupport
0037     , public KDevelop::ILanguageCheckProvider
0038 {
0039     Q_OBJECT
0040     Q_INTERFACES( KDevelop::ILanguageSupport )
0041     Q_INTERFACES( KDevelop::ILanguageCheckProvider )
0042 
0043 public:
0044     LanguageSupport( QObject *parent, const QVariantList& args = QVariantList() );
0045     ~LanguageSupport() override;
0046     /*Name Of the Language*/
0047     QString name() const override;
0048     /*Parsejob used by background parser to parse given Url*/
0049     KDevelop::ParseJob *createParseJob( const KDevelop::IndexedString &url ) override;
0050     /*the code highlighter*/
0051     KDevelop::ICodeHighlighting* codeHighlighting() const override;
0052     KDevelop::BasicRefactoring* refactoring() const override;
0053     
0054     KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context, QWidget* parent) override;
0055     
0056     static LanguageSupport* self();
0057 
0058     int suggestedReparseDelayForChange(KTextEditor::Document* doc, const KTextEditor::Range& changedRange,
0059                                        const QString & changedText, bool removal) const override;
0060     
0061     KDevelop::SourceFormatterItemList sourceFormatterItems() const override;
0062 
0063     /// Tells whether this plugin is enabled for the given file.
0064     static bool enabledForFile(const QUrl& url);
0065 
0066     QList<KDevelop::ILanguageCheck*> providedChecks() override;
0067 
0068     int configPages() const override;
0069     KDevelop::ConfigPage* configPage(int number, QWidget* parent) override;
0070 
0071     int perProjectConfigPages() const override;
0072     KDevelop::ConfigPage* perProjectConfigPage(int number, const KDevelop::ProjectConfigOptions& options, QWidget* parent) override;
0073 
0074 public Q_SLOTS:
0075     void documentOpened(KDevelop::IDocument*);
0076     void updateStyleChecking(KDevelop::ReferencedTopDUContext top);
0077 
0078 private:
0079     Highlighting* m_highlighting;
0080     Refactoring* m_refactoring;
0081     StyleChecking* m_styleChecking;
0082     static LanguageSupport* m_self;
0083 };
0084 
0085 }
0086 
0087 #endif
0088