Commit 63fe568b authored by Sergey Shambir's avatar Sergey Shambir

CppTools: improved languages support in ProjectPart

Please, read blueprint here:
http://qt-project.org/wiki/Blueprint-for-language-specs-system

Removed feature from QbsProjectManager: it not longer splits project on
separate C and C++ parts, because Qt version used only by clang parser
(not native) and can be ignored for pure C and Objective-C without C++.

Change-Id: I1c561f7f9f915cc6cb8579d19db74e8352f54c1e
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 0c417bbb
...@@ -434,13 +434,15 @@ void AutotoolsProject::updateCppCodeModel() ...@@ -434,13 +434,15 @@ void AutotoolsProject::updateCppCodeModel()
|| (pinfo.frameworkPaths() != allFrameworkPaths); || (pinfo.frameworkPaths() != allFrameworkPaths);
if (update) { if (update) {
pinfo.clearProjectParts(); pinfo.clearProjectParts();
CPlusPlus::CppModelManagerInterface::ProjectPart::Ptr part( CPlusPlus::ProjectPart::Ptr part(new CPlusPlus::ProjectPart);
new CPlusPlus::CppModelManagerInterface::ProjectPart);
part->includePaths = allIncludePaths; part->includePaths = allIncludePaths;
part->sourceFiles = m_files; foreach (const QString &file, m_files)
part->files << CPlusPlus::ProjectFile(file, CPlusPlus::ProjectFile::CXXSource);
part->defines = macros; part->defines = macros;
part->frameworkPaths = allFrameworkPaths; part->frameworkPaths = allFrameworkPaths;
part->language = CPlusPlus::CppModelManagerInterface::ProjectPart::CXX11; part->cVersion = CPlusPlus::ProjectPart::C99;
part->cxxVersion = CPlusPlus::ProjectPart::CXX11;
pinfo.appendProjectPart(part); pinfo.appendProjectPart(part);
modelManager->updateProjectInfo(pinfo); modelManager->updateProjectInfo(pinfo);
......
...@@ -372,19 +372,20 @@ bool CMakeProject::parseCMakeLists() ...@@ -372,19 +372,20 @@ bool CMakeProject::parseCMakeLists()
|| pinfo.defines() != allDefines || pinfo.defines() != allDefines
|| pinfo.frameworkPaths() != allFrameworkPaths) { || pinfo.frameworkPaths() != allFrameworkPaths) {
pinfo.clearProjectParts(); pinfo.clearProjectParts();
CPlusPlus::CppModelManagerInterface::ProjectPart::Ptr part( CPlusPlus::ProjectPart::Ptr part(new CPlusPlus::ProjectPart);
new CPlusPlus::CppModelManagerInterface::ProjectPart);
part->includePaths = allIncludePaths; part->includePaths = allIncludePaths;
// TODO we only want C++ files, not all other stuff that might be in the project CPlusPlus::ProjectFileAdder adder(part->files);
part->sourceFiles = m_files; foreach (const QString &file, m_files)
adder.maybeAdd(file);
part->defines = allDefines; part->defines = allDefines;
part->frameworkPaths = allFrameworkPaths; part->frameworkPaths = allFrameworkPaths;
part->cVersion = CPlusPlus::ProjectPart::C99;
if (tc) if (tc)
part->language = tc->compilerFlags(cxxflags) == ToolChain::STD_CXX11 part->cxxVersion = tc->compilerFlags(cxxflags) == ToolChain::STD_CXX11
? CPlusPlus::CppModelManagerInterface::ProjectPart::CXX11 ? CPlusPlus::ProjectPart::CXX11
: CPlusPlus::CppModelManagerInterface::ProjectPart::CXX; : CPlusPlus::ProjectPart::CXX98;
else else
part->language = CPlusPlus::CppModelManagerInterface::ProjectPart::CXX11; part->cxxVersion = CPlusPlus::ProjectPart::CXX11;
pinfo.appendProjectPart(part); pinfo.appendProjectPart(part);
modelmanager->updateProjectInfo(pinfo); modelmanager->updateProjectInfo(pinfo);
m_codeModelFuture.cancel(); m_codeModelFuture.cancel();
......
...@@ -1688,17 +1688,19 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa ...@@ -1688,17 +1688,19 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
QList<CppModelManagerInterface::ProjectInfo> projectInfos = modelManager->projectInfos(); QList<CppModelManagerInterface::ProjectInfo> projectInfos = modelManager->projectInfos();
bool inProject = false; bool inProject = false;
foreach (const CppModelManagerInterface::ProjectInfo &info, projectInfos) { foreach (const CppModelManagerInterface::ProjectInfo &info, projectInfos) {
foreach (CppModelManagerInterface::ProjectPart::Ptr part, info.projectParts()) { foreach (ProjectPart::Ptr part, info.projectParts()) {
if (part->sourceFiles.contains(doc->fileName()) || part->objcSourceFiles.contains(doc->fileName()) || part->headerFiles.contains(doc->fileName())) { foreach (const ProjectFile &file, part->files) {
inProject = true; if (file.path == doc->fileName()) {
includePaths += part->includePaths; inProject = true;
includePaths += part->includePaths;
}
} }
} }
} }
if (!inProject) { if (!inProject) {
// better use all include paths than none // better use all include paths than none
foreach (const CppModelManagerInterface::ProjectInfo &info, projectInfos) { foreach (const CppModelManagerInterface::ProjectInfo &info, projectInfos) {
foreach (CppModelManagerInterface::ProjectPart::Ptr part, info.projectParts()) foreach (ProjectPart::Ptr part, info.projectParts())
includePaths += part->includePaths; includePaths += part->includePaths;
} }
} }
......
...@@ -82,7 +82,7 @@ void CppModelManagerInterface::ProjectInfo::clearProjectParts() ...@@ -82,7 +82,7 @@ void CppModelManagerInterface::ProjectInfo::clearProjectParts()
} }
void CppModelManagerInterface::ProjectInfo::appendProjectPart( void CppModelManagerInterface::ProjectInfo::appendProjectPart(
const CppModelManagerInterface::ProjectPart::Ptr &part) const ProjectPart::Ptr &part)
{ {
if (!part) if (!part)
return; return;
...@@ -103,12 +103,8 @@ void CppModelManagerInterface::ProjectInfo::appendProjectPart( ...@@ -103,12 +103,8 @@ void CppModelManagerInterface::ProjectInfo::appendProjectPart(
// update source files // update source files
QSet<QString> srcs = QSet<QString>::fromList(m_sourceFiles); QSet<QString> srcs = QSet<QString>::fromList(m_sourceFiles);
foreach (const QString &src, part->headerFiles) foreach (const ProjectFile &file, part->files)
srcs.insert(src); srcs.insert(file.path);
foreach (const QString &src, part->sourceFiles)
srcs.insert(src);
foreach (const QString &src, part->objcSourceFiles)
srcs.insert(src);
m_sourceFiles = srcs.toList(); m_sourceFiles = srcs.toList();
// update defines // update defines
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <cplusplus/CppDocument.h> #include <cplusplus/CppDocument.h>
#include <languageutils/fakemetaobject.h> #include <languageutils/fakemetaobject.h>
#include "cpptools_global.h" #include "cpptools_global.h"
#include "cppprojectfile.h"
#include <QObject> #include <QObject>
#include <QHash> #include <QHash>
...@@ -63,48 +64,64 @@ namespace CppTools { ...@@ -63,48 +64,64 @@ namespace CppTools {
namespace CPlusPlus { namespace CPlusPlus {
class CPPTOOLS_EXPORT CppModelManagerInterface : public QObject class CPPTOOLS_EXPORT ProjectPart
{ {
Q_OBJECT public:
ProjectPart()
: cVersion(C89)
, cxxVersion(CXX11)
, cxxExtensions(NoExtensions)
, qtVersion(UnknownQt)
{}
public: public:
enum CVersion {
C89,
C99,
C11
};
class CPPTOOLS_EXPORT ProjectPart enum CXXVersion {
{ CXX98,
public: CXX11
ProjectPart() };
: language(CXX11)
, qtVersion(UnknownQt) enum CXXExtension {
{} NoExtensions = 0x0,
GnuExtensions = 0x1,
public: // enums and types MicrosoftExtensions = 0x2,
enum Language { BorlandExtensions = 0x4,
C89 = 1, OpenMP = 0x8
C99 = 2, };
CXX = 3, Q_DECLARE_FLAGS(CXXExtensions, CXXExtension)
CXX11 = 4
}; enum QtVersion {
enum QtVersion { UnknownQt = -1,
UnknownQt = -1, NoQt = 0,
NoQt = 0, Qt4 = 1,
Qt4 = 1, Qt5 = 2
Qt5 = 2
};
typedef QSharedPointer<ProjectPart> Ptr;
public: //attributes
QStringList headerFiles;
QStringList sourceFiles;
QStringList objcSourceFiles;
QByteArray defines;
QStringList includePaths;
QStringList frameworkPaths;
QStringList precompiledHeaders;
Language language;
QtVersion qtVersion;
}; };
typedef QSharedPointer<ProjectPart> Ptr;
public: //attributes
QList<ProjectFile> files;
QByteArray defines;
QStringList includePaths;
QStringList frameworkPaths;
QStringList precompiledHeaders;
CVersion cVersion;
CXXVersion cxxVersion;
CXXExtensions cxxExtensions;
QtVersion qtVersion;
};
class CPPTOOLS_EXPORT CppModelManagerInterface : public QObject
{
Q_OBJECT
public:
class CPPTOOLS_EXPORT ProjectInfo class CPPTOOLS_EXPORT ProjectInfo
{ {
public: public:
...@@ -252,4 +269,6 @@ public Q_SLOTS: ...@@ -252,4 +269,6 @@ public Q_SLOTS:
} // namespace CPlusPlus } // namespace CPlusPlus
QDebug operator <<(QDebug stream, const CPlusPlus::ProjectFile &cxxFile);
#endif // CPPMODELMANAGERINTERFACE_H #endif // CPPMODELMANAGERINTERFACE_H
...@@ -89,9 +89,9 @@ ...@@ -89,9 +89,9 @@
namespace CPlusPlus { namespace CPlusPlus {
uint qHash(const CppModelManagerInterface::ProjectPart &p) uint qHash(const ProjectPart &p)
{ {
uint h = qHash(p.defines) ^ p.language ^ p.qtVersion; uint h = qHash(p.defines) ^ p.cVersion ^ p.cxxVersion ^ p.cxxExtensions ^ p.qtVersion;
foreach (const QString &i, p.includePaths) foreach (const QString &i, p.includePaths)
h ^= qHash(i); h ^= qHash(i);
...@@ -102,12 +102,16 @@ uint qHash(const CppModelManagerInterface::ProjectPart &p) ...@@ -102,12 +102,16 @@ uint qHash(const CppModelManagerInterface::ProjectPart &p)
return h; return h;
} }
bool operator==(const CppModelManagerInterface::ProjectPart &p1, bool operator==(const ProjectPart &p1,
const CppModelManagerInterface::ProjectPart &p2) const ProjectPart &p2)
{ {
if (p1.defines != p2.defines) if (p1.defines != p2.defines)
return false; return false;
if (p1.language != p2.language) if (p1.cVersion != p2.cVersion)
return false;
if (p1.cxxVersion != p2.cxxVersion)
return false;
if (p1.cxxExtensions != p2.cxxExtensions)
return false; return false;
if (p1.qtVersion!= p2.qtVersion) if (p1.qtVersion!= p2.qtVersion)
return false; return false;
...@@ -769,9 +773,8 @@ QStringList CppModelManager::internalProjectFiles() const ...@@ -769,9 +773,8 @@ QStringList CppModelManager::internalProjectFiles() const
it.next(); it.next();
ProjectInfo pinfo = it.value(); ProjectInfo pinfo = it.value();
foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) { foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) {
files += part->headerFiles; foreach (const ProjectFile &file, part->files)
files += part->sourceFiles; files += file.path;
files += part->objcSourceFiles;
} }
} }
files.removeDuplicates(); files.removeDuplicates();
...@@ -839,24 +842,37 @@ void CppModelManager::dumpModelManagerConfiguration() ...@@ -839,24 +842,37 @@ void CppModelManager::dumpModelManagerConfiguration()
qDebug()<<" for project:"<< pinfo.project().data()->document()->fileName(); qDebug()<<" for project:"<< pinfo.project().data()->document()->fileName();
foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) { foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) {
qDebug() << "=== part ==="; qDebug() << "=== part ===";
const char* lang; const char* cVersion;
switch (part->language) { const char* cxxVersion;
case ProjectPart::CXX: lang = "C++"; break; const char* cxxExtensions;
case ProjectPart::CXX11: lang = "C++11"; break; switch (part->cVersion) {
case ProjectPart::C89: lang = "C89"; break; case ProjectPart::C89: cVersion = "C89"; break;
case ProjectPart::C99: lang = "C99"; break; case ProjectPart::C99: cVersion = "C99"; break;
default: lang = "INVALID"; case ProjectPart::C11: cVersion = "C11"; break;
default: cVersion = "INVALID";
}
switch (part->cxxVersion) {
case ProjectPart::CXX98: cVersion = "CXX98"; break;
case ProjectPart::CXX11: cVersion = "CXX11"; break;
default: cxxVersion = "INVALID";
}
switch (part->cxxExtensions) {
case ProjectPart::NoExtensions: cVersion = "NoExtensions"; break;
case ProjectPart::GnuExtensions: cVersion = "GnuExtensions"; break;
case ProjectPart::MicrosoftExtensions: cVersion = "MicrosoftExtensions"; break;
case ProjectPart::BorlandExtensions: cVersion = "BorlandExtensions"; break;
default: cxxExtensions = "INVALID";
} }
qDebug() << "language:" << lang; qDebug() << "cVersion:" << cVersion;
qDebug() << "cxxVersion:" << cxxVersion;
qDebug() << "cxxExtensions:" << cxxExtensions;
qDebug() << "Qt version:" << part->qtVersion; qDebug() << "Qt version:" << part->qtVersion;
qDebug() << "precompiled header:" << part->precompiledHeaders; qDebug() << "precompiled header:" << part->precompiledHeaders;
qDebug() << "defines:" << part->defines; qDebug() << "defines:" << part->defines;
qDebug() << "includes:" << part->includePaths; qDebug() << "includes:" << part->includePaths;
qDebug() << "frameworkPaths:" << part->frameworkPaths; qDebug() << "frameworkPaths:" << part->frameworkPaths;
qDebug() << "headers:" << part->headerFiles; qDebug() << "files:" << part->files;
qDebug() << "sources:" << part->sourceFiles;
qDebug() << "objc sources:" << part->objcSourceFiles;
qDebug() << ""; qDebug() << "";
} }
} }
...@@ -988,12 +1004,8 @@ void CppModelManager::updateProjectInfo(const ProjectInfo &pinfo) ...@@ -988,12 +1004,8 @@ void CppModelManager::updateProjectInfo(const ProjectInfo &pinfo)
foreach (const ProjectInfo &projectInfo, m_projects) { foreach (const ProjectInfo &projectInfo, m_projects) {
foreach (const ProjectPart::Ptr &projectPart, projectInfo.projectParts()) { foreach (const ProjectPart::Ptr &projectPart, projectInfo.projectParts()) {
foreach (const QString &sourceFile, projectPart->sourceFiles) foreach (const ProjectFile &cxxFile, projectPart->files)
m_srcToProjectPart[sourceFile].append(projectPart); m_srcToProjectPart[cxxFile.path].append(projectPart);
foreach (const QString &objcSourceFile, projectPart->objcSourceFiles)
m_srcToProjectPart[objcSourceFile].append(projectPart);
foreach (const QString &headerFile, projectPart->headerFiles)
m_srcToProjectPart[headerFile].append(projectPart);
} }
} }
} }
...@@ -1004,9 +1016,9 @@ void CppModelManager::updateProjectInfo(const ProjectInfo &pinfo) ...@@ -1004,9 +1016,9 @@ void CppModelManager::updateProjectInfo(const ProjectInfo &pinfo)
emit projectPartsUpdated(pinfo.project().data()); emit projectPartsUpdated(pinfo.project().data());
} }
QList<CppModelManager::ProjectPart::Ptr> CppModelManager::projectPart(const QString &fileName) const QList<ProjectPart::Ptr> CppModelManager::projectPart(const QString &fileName) const
{ {
QList<CppModelManager::ProjectPart::Ptr> parts = m_srcToProjectPart.value(fileName); QList<ProjectPart::Ptr> parts = m_srcToProjectPart.value(fileName);
if (!parts.isEmpty()) if (!parts.isEmpty())
return parts; return parts;
......
...@@ -94,7 +94,7 @@ public: ...@@ -94,7 +94,7 @@ public:
virtual QList<ProjectInfo> projectInfos() const; virtual QList<ProjectInfo> projectInfos() const;
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const; virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const;
virtual void updateProjectInfo(const ProjectInfo &pinfo); virtual void updateProjectInfo(const ProjectInfo &pinfo);
virtual QList<ProjectPart::Ptr> projectPart(const QString &fileName) const; virtual QList<CPlusPlus::ProjectPart::Ptr> projectPart(const QString &fileName) const;
virtual CPlusPlus::Snapshot snapshot() const; virtual CPlusPlus::Snapshot snapshot() const;
virtual Document::Ptr document(const QString &fileName) const; virtual Document::Ptr document(const QString &fileName) const;
...@@ -244,7 +244,7 @@ private: ...@@ -244,7 +244,7 @@ private:
mutable QMutex m_protectExtraDiagnostics; mutable QMutex m_protectExtraDiagnostics;
QHash<QString, QHash<int, QList<Document::DiagnosticMessage> > > m_extraDiagnostics; QHash<QString, QHash<int, QList<Document::DiagnosticMessage> > > m_extraDiagnostics;
QMap<QString, QList<ProjectPart::Ptr> > m_srcToProjectPart; QMap<QString, QList<CPlusPlus::ProjectPart::Ptr> > m_srcToProjectPart;
CppCompletionAssistProvider *m_completionAssistProvider; CppCompletionAssistProvider *m_completionAssistProvider;
CppCompletionAssistProvider *m_completionFallback; CppCompletionAssistProvider *m_completionFallback;
......
...@@ -39,7 +39,8 @@ using namespace CppTools::Internal; ...@@ -39,7 +39,8 @@ using namespace CppTools::Internal;
typedef CPlusPlus::Document Document; typedef CPlusPlus::Document Document;
typedef CPlusPlus::CppModelManagerInterface::ProjectInfo ProjectInfo; typedef CPlusPlus::CppModelManagerInterface::ProjectInfo ProjectInfo;
typedef CPlusPlus::CppModelManagerInterface::ProjectPart ProjectPart; typedef CPlusPlus::ProjectPart ProjectPart;
typedef CPlusPlus::ProjectFile ProjectFile;
typedef ProjectExplorer::Project Project; typedef ProjectExplorer::Project Project;
namespace { namespace {
...@@ -81,7 +82,7 @@ void CppToolsPlugin::test_modelmanager_paths() ...@@ -81,7 +82,7 @@ void CppToolsPlugin::test_modelmanager_paths()
ProjectPart::Ptr part(new ProjectPart); ProjectPart::Ptr part(new ProjectPart);
pi.appendProjectPart(part); pi.appendProjectPart(part);
part->language = ProjectPart::CXX; part->cxxVersion = ProjectPart::CXX98;
part->qtVersion = ProjectPart::Qt5; part->qtVersion = ProjectPart::Qt5;
part->defines = QByteArray("#define OH_BEHAVE -1\n"); part->defines = QByteArray("#define OH_BEHAVE -1\n");
part->includePaths = QStringList() << testIncludeDir(false); part->includePaths = QStringList() << testIncludeDir(false);
...@@ -109,19 +110,20 @@ void CppToolsPlugin::test_modelmanager_framework_headers() ...@@ -109,19 +110,20 @@ void CppToolsPlugin::test_modelmanager_framework_headers()
ProjectPart::Ptr part(new ProjectPart); ProjectPart::Ptr part(new ProjectPart);
pi.appendProjectPart(part); pi.appendProjectPart(part);
part->language = ProjectPart::CXX; part->cxxVersion = ProjectPart::CXX98;
part->qtVersion = ProjectPart::Qt5; part->qtVersion = ProjectPart::Qt5;
part->defines = QByteArray("#define OH_BEHAVE -1\n"); part->defines = QByteArray("#define OH_BEHAVE -1\n");
part->includePaths << testIncludeDir(); part->includePaths << testIncludeDir();
part->frameworkPaths << testFrameworksDir(); part->frameworkPaths << testFrameworksDir();
part->sourceFiles << testSource(QLatin1String("test_modelmanager_framework_headers.cpp")); const QString &source = testSource(QLatin1String("test_modelmanager_framework_headers.cpp"));
part->files << ProjectFile(source, ProjectFile::CXXSource);
mm->updateProjectInfo(pi); mm->updateProjectInfo(pi);
mm->updateSourceFiles(part->sourceFiles).waitForFinished(); mm->updateSourceFiles(QStringList(source)).waitForFinished();
QCoreApplication::processEvents(); QCoreApplication::processEvents();
QVERIFY(mm->snapshot().contains(part->sourceFiles.first())); QVERIFY(mm->snapshot().contains(source));
Document::Ptr doc = mm->snapshot().document(part->sourceFiles.first()); Document::Ptr doc = mm->snapshot().document(source);
QVERIFY(!doc.isNull()); QVERIFY(!doc.isNull());
CPlusPlus::Namespace *ns = doc->globalNamespace(); CPlusPlus::Namespace *ns = doc->globalNamespace();
QVERIFY(ns); QVERIFY(ns);
......
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "cppprojectfile.h"
#include <coreplugin/icore.h>
#include "cpptoolsconstants.h"
#include <QDebug>
namespace CPlusPlus {
ProjectFile::ProjectFile()
: kind(CHeader)
{
}
ProjectFile::ProjectFile(const QString &file, Kind kind)
: path(file)
, kind(kind)
{
}
ProjectFileAdder::ProjectFileAdder(QList<ProjectFile> &files)
: m_files(files)
{
addMapping(CppTools::Constants::C_SOURCE_MIMETYPE, ProjectFile::CSource);
addMapping(CppTools::Constants::C_HEADER_MIMETYPE, ProjectFile::CHeader);
addMapping(CppTools::Constants::CPP_SOURCE_MIMETYPE, ProjectFile::CSource);
addMapping(CppTools::Constants::CPP_HEADER_MIMETYPE, ProjectFile::CHeader);
addMapping(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE, ProjectFile::ObjCXXSource);
}
ProjectFileAdder::~ProjectFileAdder()
{
}
bool ProjectFileAdder::maybeAdd(const QString &path)
{
m_fileInfo.setFile(path);
foreach (const Pair &pair, m_mapping)
if (pair.first.matchesFile(path)) {
m_files << ProjectFile(path, pair.second);
return true;
}
return false;
}
void ProjectFileAdder::addMapping(const char *mimeName, ProjectFile::Kind kind)
{
const Core::MimeDatabase *mimeDatabase = Core::ICore::mimeDatabase();
Core::MimeType mimeType = mimeDatabase->findByType(QLatin1String(mimeName));
if (!mimeType.isNull())
m_mapping.append(Pair(mimeType, kind));
}
} // namespace CPlusPlus
QDebug operator <<(QDebug stream, const CPlusPlus::ProjectFile &cxxFile)
{
const char *kind;
switch (cxxFile.kind) {
case CPlusPlus::ProjectFile::CHeader: kind = "CHeader"; break;
case CPlusPlus::ProjectFile::CSource: kind = "CSource"; break;
case CPlusPlus::ProjectFile::CXXHeader: kind = "CXXHeader"; break;
case CPlusPlus::ProjectFile::CXXSource: kind = "CXXSource"; break;
case CPlusPlus::ProjectFile::ObjCHeader: kind = "ObjCHeader"; break;
case CPlusPlus::ProjectFile::ObjCSource: kind = "ObjCSource"; break;
case CPlusPlus::ProjectFile::ObjCXXHeader: kind = "ObjCXXHeader"; break;
case CPlusPlus::ProjectFile::ObjCXXSource: kind = "ObjCXXSource"; break;
case CPlusPlus::ProjectFile::CudaSource: kind = "CudaSource"; break;
case CPlusPlus::ProjectFile::OpenCLSource: kind = "OpenCLSource"; break;
default: kind = "INVALID"; break;
}
stream << cxxFile.path << QLatin1String(", ") << kind;
return stream;
}
/****************************************************************************