forked from qt-creator/qt-creator
CppTools: Clean up ProjectFileCategorizer
Change-Id: Ia6954810ad49d43629be2db074d620ab71a09cee Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -27,21 +27,19 @@
|
|||||||
|
|
||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
|
|
||||||
ProjectFileCategorizer::ProjectFileCategorizer(const QString &partName,
|
ProjectFileCategorizer::ProjectFileCategorizer(const QString &projectPartName,
|
||||||
const QStringList &files,
|
const QStringList &filePaths,
|
||||||
ProjectPartBuilder::FileClassifier fileClassifier)
|
ProjectPartBuilder::FileClassifier fileClassifier)
|
||||||
: m_partName(partName)
|
: m_partName(projectPartName)
|
||||||
{
|
{
|
||||||
using CppTools::ProjectFile;
|
ProjectFiles cHeaders;
|
||||||
|
ProjectFiles cxxHeaders;
|
||||||
|
|
||||||
QVector<ProjectFile> cHeaders;
|
foreach (const QString &filePath, filePaths) {
|
||||||
QVector<ProjectFile> cxxHeaders;
|
|
||||||
|
|
||||||
foreach (const QString &file, files) {
|
|
||||||
const ProjectFile::Kind kind = fileClassifier
|
const ProjectFile::Kind kind = fileClassifier
|
||||||
? fileClassifier(file)
|
? fileClassifier(filePath)
|
||||||
: ProjectFile::classify(file);
|
: ProjectFile::classify(filePath);
|
||||||
const ProjectFile projectFile(file, kind);
|
const ProjectFile projectFile(filePath, kind);
|
||||||
|
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case ProjectFile::CSource: m_cSources += projectFile; break;
|
case ProjectFile::CSource: m_cSources += projectFile; break;
|
||||||
@@ -71,11 +69,10 @@ ProjectFileCategorizer::ProjectFileCategorizer(const QString &partName,
|
|||||||
if (hasC || (!hasObjc && !hasObjcxx && !hasCxx))
|
if (hasC || (!hasObjc && !hasObjcxx && !hasCxx))
|
||||||
m_cSources += cHeaders;
|
m_cSources += cHeaders;
|
||||||
|
|
||||||
m_partCount =
|
m_partCount = (m_cSources.isEmpty() ? 0 : 1)
|
||||||
(m_cSources.isEmpty() ? 0 : 1) +
|
+ (m_cxxSources.isEmpty() ? 0 : 1)
|
||||||
(m_cxxSources.isEmpty() ? 0 : 1) +
|
+ (m_objcSources.isEmpty() ? 0 : 1)
|
||||||
(m_objcSources.isEmpty() ? 0 : 1) +
|
+ (m_objcxxSources.isEmpty() ? 0 : 1);
|
||||||
(m_objcxxSources.isEmpty() ? 0 : 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ProjectFileCategorizer::partName(const QString &languageName) const
|
QString ProjectFileCategorizer::partName(const QString &languageName) const
|
||||||
|
@@ -25,19 +25,19 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QVector>
|
|
||||||
|
|
||||||
#include "cppprojectfile.h"
|
#include "cppprojectfile.h"
|
||||||
#include "projectpartbuilder.h"
|
#include "projectpartbuilder.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
|
|
||||||
class ProjectFileCategorizer
|
class ProjectFileCategorizer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProjectFileCategorizer(const QString &partName,
|
ProjectFileCategorizer(const QString &projectPartName,
|
||||||
const QStringList &files,
|
const QStringList &filePaths,
|
||||||
ProjectPartBuilder::FileClassifier fileClassifier
|
ProjectPartBuilder::FileClassifier fileClassifier
|
||||||
= ProjectPartBuilder::FileClassifier());
|
= ProjectPartBuilder::FileClassifier());
|
||||||
|
|
||||||
@@ -46,10 +46,10 @@ public:
|
|||||||
bool hasObjcSources() const { return !m_objcSources.isEmpty(); }
|
bool hasObjcSources() const { return !m_objcSources.isEmpty(); }
|
||||||
bool hasObjcxxSources() const { return !m_objcxxSources.isEmpty(); }
|
bool hasObjcxxSources() const { return !m_objcxxSources.isEmpty(); }
|
||||||
|
|
||||||
QVector<ProjectFile> cSources() const { return m_cSources; }
|
ProjectFiles cSources() const { return m_cSources; }
|
||||||
QVector<ProjectFile> cxxSources() const { return m_cxxSources; }
|
ProjectFiles cxxSources() const { return m_cxxSources; }
|
||||||
QVector<ProjectFile> objcSources() const { return m_objcSources; }
|
ProjectFiles objcSources() const { return m_objcSources; }
|
||||||
QVector<ProjectFile> objcxxSources() const { return m_objcxxSources; }
|
ProjectFiles objcxxSources() const { return m_objcxxSources; }
|
||||||
|
|
||||||
bool hasMultipleParts() const { return m_partCount > 1; }
|
bool hasMultipleParts() const { return m_partCount > 1; }
|
||||||
bool hasNoParts() const { return m_partCount == 0; }
|
bool hasNoParts() const { return m_partCount == 0; }
|
||||||
@@ -58,10 +58,10 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_partName;
|
QString m_partName;
|
||||||
QVector<ProjectFile> m_cSources;
|
ProjectFiles m_cSources;
|
||||||
QVector<ProjectFile> m_cxxSources;
|
ProjectFiles m_cxxSources;
|
||||||
QVector<ProjectFile> m_objcSources;
|
ProjectFiles m_objcSources;
|
||||||
QVector<ProjectFile> m_objcxxSources;
|
ProjectFiles m_objcxxSources;
|
||||||
int m_partCount;
|
int m_partCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user