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

0001 /*
0002     SPDX-FileCopyrightText: 2016 Sven Brauch <mail@svenbrauch.de>
0003 
0004     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 
0007 #ifndef PYTHONSTYLECHECKING_H
0008 #define PYTHONSTYLECHECKING_H
0009 
0010 #include <QObject>
0011 #include <QProcess>
0012 #include <KConfig>
0013 #include <KConfigGroup>
0014 
0015 #include <language/duchain/topducontext.h>
0016 
0017 namespace Python {
0018 
0019 class StyleChecking : public QObject
0020 {
0021 Q_OBJECT
0022 public:
0023     StyleChecking(QObject* parent=nullptr);
0024     ~StyleChecking() override;
0025     void startChecker(const QString& text, const QString& select={},
0026                       const QString& ignore={}, const int maxLineLength=80);
0027 
0028 public Q_SLOTS:
0029     void updateStyleChecking(const KDevelop::ReferencedTopDUContext& top);
0030     void addErrorsToContext(const QVector<QString>& errors);
0031 
0032 private Q_SLOTS:
0033     void processOutputStarted();
0034 
0035 private:
0036     void addSetupErrorToContext(const QString& error);
0037 
0038 private:
0039     QProcess m_checkerProcess;
0040     KDevelop::ReferencedTopDUContext m_currentlyChecking;
0041     QMutex m_mutex;
0042     KConfigGroup m_pep8Group;
0043 };
0044 
0045 };
0046 
0047 #endif // PYTHONSTYLECHECKING_H