File indexing completed on 2024-04-28 04:38:10
0001 /* 0002 SPDX-FileCopyrightText: 2016 Carlos Nihelton <carlosnsoliveira@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef CLANGTIDY_JOB_H 0008 #define CLANGTIDY_JOB_H 0009 0010 // plugin 0011 #include "parsers/clangtidyparser.h" 0012 #include <debug.h> 0013 // CompileAnalyzer 0014 #include <compileanalyzejob.h> 0015 // KDevPlatform 0016 #include <interfaces/iproblem.h> 0017 0018 namespace ClangTidy 0019 { 0020 /** 0021 * \class 0022 * \brief specializes a KJob for running clang-tidy. 0023 */ 0024 class Job : public KDevelop::CompileAnalyzeJob 0025 { 0026 Q_OBJECT 0027 0028 public: 0029 /** 0030 * \class 0031 * \brief command line parameters. 0032 */ 0033 struct Parameters { 0034 QString projectRootDir; 0035 QString executablePath; 0036 QStringList filePaths; 0037 QString buildDir; 0038 QString additionalParameters; 0039 QString enabledChecks; 0040 bool useConfigFile = false; 0041 QString headerFilter; 0042 bool checkSystemHeaders = false; 0043 int parallelJobCount = 1; 0044 }; 0045 0046 explicit Job(const Parameters& params, QObject* parent = nullptr); 0047 ~Job() override; 0048 0049 public: // KJob API 0050 void start() override; 0051 0052 protected Q_SLOTS: 0053 void postProcessStdout(const QStringList& lines) override; 0054 void postProcessStderr(const QStringList& lines) override; 0055 0056 void childProcessExited(int exitCode, QProcess::ExitStatus exitStatus) override; 0057 void childProcessError(QProcess::ProcessError processError) override; 0058 0059 protected: 0060 void processStdoutLines(const QStringList& lines); 0061 void processStderrLines(const QStringList& lines); 0062 0063 protected: 0064 ClangTidyParser m_parser; 0065 QStringList m_standardOutput; 0066 QStringList m_xmlOutput; 0067 const Job::Parameters m_parameters; 0068 0069 QVector<KDevelop::IProblem::Ptr> m_problems; 0070 }; 0071 0072 } 0073 0074 #endif