summaryrefslogtreecommitdiff
path: root/src/libs/cplusplus
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/cplusplus')
-rw-r--r--src/libs/cplusplus/ModelManagerInterface.cpp43
-rw-r--r--src/libs/cplusplus/ModelManagerInterface.h88
2 files changed, 118 insertions, 13 deletions
diff --git a/src/libs/cplusplus/ModelManagerInterface.cpp b/src/libs/cplusplus/ModelManagerInterface.cpp
index 5dfce63cc9..18443186df 100644
--- a/src/libs/cplusplus/ModelManagerInterface.cpp
+++ b/src/libs/cplusplus/ModelManagerInterface.cpp
@@ -32,6 +32,8 @@
#include "ModelManagerInterface.h"
+#include <QtCore/QSet>
+
using namespace CPlusPlus;
static CppModelManagerInterface *g_instance = 0;
@@ -54,3 +56,44 @@ CppModelManagerInterface *CppModelManagerInterface::instance()
return g_instance;
}
+
+void CppModelManagerInterface::ProjectInfo::clearProjectParts()
+{
+ m_projectParts.clear();
+ m_includePaths.clear();
+ m_frameworkPaths.clear();
+ m_sourceFiles.clear();
+ m_defines.clear();
+}
+
+void CppModelManagerInterface::ProjectInfo::appendProjectPart(
+ const CppModelManagerInterface::ProjectPart::Ptr &part)
+{
+ if (!part)
+ return;
+
+ m_projectParts.append(part);
+
+ // update include paths
+ QSet<QString> incs = QSet<QString>::fromList(m_includePaths);
+ foreach (const QString &ins, part->includePaths)
+ incs.insert(ins);
+ m_includePaths = incs.toList();
+
+ // update framework paths
+ QSet<QString> frms = QSet<QString>::fromList(m_frameworkPaths);
+ foreach (const QString &frm, part->frameworkPaths)
+ frms.insert(frm);
+ m_frameworkPaths = frms.toList();
+
+ // update source files
+ QSet<QString> srcs = QSet<QString>::fromList(m_sourceFiles);
+ foreach (const QString &src, part->sourceFiles)
+ srcs.insert(src);
+ m_sourceFiles = srcs.toList();
+
+ // update defines
+ if (!m_defines.isEmpty())
+ m_defines.append('\n');
+ m_defines.append(part->defines);
+}
diff --git a/src/libs/cplusplus/ModelManagerInterface.h b/src/libs/cplusplus/ModelManagerInterface.h
index a057a601da..06ab239c68 100644
--- a/src/libs/cplusplus/ModelManagerInterface.h
+++ b/src/libs/cplusplus/ModelManagerInterface.h
@@ -35,6 +35,9 @@
#include <cplusplus/CppDocument.h>
#include <languageutils/fakemetaobject.h>
+#include <projectexplorer/project.h>
+#include <projectexplorer/toolchain.h>
+
#include <QObject>
#include <QHash>
#include <QPointer>
@@ -66,33 +69,88 @@ class CPLUSPLUS_EXPORT CppModelManagerInterface : public QObject
Q_OBJECT
public:
+ enum Language { CXX, OBJC };
+
+ class CPLUSPLUS_EXPORT ProjectPart
+ {
+ public:
+ ProjectPart()
+ : qtVersion(UnknownQt)
+ {}
+
+ public: //attributes
+ QStringList sourceFiles;
+ QByteArray defines;
+ QStringList includePaths;
+ QStringList frameworkPaths;
+ QStringList precompiledHeaders;
+ Language language;
+ ProjectExplorer::ToolChain::CompilerFlags flags;
+ enum QtVersion {
+ UnknownQt = -1,
+ NoQt = 0,
+ Qt4 = 1,
+ Qt5 = 2
+ };
+ QtVersion qtVersion;
+
+ bool cpp0xEnabled() const
+ { return flags == ProjectExplorer::ToolChain::STD_CXX11; }
+
+ bool objcEnabled() const
+ { return language == CppModelManagerInterface::OBJC; }
+
+ typedef QSharedPointer<ProjectPart> Ptr;
+ };
+
class ProjectInfo
{
public:
ProjectInfo()
{ }
- ProjectInfo(QPointer<ProjectExplorer::Project> project)
- : project(project)
+ ProjectInfo(QWeakPointer<ProjectExplorer::Project> project)
+ : m_project(project)
{ }
operator bool() const
- { return ! project.isNull(); }
+ { return ! m_project.isNull(); }
bool isValid() const
- { return ! project.isNull(); }
+ { return ! m_project.isNull(); }
bool isNull() const
- { return project.isNull(); }
+ { return m_project.isNull(); }
- public: // attributes
- QPointer<ProjectExplorer::Project> project;
- QString projectPath;
- QByteArray defines;
- QStringList sourceFiles;
- QStringList includePaths;
- QStringList frameworkPaths;
- QStringList precompiledHeaders;
+ QWeakPointer<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 QStringList includePaths() const
+ { return m_includePaths; }
+
+ const QStringList frameworkPaths() const
+ { return m_frameworkPaths; }
+
+ const QStringList sourceFiles() const
+ { return m_sourceFiles; }
+
+ const QByteArray defines() const
+ { return m_defines; }
+
+ private: // attributes
+ QWeakPointer<ProjectExplorer::Project> m_project;
+ QList<ProjectPart::Ptr> m_projectParts;
+ // the attributes below are calculated from the project parts.
+ QStringList m_includePaths;
+ QStringList m_frameworkPaths;
+ QStringList m_sourceFiles;
+ QByteArray m_defines;
};
class WorkingCopy
@@ -110,6 +168,9 @@ public:
QPair<QString, unsigned> get(const QString &fileName) const
{ return _elements.value(fileName); }
+ QHashIterator<QString, QPair<QString, unsigned> > iterator() const
+ { return QHashIterator<QString, QPair<QString, unsigned> >(_elements); }
+
private:
typedef QHash<QString, QPair<QString, unsigned> > Table;
Table _elements;
@@ -135,6 +196,7 @@ public:
virtual QList<ProjectInfo> projectInfos() const = 0;
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const = 0;
virtual void updateProjectInfo(const ProjectInfo &pinfo) = 0;
+ virtual QList<ProjectPart::Ptr> projectPart(const QString &fileName) const = 0;
virtual void addEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 0;
virtual void removeEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 0;