Extract AnalyzeUnit out of ClangStaticAnalyzerRunControl

Reduces some noise in the implementation file.

Change-Id: I24e81941c1888ba69f6b7f8dcab35956f60ca4e6
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
This commit is contained in:
Nikolai Kosjar
2015-04-16 13:16:09 +02:00
parent fce0b85106
commit ef79615fe5
2 changed files with 20 additions and 23 deletions

View File

@@ -146,14 +146,13 @@ static QStringList argumentsFromProjectPart(const CppTools::ProjectPart::Ptr &pr
return result; return result;
} }
static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromCompilerCallData( static AnalyzeUnits unitsToAnalyzeFromCompilerCallData(
const ProjectInfo::CompilerCallData &compilerCallData, const ProjectInfo::CompilerCallData &compilerCallData,
unsigned char wordWidth) unsigned char wordWidth)
{ {
typedef ClangStaticAnalyzerRunControl::AnalyzeUnit AnalyzeUnit;
qCDebug(LOG) << "Taking arguments for analyzing from CompilerCallData."; qCDebug(LOG) << "Taking arguments for analyzing from CompilerCallData.";
QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyze; AnalyzeUnits unitsToAnalyze;
QHashIterator<QString, QList<QStringList> > it(compilerCallData); QHashIterator<QString, QList<QStringList> > it(compilerCallData);
while (it.hasNext()) { while (it.hasNext()) {
@@ -169,15 +168,13 @@ static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromCompi
return unitsToAnalyze; return unitsToAnalyze;
} }
static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromProjectParts( static AnalyzeUnits unitsToAnalyzeFromProjectParts(const QList<ProjectPart::Ptr> projectParts,
const QList<ProjectPart::Ptr> projectParts,
const QString &toolchainType, const QString &toolchainType,
unsigned char wordWidth) unsigned char wordWidth)
{ {
typedef ClangStaticAnalyzerRunControl::AnalyzeUnit AnalyzeUnit;
qCDebug(LOG) << "Taking arguments for analyzing from ProjectParts."; qCDebug(LOG) << "Taking arguments for analyzing from ProjectParts.";
QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyze; AnalyzeUnits unitsToAnalyze;
foreach (const ProjectPart::Ptr &projectPart, projectParts) { foreach (const ProjectPart::Ptr &projectPart, projectParts) {
if (!projectPart->selectedForBuilding) if (!projectPart->selectedForBuilding)
@@ -200,9 +197,9 @@ static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromProje
return unitsToAnalyze; return unitsToAnalyze;
} }
QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> ClangStaticAnalyzerRunControl::unitsToAnalyze() AnalyzeUnits ClangStaticAnalyzerRunControl::unitsToAnalyze()
{ {
QTC_ASSERT(m_projectInfo.isValid(), return QList<ClangStaticAnalyzerRunControl::AnalyzeUnit>()); QTC_ASSERT(m_projectInfo.isValid(), return AnalyzeUnits());
const ProjectInfo::CompilerCallData compilerCallData = m_projectInfo.compilerCallData(); const ProjectInfo::CompilerCallData compilerCallData = m_projectInfo.compilerCallData();
if (!compilerCallData.isEmpty()) if (!compilerCallData.isEmpty())
@@ -249,7 +246,7 @@ bool ClangStaticAnalyzerRunControl::startEngine()
m_clangLogFileDir = temporaryDir.path(); m_clangLogFileDir = temporaryDir.path();
// Collect files // Collect files
QList<AnalyzeUnit> unitsToProcess = unitsToAnalyze(); AnalyzeUnits unitsToProcess = unitsToAnalyze();
Utils::sort(unitsToProcess, [](const AnalyzeUnit &a1, const AnalyzeUnit &a2) -> bool { Utils::sort(unitsToProcess, [](const AnalyzeUnit &a1, const AnalyzeUnit &a2) -> bool {
return a1.file < a2.file; return a1.file < a2.file;
}); });

View File

@@ -31,11 +31,6 @@ namespace Internal {
class ClangStaticAnalyzerRunner; class ClangStaticAnalyzerRunner;
class Diagnostic; class Diagnostic;
class ClangStaticAnalyzerRunControl : public Analyzer::AnalyzerRunControl
{
Q_OBJECT
public:
struct AnalyzeUnit { struct AnalyzeUnit {
AnalyzeUnit(const QString &file, const QStringList &options) AnalyzeUnit(const QString &file, const QStringList &options)
: file(file), arguments(options) {} : file(file), arguments(options) {}
@@ -43,6 +38,11 @@ public:
QString file; QString file;
QStringList arguments; // without file itself and "-o somePath" QStringList arguments; // without file itself and "-o somePath"
}; };
typedef QList<AnalyzeUnit> AnalyzeUnits;
class ClangStaticAnalyzerRunControl : public Analyzer::AnalyzerRunControl
{
Q_OBJECT
public: public:
explicit ClangStaticAnalyzerRunControl(const Analyzer::AnalyzerStartParameters &startParams, explicit ClangStaticAnalyzerRunControl(const Analyzer::AnalyzerStartParameters &startParams,
@@ -56,7 +56,7 @@ signals:
void newDiagnosticsAvailable(const QList<Diagnostic> &diagnostics); void newDiagnosticsAvailable(const QList<Diagnostic> &diagnostics);
private: private:
QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyze(); AnalyzeUnits unitsToAnalyze();
void analyzeNextFile(); void analyzeNextFile();
ClangStaticAnalyzerRunner *createRunner(); ClangStaticAnalyzerRunner *createRunner();
@@ -75,7 +75,7 @@ private:
QString m_clangExecutable; QString m_clangExecutable;
QString m_clangLogFileDir; QString m_clangLogFileDir;
QFutureInterface<void> m_progress; QFutureInterface<void> m_progress;
QList<AnalyzeUnit> m_unitsToProcess; AnalyzeUnits m_unitsToProcess;
QSet<ClangStaticAnalyzerRunner *> m_runners; QSet<ClangStaticAnalyzerRunner *> m_runners;
int m_initialFilesToProcessSize; int m_initialFilesToProcessSize;
int m_filesAnalyzed; int m_filesAnalyzed;