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

View File

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