forked from qt-creator/qt-creator
qml: moving most of ModelManager logic to ModelManageInterface
Currently ModelManager contains lot logic, but as it sits in QmlJSTools it is not possible to use it in standalone tests. Moving most of the logic to ModelManagerInterface (and cleanup) to allow better testing, and refactoring. This introduces a dependency of the qmljs lib on the cplusplus lib Also a (small) part of the CppTool::ModelManagerInterface has been moved to CPlusPlus::CppModelManagerBase to remove the dependency on CppTools to gather the Qml types exposed from C++. Change-Id: Icad7fe96dfd0f1a2b1058d82bd98c77c40aa5e9d Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
@@ -999,7 +999,7 @@ void CppModelManager::enableGarbageCollector(bool enable)
|
||||
m_enableGC = enable;
|
||||
}
|
||||
|
||||
void CppModelManager::setExtraDiagnostics(const QString &fileName,
|
||||
bool CppModelManager::setExtraDiagnostics(const QString &fileName,
|
||||
const QString &kind,
|
||||
const QList<Document::DiagnosticMessage> &diagnostics)
|
||||
{
|
||||
@@ -1013,9 +1013,10 @@ void CppModelManager::setExtraDiagnostics(const QString &fileName,
|
||||
foreach (CppEditorSupport *editorSupport, cppEditorSupports) {
|
||||
if (editorSupport->fileName() == fileName) {
|
||||
editorSupport->setExtraDiagnostics(kind, diagnostics);
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CppModelManager::setIfdefedOutBlocks(const QString &fileName,
|
||||
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
virtual void findMacroUsages(const CPlusPlus::Macro ¯o);
|
||||
virtual void renameMacroUsages(const CPlusPlus::Macro ¯o, const QString &replacement);
|
||||
|
||||
virtual void setExtraDiagnostics(const QString &fileName, const QString &key,
|
||||
virtual bool setExtraDiagnostics(const QString &fileName, const QString &key,
|
||||
const QList<Document::DiagnosticMessage> &diagnostics);
|
||||
virtual void setIfdefedOutBlocks(const QString &fileName,
|
||||
const QList<TextEditor::BlockRange> &ifdeffedOutBlocks);
|
||||
|
||||
@@ -164,8 +164,6 @@ void ProjectPart::evaluateToolchain(const ToolChain *tc,
|
||||
toolchainDefines = tc->predefinedMacros(cxxflags);
|
||||
}
|
||||
|
||||
static CppModelManagerInterface *g_instance = 0;
|
||||
|
||||
const QString CppModelManagerInterface::configurationFileName()
|
||||
{ return CPlusPlus::Preprocessor::configurationFileName; }
|
||||
|
||||
@@ -175,21 +173,15 @@ const QString CppModelManagerInterface::editorConfigurationFileName()
|
||||
}
|
||||
|
||||
CppModelManagerInterface::CppModelManagerInterface(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
Q_ASSERT(!g_instance);
|
||||
g_instance = this;
|
||||
}
|
||||
: CPlusPlus::CppModelManagerBase(parent)
|
||||
{ }
|
||||
|
||||
CppModelManagerInterface::~CppModelManagerInterface()
|
||||
{
|
||||
Q_ASSERT(g_instance == this);
|
||||
g_instance = 0;
|
||||
}
|
||||
{ }
|
||||
|
||||
CppModelManagerInterface *CppModelManagerInterface::instance()
|
||||
{
|
||||
return g_instance;
|
||||
return qobject_cast<CppModelManagerInterface *>(CPlusPlus::CppModelManagerBase::instance());
|
||||
}
|
||||
|
||||
void CppModelManagerInterface::ProjectInfo::clearProjectParts()
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "cppprojectfile.h"
|
||||
|
||||
#include <cplusplus/CppDocument.h>
|
||||
#include <cplusplus/cppmodelmanagerbase.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
||||
#include <QFuture>
|
||||
@@ -118,7 +119,7 @@ public:
|
||||
ProjectExplorer::ToolChain::WarningFlags cxxWarningFlags;
|
||||
};
|
||||
|
||||
class CPPTOOLS_EXPORT CppModelManagerInterface : public QObject
|
||||
class CPPTOOLS_EXPORT CppModelManagerInterface : public CPlusPlus::CppModelManagerBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -228,7 +229,6 @@ public:
|
||||
|
||||
virtual WorkingCopy workingCopy() const = 0;
|
||||
virtual QByteArray codeModelConfiguration() const = 0;
|
||||
virtual CPlusPlus::Snapshot snapshot() const = 0;
|
||||
|
||||
virtual QList<ProjectInfo> projectInfos() const = 0;
|
||||
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const = 0;
|
||||
@@ -255,8 +255,6 @@ public:
|
||||
virtual void renameMacroUsages(const CPlusPlus::Macro ¯o, const QString &replacement = QString()) = 0;
|
||||
virtual void findMacroUsages(const CPlusPlus::Macro ¯o) = 0;
|
||||
|
||||
virtual void setExtraDiagnostics(const QString &fileName, const QString &kind,
|
||||
const QList<CPlusPlus::Document::DiagnosticMessage> &diagnostics) = 0;
|
||||
virtual void setIfdefedOutBlocks(const QString &fileName,
|
||||
const QList<TextEditor::BlockRange> &ifdeffedOutBlocks) = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user