forked from qt-creator/qt-creator
CppTools: Move Project{Part,Info} to new cppprojects.{h,cpp}
Change-Id: Ieff216017b9da1e6a12121688ea9572bdd81fd9b Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
b8a6a4dd4e
commit
6b5298faf9
@@ -472,7 +472,7 @@ Dumper::~Dumper()
|
||||
m_out << "*** END Code Model Inspection Report\n";
|
||||
}
|
||||
|
||||
void Dumper::dumpProjectInfos( const QList<CppModelManagerInterface::ProjectInfo> &projectInfos)
|
||||
void Dumper::dumpProjectInfos( const QList<ProjectInfo> &projectInfos)
|
||||
{
|
||||
const QByteArray i1 = indent(1);
|
||||
const QByteArray i2 = indent(2);
|
||||
@@ -480,7 +480,7 @@ void Dumper::dumpProjectInfos( const QList<CppModelManagerInterface::ProjectInfo
|
||||
const QByteArray i4 = indent(4);
|
||||
|
||||
m_out << "Projects loaded: " << projectInfos.size() << "{{{1\n";
|
||||
foreach (const CppModelManagerInterface::ProjectInfo &info, projectInfos) {
|
||||
foreach (const ProjectInfo &info, projectInfos) {
|
||||
const QPointer<ProjectExplorer::Project> project = info.project();
|
||||
m_out << i1 << "Project " << project->displayName()
|
||||
<< " (" << project->projectFilePath().toUserOutput() << "){{{2\n";
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
const QString &logFileId = QString());
|
||||
~Dumper();
|
||||
|
||||
void dumpProjectInfos(const QList<CppTools::CppModelManagerInterface::ProjectInfo> &projectInfos);
|
||||
void dumpProjectInfos(const QList<CppTools::ProjectInfo> &projectInfos);
|
||||
void dumpSnapshot(const CPlusPlus::Snapshot &snapshot,
|
||||
const QString &title,
|
||||
bool isGlobalSnapshot = false);
|
||||
|
||||
@@ -368,7 +368,7 @@ QByteArray CppModelManager::internalDefinedMacros() const
|
||||
addUnique(part->toolchainDefines.split('\n'), ¯os, &alreadyIn);
|
||||
addUnique(part->projectDefines.split('\n'), ¯os, &alreadyIn);
|
||||
if (!part->projectConfigFile.isEmpty())
|
||||
macros += readProjectConfigFile(part);
|
||||
macros += ProjectPart::readProjectConfigFile(part);
|
||||
}
|
||||
}
|
||||
return macros;
|
||||
@@ -523,13 +523,13 @@ QFuture<void> CppModelManager::updateSourceFiles(const QStringList &sourceFiles,
|
||||
return m_internalIndexingSupport->refreshSourceFiles(sourceFiles, mode);
|
||||
}
|
||||
|
||||
QList<CppModelManager::ProjectInfo> CppModelManager::projectInfos() const
|
||||
QList<ProjectInfo> CppModelManager::projectInfos() const
|
||||
{
|
||||
QMutexLocker locker(&m_projectMutex);
|
||||
return m_projectToProjectsInfo.values();
|
||||
}
|
||||
|
||||
CppModelManager::ProjectInfo CppModelManager::projectInfo(ProjectExplorer::Project *project) const
|
||||
ProjectInfo CppModelManager::projectInfo(ProjectExplorer::Project *project) const
|
||||
{
|
||||
QMutexLocker locker(&m_projectMutex);
|
||||
return m_projectToProjectsInfo.value(project, ProjectInfo(project));
|
||||
@@ -569,8 +569,8 @@ void CppModelManager::removeFilesFromSnapshot(const QSet<QString> &filesToRemove
|
||||
class ProjectInfoComparer
|
||||
{
|
||||
public:
|
||||
ProjectInfoComparer(const CppModelManager::ProjectInfo &oldProjectInfo,
|
||||
const CppModelManager::ProjectInfo &newProjectInfo)
|
||||
ProjectInfoComparer(const ProjectInfo &oldProjectInfo,
|
||||
const ProjectInfo &newProjectInfo)
|
||||
: m_old(oldProjectInfo)
|
||||
, m_oldSourceFiles(oldProjectInfo.sourceFiles().toSet())
|
||||
, m_new(newProjectInfo)
|
||||
@@ -625,10 +625,10 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const CppModelManager::ProjectInfo &m_old;
|
||||
const ProjectInfo &m_old;
|
||||
const QSet<QString> m_oldSourceFiles;
|
||||
|
||||
const CppModelManager::ProjectInfo &m_new;
|
||||
const ProjectInfo &m_new;
|
||||
const QSet<QString> m_newSourceFiles;
|
||||
};
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ using namespace CppTools::Internal;
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
typedef CPlusPlus::Document Document;
|
||||
typedef CppTools::CppModelManagerInterface::ProjectInfo ProjectInfo;
|
||||
typedef CppTools::ProjectInfo ProjectInfo;
|
||||
typedef CppTools::ProjectPart ProjectPart;
|
||||
typedef CppTools::ProjectFile ProjectFile;
|
||||
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
#include <projectexplorer/headerpath.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
||||
#include <QSet>
|
||||
|
||||
using namespace CppTools;
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
@@ -99,71 +97,6 @@ using namespace ProjectExplorer;
|
||||
\sa CppTools::CppModelManagerInterface::updateProjectInfo()
|
||||
*/
|
||||
|
||||
ProjectPart::ProjectPart()
|
||||
: project(0)
|
||||
, cVersion(C89)
|
||||
, cxxVersion(CXX11)
|
||||
, cxxExtensions(NoExtensions)
|
||||
, qtVersion(UnknownQt)
|
||||
, cWarningFlags(ProjectExplorer::ToolChain::WarningsDefault)
|
||||
, cxxWarningFlags(ProjectExplorer::ToolChain::WarningsDefault)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Retrieves info from concrete compiler using it's flags.
|
||||
|
||||
\param tc Either nullptr or toolchain for project's active target.
|
||||
\param cxxflags C++ or Objective-C++ flags.
|
||||
\param cflags C or ObjectiveC flags if possible, \a cxxflags otherwise.
|
||||
*/
|
||||
void ProjectPart::evaluateToolchain(const ToolChain *tc,
|
||||
const QStringList &cxxflags,
|
||||
const QStringList &cflags,
|
||||
const Utils::FileName &sysRoot)
|
||||
{
|
||||
if (!tc)
|
||||
return;
|
||||
|
||||
ToolChain::CompilerFlags cxx = tc->compilerFlags(cxxflags);
|
||||
ToolChain::CompilerFlags c = (cxxflags == cflags)
|
||||
? cxx : tc->compilerFlags(cflags);
|
||||
|
||||
if (c & ToolChain::StandardC11)
|
||||
cVersion = C11;
|
||||
else if (c & ToolChain::StandardC99)
|
||||
cVersion = C99;
|
||||
else
|
||||
cVersion = C89;
|
||||
|
||||
if (cxx & ToolChain::StandardCxx11)
|
||||
cxxVersion = CXX11;
|
||||
else
|
||||
cxxVersion = CXX98;
|
||||
|
||||
if (cxx & ToolChain::BorlandExtensions)
|
||||
cxxExtensions |= BorlandExtensions;
|
||||
if (cxx & ToolChain::GnuExtensions)
|
||||
cxxExtensions |= GnuExtensions;
|
||||
if (cxx & ToolChain::MicrosoftExtensions)
|
||||
cxxExtensions |= MicrosoftExtensions;
|
||||
if (cxx & ToolChain::OpenMP)
|
||||
cxxExtensions |= OpenMPExtensions;
|
||||
|
||||
cWarningFlags = tc->warningFlags(cflags);
|
||||
cxxWarningFlags = tc->warningFlags(cxxflags);
|
||||
|
||||
const QList<ProjectExplorer::HeaderPath> headers = tc->systemHeaderPaths(cxxflags, sysRoot);
|
||||
foreach (const ProjectExplorer::HeaderPath &header, headers) {
|
||||
headerPaths << HeaderPath(header.path(),
|
||||
header.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath
|
||||
? HeaderPath::FrameworkPath : HeaderPath::IncludePath);
|
||||
}
|
||||
|
||||
toolchainDefines = tc->predefinedMacros(cxxflags);
|
||||
}
|
||||
|
||||
const QString CppModelManagerInterface::configurationFileName()
|
||||
{ return CPlusPlus::Preprocessor::configurationFileName; }
|
||||
|
||||
@@ -183,62 +116,3 @@ CppModelManagerInterface *CppModelManagerInterface::instance()
|
||||
{
|
||||
return qobject_cast<CppModelManagerInterface *>(CPlusPlus::CppModelManagerBase::instance());
|
||||
}
|
||||
|
||||
void CppModelManagerInterface::ProjectInfo::clearProjectParts()
|
||||
{
|
||||
m_projectParts.clear();
|
||||
m_headerPaths.clear();
|
||||
m_sourceFiles.clear();
|
||||
m_defines.clear();
|
||||
}
|
||||
|
||||
void CppModelManagerInterface::ProjectInfo::appendProjectPart(const ProjectPart::Ptr &part)
|
||||
{
|
||||
if (!part)
|
||||
return;
|
||||
|
||||
m_projectParts.append(part);
|
||||
|
||||
typedef ProjectPart::HeaderPath HeaderPath;
|
||||
|
||||
// Update header paths
|
||||
QSet<HeaderPath> incs = QSet<HeaderPath>::fromList(m_headerPaths);
|
||||
foreach (const HeaderPath &hp, part->headerPaths) {
|
||||
if (!incs.contains(hp)) {
|
||||
incs.insert(hp);
|
||||
m_headerPaths += hp;
|
||||
}
|
||||
}
|
||||
|
||||
// Update source files
|
||||
QSet<QString> srcs = QSet<QString>::fromList(m_sourceFiles);
|
||||
foreach (const ProjectFile &file, part->files)
|
||||
srcs.insert(file.path);
|
||||
m_sourceFiles = srcs.toList();
|
||||
|
||||
// Update defines
|
||||
if (!m_defines.isEmpty())
|
||||
m_defines.append('\n');
|
||||
m_defines.append(part->toolchainDefines);
|
||||
m_defines.append(part->projectDefines);
|
||||
if (!part->projectConfigFile.isEmpty()) {
|
||||
m_defines.append('\n');
|
||||
m_defines += readProjectConfigFile(part);
|
||||
m_defines.append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray CppModelManagerInterface::readProjectConfigFile(const ProjectPart::Ptr &part)
|
||||
{
|
||||
QByteArray result;
|
||||
|
||||
QFile f(part->projectConfigFile);
|
||||
if (f.open(QIODevice::ReadOnly)) {
|
||||
QTextStream is(&f);
|
||||
result = is.readAll().toUtf8();
|
||||
f.close();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,11 +32,10 @@
|
||||
|
||||
#include "cpptools_global.h"
|
||||
|
||||
#include "cppprojectfile.h"
|
||||
#include "cppprojects.h"
|
||||
|
||||
#include <cplusplus/CppDocument.h>
|
||||
#include <cplusplus/cppmodelmanagerbase.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
||||
#include <QFuture>
|
||||
#include <QHash>
|
||||
@@ -53,97 +52,13 @@ namespace Utils { class FileName; }
|
||||
namespace CppTools {
|
||||
|
||||
class AbstractEditorSupport;
|
||||
class ModelManagerSupport;
|
||||
class CppCompletionAssistProvider;
|
||||
class CppEditorSupport;
|
||||
class CppHighlightingSupport;
|
||||
class CppIndexingSupport;
|
||||
class ModelManagerSupport;
|
||||
class WorkingCopy;
|
||||
|
||||
class CPPTOOLS_EXPORT ProjectPart
|
||||
{
|
||||
public:
|
||||
ProjectPart();
|
||||
|
||||
void evaluateToolchain(const ProjectExplorer::ToolChain *tc,
|
||||
const QStringList &cxxflags,
|
||||
const QStringList &cflags,
|
||||
const Utils::FileName &sysRoot);
|
||||
|
||||
public:
|
||||
enum CVersion {
|
||||
C89,
|
||||
C99,
|
||||
C11
|
||||
};
|
||||
|
||||
enum CXXVersion {
|
||||
CXX98,
|
||||
CXX11
|
||||
};
|
||||
|
||||
enum CXXExtension {
|
||||
NoExtensions = 0x0,
|
||||
GnuExtensions = 0x1,
|
||||
MicrosoftExtensions = 0x2,
|
||||
BorlandExtensions = 0x4,
|
||||
OpenMPExtensions = 0x8,
|
||||
|
||||
AllExtensions = GnuExtensions | MicrosoftExtensions | BorlandExtensions | OpenMPExtensions
|
||||
};
|
||||
Q_DECLARE_FLAGS(CXXExtensions, CXXExtension)
|
||||
|
||||
enum QtVersion {
|
||||
UnknownQt = -1,
|
||||
NoQt = 0,
|
||||
Qt4 = 1,
|
||||
Qt5 = 2
|
||||
};
|
||||
|
||||
typedef QSharedPointer<ProjectPart> Ptr;
|
||||
|
||||
struct HeaderPath {
|
||||
enum Type { InvalidPath, IncludePath, FrameworkPath };
|
||||
|
||||
public:
|
||||
QString path;
|
||||
Type type;
|
||||
|
||||
HeaderPath(): type(InvalidPath) {}
|
||||
HeaderPath(const QString &path, Type type): path(path), type(type) {}
|
||||
|
||||
bool isValid() const { return type != InvalidPath; }
|
||||
bool isFrameworkPath() const { return type == FrameworkPath; }
|
||||
|
||||
bool operator==(const HeaderPath &other) const
|
||||
{ return path == other.path && type == other.type; }
|
||||
|
||||
bool operator!=(const HeaderPath &other) const
|
||||
{ return !(*this == other); }
|
||||
};
|
||||
typedef QList<HeaderPath> HeaderPaths;
|
||||
|
||||
public:
|
||||
QString displayName;
|
||||
QString projectFile;
|
||||
ProjectExplorer::Project *project;
|
||||
QList<ProjectFile> files;
|
||||
QString projectConfigFile; // currently only used by the Generic Project Manager
|
||||
QByteArray projectDefines;
|
||||
QByteArray toolchainDefines;
|
||||
QList<HeaderPath> headerPaths;
|
||||
QStringList precompiledHeaders;
|
||||
CVersion cVersion;
|
||||
CXXVersion cxxVersion;
|
||||
CXXExtensions cxxExtensions;
|
||||
QtVersion qtVersion;
|
||||
ProjectExplorer::ToolChain::WarningFlags cWarningFlags;
|
||||
ProjectExplorer::ToolChain::WarningFlags cxxWarningFlags;
|
||||
};
|
||||
|
||||
inline uint qHash(const ProjectPart::HeaderPath &key, uint seed = 0)
|
||||
{ return ((qHash(key.path) << 2) | key.type) ^ seed; }
|
||||
|
||||
class CPPTOOLS_EXPORT CppModelManagerInterface : public CPlusPlus::CppModelManagerBase
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -155,52 +70,6 @@ public:
|
||||
ReservedProgressNotification
|
||||
};
|
||||
|
||||
class CPPTOOLS_EXPORT ProjectInfo
|
||||
{
|
||||
public:
|
||||
ProjectInfo()
|
||||
{}
|
||||
|
||||
ProjectInfo(QPointer<ProjectExplorer::Project> project)
|
||||
: m_project(project)
|
||||
{}
|
||||
|
||||
operator bool() const
|
||||
{ return !m_project.isNull(); }
|
||||
|
||||
bool isValid() const
|
||||
{ return !m_project.isNull(); }
|
||||
|
||||
bool isNull() const
|
||||
{ return m_project.isNull(); }
|
||||
|
||||
QPointer<ProjectExplorer::Project> project() const
|
||||
{ return m_project; }
|
||||
|
||||
const QList<ProjectPart::Ptr> projectParts() const
|
||||
{ return m_projectParts; }
|
||||
|
||||
void clearProjectParts();
|
||||
void appendProjectPart(const ProjectPart::Ptr &part);
|
||||
|
||||
const ProjectPart::HeaderPaths headerPaths() const
|
||||
{ return m_headerPaths; }
|
||||
|
||||
const QStringList sourceFiles() const
|
||||
{ return m_sourceFiles; }
|
||||
|
||||
const QByteArray defines() const
|
||||
{ return m_defines; }
|
||||
|
||||
private:
|
||||
QPointer<ProjectExplorer::Project> m_project;
|
||||
QList<ProjectPart::Ptr> m_projectParts;
|
||||
// The members below are (re)calculated from the project parts once a part is appended.
|
||||
ProjectPart::HeaderPaths m_headerPaths;
|
||||
QStringList m_sourceFiles;
|
||||
QByteArray m_defines;
|
||||
};
|
||||
|
||||
public:
|
||||
static const QString configurationFileName();
|
||||
static const QString editorConfigurationFileName();
|
||||
@@ -278,9 +147,6 @@ public slots:
|
||||
|
||||
virtual void updateModifiedSourceFiles() = 0;
|
||||
virtual void GC() = 0;
|
||||
|
||||
protected:
|
||||
static QByteArray readProjectConfigFile(const ProjectPart::Ptr &part);
|
||||
};
|
||||
|
||||
} // namespace CppTools
|
||||
|
||||
211
src/plugins/cpptools/cppprojects.cpp
Normal file
211
src/plugins/cpptools/cppprojects.cpp
Normal file
@@ -0,0 +1,211 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2014 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 "cppprojects.h"
|
||||
|
||||
#include <projectexplorer/headerpath.h>
|
||||
|
||||
#include <QSet>
|
||||
#include <QTextStream>
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
ProjectPart::ProjectPart()
|
||||
: project(0)
|
||||
, cVersion(C89)
|
||||
, cxxVersion(CXX11)
|
||||
, cxxExtensions(NoExtensions)
|
||||
, qtVersion(UnknownQt)
|
||||
, cWarningFlags(ProjectExplorer::ToolChain::WarningsDefault)
|
||||
, cxxWarningFlags(ProjectExplorer::ToolChain::WarningsDefault)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Retrieves info from concrete compiler using it's flags.
|
||||
|
||||
\param tc Either nullptr or toolchain for project's active target.
|
||||
\param cxxflags C++ or Objective-C++ flags.
|
||||
\param cflags C or ObjectiveC flags if possible, \a cxxflags otherwise.
|
||||
*/
|
||||
void ProjectPart::evaluateToolchain(const ProjectExplorer::ToolChain *tc,
|
||||
const QStringList &cxxflags,
|
||||
const QStringList &cflags,
|
||||
const Utils::FileName &sysRoot)
|
||||
{
|
||||
if (!tc)
|
||||
return;
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
ToolChain::CompilerFlags cxx = tc->compilerFlags(cxxflags);
|
||||
ToolChain::CompilerFlags c = (cxxflags == cflags)
|
||||
? cxx : tc->compilerFlags(cflags);
|
||||
|
||||
if (c & ToolChain::StandardC11)
|
||||
cVersion = C11;
|
||||
else if (c & ToolChain::StandardC99)
|
||||
cVersion = C99;
|
||||
else
|
||||
cVersion = C89;
|
||||
|
||||
if (cxx & ToolChain::StandardCxx11)
|
||||
cxxVersion = CXX11;
|
||||
else
|
||||
cxxVersion = CXX98;
|
||||
|
||||
if (cxx & ToolChain::BorlandExtensions)
|
||||
cxxExtensions |= BorlandExtensions;
|
||||
if (cxx & ToolChain::GnuExtensions)
|
||||
cxxExtensions |= GnuExtensions;
|
||||
if (cxx & ToolChain::MicrosoftExtensions)
|
||||
cxxExtensions |= MicrosoftExtensions;
|
||||
if (cxx & ToolChain::OpenMP)
|
||||
cxxExtensions |= OpenMPExtensions;
|
||||
|
||||
cWarningFlags = tc->warningFlags(cflags);
|
||||
cxxWarningFlags = tc->warningFlags(cxxflags);
|
||||
|
||||
const QList<ProjectExplorer::HeaderPath> headers = tc->systemHeaderPaths(cxxflags, sysRoot);
|
||||
foreach (const ProjectExplorer::HeaderPath &header, headers) {
|
||||
headerPaths << ProjectPart::HeaderPath(header.path(),
|
||||
header.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath
|
||||
? ProjectPart::HeaderPath::FrameworkPath
|
||||
: ProjectPart::HeaderPath::IncludePath);
|
||||
}
|
||||
|
||||
toolchainDefines = tc->predefinedMacros(cxxflags);
|
||||
}
|
||||
|
||||
QByteArray ProjectPart::readProjectConfigFile(const ProjectPart::Ptr &part)
|
||||
{
|
||||
QByteArray result;
|
||||
|
||||
QFile f(part->projectConfigFile);
|
||||
if (f.open(QIODevice::ReadOnly)) {
|
||||
QTextStream is(&f);
|
||||
result = is.readAll().toUtf8();
|
||||
f.close();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ProjectInfo::ProjectInfo()
|
||||
{}
|
||||
|
||||
ProjectInfo::ProjectInfo(QPointer<ProjectExplorer::Project> project)
|
||||
: m_project(project)
|
||||
{}
|
||||
|
||||
ProjectInfo::operator bool() const
|
||||
{
|
||||
return !m_project.isNull();
|
||||
}
|
||||
|
||||
bool ProjectInfo::isValid() const
|
||||
{
|
||||
return !m_project.isNull();
|
||||
}
|
||||
|
||||
bool ProjectInfo::isNull() const
|
||||
{
|
||||
return m_project.isNull();
|
||||
}
|
||||
|
||||
QPointer<ProjectExplorer::Project> ProjectInfo::project() const
|
||||
{
|
||||
return m_project;
|
||||
}
|
||||
|
||||
const QList<ProjectPart::Ptr> ProjectInfo::projectParts() const
|
||||
{
|
||||
return m_projectParts;
|
||||
}
|
||||
|
||||
void ProjectInfo::appendProjectPart(const ProjectPart::Ptr &part)
|
||||
{
|
||||
if (!part)
|
||||
return;
|
||||
|
||||
m_projectParts.append(part);
|
||||
|
||||
typedef ProjectPart::HeaderPath HeaderPath;
|
||||
|
||||
// Update header paths
|
||||
QSet<HeaderPath> incs = QSet<HeaderPath>::fromList(m_headerPaths);
|
||||
foreach (const HeaderPath &hp, part->headerPaths) {
|
||||
if (!incs.contains(hp)) {
|
||||
incs.insert(hp);
|
||||
m_headerPaths += hp;
|
||||
}
|
||||
}
|
||||
|
||||
// Update source files
|
||||
QSet<QString> srcs = QSet<QString>::fromList(m_sourceFiles);
|
||||
foreach (const ProjectFile &file, part->files)
|
||||
srcs.insert(file.path);
|
||||
m_sourceFiles = srcs.toList();
|
||||
|
||||
// Update defines
|
||||
if (!m_defines.isEmpty())
|
||||
m_defines.append('\n');
|
||||
m_defines.append(part->toolchainDefines);
|
||||
m_defines.append(part->projectDefines);
|
||||
if (!part->projectConfigFile.isEmpty()) {
|
||||
m_defines.append('\n');
|
||||
m_defines += ProjectPart::readProjectConfigFile(part);
|
||||
m_defines.append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectInfo::clearProjectParts()
|
||||
{
|
||||
m_projectParts.clear();
|
||||
m_headerPaths.clear();
|
||||
m_sourceFiles.clear();
|
||||
m_defines.clear();
|
||||
}
|
||||
|
||||
const ProjectPart::HeaderPaths ProjectInfo::headerPaths() const
|
||||
{
|
||||
return m_headerPaths;
|
||||
}
|
||||
|
||||
const QStringList ProjectInfo::sourceFiles() const
|
||||
{
|
||||
return m_sourceFiles;
|
||||
}
|
||||
|
||||
const QByteArray ProjectInfo::defines() const
|
||||
{
|
||||
return m_defines;
|
||||
}
|
||||
|
||||
} // namespace CppTools
|
||||
164
src/plugins/cpptools/cppprojects.h
Normal file
164
src/plugins/cpptools/cppprojects.h
Normal file
@@ -0,0 +1,164 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2014 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CPPPROJECTPART_H
|
||||
#define CPPPROJECTPART_H
|
||||
|
||||
#include "cpptools_global.h"
|
||||
|
||||
#include "cppprojectfile.h"
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
class CPPTOOLS_EXPORT ProjectPart
|
||||
{
|
||||
public:
|
||||
typedef QSharedPointer<ProjectPart> Ptr;
|
||||
|
||||
public:
|
||||
ProjectPart();
|
||||
|
||||
void evaluateToolchain(const ProjectExplorer::ToolChain *tc,
|
||||
const QStringList &cxxflags,
|
||||
const QStringList &cflags,
|
||||
const Utils::FileName &sysRoot);
|
||||
|
||||
public:
|
||||
enum CVersion {
|
||||
C89,
|
||||
C99,
|
||||
C11
|
||||
};
|
||||
|
||||
enum CXXVersion {
|
||||
CXX98,
|
||||
CXX11
|
||||
};
|
||||
|
||||
enum CXXExtension {
|
||||
NoExtensions = 0x0,
|
||||
GnuExtensions = 0x1,
|
||||
MicrosoftExtensions = 0x2,
|
||||
BorlandExtensions = 0x4,
|
||||
OpenMPExtensions = 0x8,
|
||||
|
||||
AllExtensions = GnuExtensions | MicrosoftExtensions | BorlandExtensions | OpenMPExtensions
|
||||
};
|
||||
Q_DECLARE_FLAGS(CXXExtensions, CXXExtension)
|
||||
|
||||
enum QtVersion {
|
||||
UnknownQt = -1,
|
||||
NoQt = 0,
|
||||
Qt4 = 1,
|
||||
Qt5 = 2
|
||||
};
|
||||
|
||||
class HeaderPath
|
||||
{
|
||||
public:
|
||||
enum Type { InvalidPath, IncludePath, FrameworkPath };
|
||||
|
||||
QString path;
|
||||
Type type;
|
||||
|
||||
HeaderPath(): type(InvalidPath) {}
|
||||
HeaderPath(const QString &path, Type type): path(path), type(type) {}
|
||||
|
||||
bool isValid() const { return type != InvalidPath; }
|
||||
bool isFrameworkPath() const { return type == FrameworkPath; }
|
||||
|
||||
bool operator==(const HeaderPath &other) const
|
||||
{ return path == other.path && type == other.type; }
|
||||
|
||||
bool operator!=(const HeaderPath &other) const
|
||||
{ return !(*this == other); }
|
||||
};
|
||||
typedef QList<HeaderPath> HeaderPaths;
|
||||
|
||||
public:
|
||||
static QByteArray readProjectConfigFile(const ProjectPart::Ptr &part);
|
||||
|
||||
public:
|
||||
QString displayName;
|
||||
QString projectFile;
|
||||
ProjectExplorer::Project *project;
|
||||
QList<ProjectFile> files;
|
||||
QString projectConfigFile; // currently only used by the Generic Project Manager
|
||||
QByteArray projectDefines;
|
||||
QByteArray toolchainDefines;
|
||||
QList<HeaderPath> headerPaths;
|
||||
QStringList precompiledHeaders;
|
||||
CVersion cVersion;
|
||||
CXXVersion cxxVersion;
|
||||
CXXExtensions cxxExtensions;
|
||||
QtVersion qtVersion;
|
||||
ProjectExplorer::ToolChain::WarningFlags cWarningFlags;
|
||||
ProjectExplorer::ToolChain::WarningFlags cxxWarningFlags;
|
||||
};
|
||||
|
||||
inline uint qHash(const ProjectPart::HeaderPath &key, uint seed = 0)
|
||||
{ return ((qHash(key.path) << 2) | key.type) ^ seed; }
|
||||
|
||||
class CPPTOOLS_EXPORT ProjectInfo
|
||||
{
|
||||
public:
|
||||
ProjectInfo();
|
||||
ProjectInfo(QPointer<ProjectExplorer::Project> project);
|
||||
|
||||
operator bool() const;
|
||||
bool isValid() const;
|
||||
bool isNull() const;
|
||||
|
||||
QPointer<ProjectExplorer::Project> project() const;
|
||||
const QList<ProjectPart::Ptr> projectParts() const;
|
||||
|
||||
void appendProjectPart(const ProjectPart::Ptr &part);
|
||||
void clearProjectParts();
|
||||
|
||||
const ProjectPart::HeaderPaths headerPaths() const;
|
||||
const QStringList sourceFiles() const;
|
||||
const QByteArray defines() const;
|
||||
|
||||
private:
|
||||
QPointer<ProjectExplorer::Project> m_project;
|
||||
QList<ProjectPart::Ptr> m_projectParts;
|
||||
// The members below are (re)calculated from the project parts once a part is appended.
|
||||
ProjectPart::HeaderPaths m_headerPaths;
|
||||
QStringList m_sourceFiles;
|
||||
QByteArray m_defines;
|
||||
};
|
||||
|
||||
} // namespace CppTools
|
||||
|
||||
#endif // CPPPROJECTPART_H
|
||||
@@ -36,6 +36,7 @@ HEADERS += \
|
||||
cppmodelmanagersupportinternal.h \
|
||||
cpppointerdeclarationformatter.h \
|
||||
cppprojectfile.h \
|
||||
cppprojects.h \
|
||||
cppqtstyleindenter.h \
|
||||
cpprefactoringchanges.h \
|
||||
cppsemanticinfo.h \
|
||||
@@ -93,6 +94,7 @@ SOURCES += \
|
||||
cppmodelmanagersupportinternal.cpp \
|
||||
cpppointerdeclarationformatter.cpp \
|
||||
cppprojectfile.cpp \
|
||||
cppprojects.cpp \
|
||||
cppqtstyleindenter.cpp \
|
||||
cpprefactoringchanges.cpp \
|
||||
cppsemanticinfo.cpp \
|
||||
|
||||
@@ -56,6 +56,7 @@ QtcPlugin {
|
||||
"cppmodelmanagersupportinternal.cpp", "cppmodelmanagersupportinternal.h",
|
||||
"cpppointerdeclarationformatter.cpp", "cpppointerdeclarationformatter.h",
|
||||
"cppprojectfile.cpp", "cppprojectfile.h",
|
||||
"cppprojects.cpp", "cppprojects.h",
|
||||
"cppqtstyleindenter.cpp", "cppqtstyleindenter.h",
|
||||
"cpprefactoringchanges.cpp", "cpprefactoringchanges.h",
|
||||
"cppsemanticinfo.cpp", "cppsemanticinfo.h",
|
||||
|
||||
@@ -433,8 +433,8 @@ QString correspondingHeaderOrSource(const QString &fileName, bool *wasHeader)
|
||||
// Find files in other projects
|
||||
} else {
|
||||
CppModelManager *modelManager = CppModelManager::instance();
|
||||
QList<CppModelManagerInterface::ProjectInfo> projectInfos = modelManager->projectInfos();
|
||||
foreach (const CppModelManagerInterface::ProjectInfo &projectInfo, projectInfos) {
|
||||
QList<ProjectInfo> projectInfos = modelManager->projectInfos();
|
||||
foreach (const ProjectInfo &projectInfo, projectInfos) {
|
||||
const ProjectExplorer::Project *project = projectInfo.project().data();
|
||||
if (project == currentProject)
|
||||
continue; // We have already checked the current project.
|
||||
|
||||
@@ -69,7 +69,6 @@ class ModelManagerTestHelper: public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
typedef CppModelManagerInterface::ProjectInfo ProjectInfo;
|
||||
typedef ProjectExplorer::Project Project;
|
||||
|
||||
explicit ModelManagerTestHelper(QObject *parent = 0);
|
||||
|
||||
Reference in New Issue
Block a user