diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp index fb43abc65a9fa5a240d37c0e0e10051011e751bb..96aac5619d12bca32e9af5fad9b847f0457828b3 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp @@ -34,6 +34,24 @@ using namespace QmlJS; +/*! + \class QmlJS::ModelManagerInterface + \brief Interface to the global state of the QmlJS code model. + \sa QmlJS::Document QmlJS::Snapshot QmlJSTools::Internal::ModelManager + + The ModelManagerInterface is an interface for global state and actions in + the QmlJS code model. It is implemented by \l{QmlJSTools::Internal::ModelManager} + and the instance can be accessed through ModelManagerInterface::instance(). + + One of its primary concerns is to keep the Snapshots it + maintains up to date by parsing documents and finding QML modules. + + It has a Snapshot that contains only valid Documents, + accessible through ModelManagerInterface::snapshot() and a Snapshot with + potentially more recent, but invalid documents that is exposed through + ModelManagerInterface::newestSnapshot(). +*/ + static ModelManagerInterface *g_instance = 0; ModelManagerInterface::ModelManagerInterface(QObject *parent) diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.h b/src/libs/qmljs/qmljsmodelmanagerinterface.h index 17530e435936c6a9f5ba3f97e59f9032632b1fc6..c021341e5d6b0c4f7139e307b7259f376ed492e1 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.h +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.h @@ -119,7 +119,9 @@ public: static ModelManagerInterface *instance(); virtual WorkingCopy workingCopy() const = 0; - virtual QmlJS::Snapshot snapshot(bool preferValid = true) const = 0; + + virtual QmlJS::Snapshot snapshot() const = 0; + virtual QmlJS::Snapshot newestSnapshot() const = 0; virtual void updateSourceFiles(const QStringList &files, bool emitDocumentOnDiskChanged) = 0; diff --git a/src/plugins/qmljseditor/qmltaskmanager.cpp b/src/plugins/qmljseditor/qmltaskmanager.cpp index 93e17201cfd888fec64db883caf7747ce524fa40..2a59adc8f6f7fe8a1aa07b3c89103f4ec657f911 100644 --- a/src/plugins/qmljseditor/qmltaskmanager.cpp +++ b/src/plugins/qmljseditor/qmltaskmanager.cpp @@ -153,7 +153,7 @@ void QmlTaskManager::updateMessagesNow(bool updateSemantic) // process them QFuture<FileErrorMessages> future = QtConcurrent::run<FileErrorMessages>( - &collectMessages, modelManager->snapshot(false), modelManager->projectInfos(), + &collectMessages, modelManager->newestSnapshot(), modelManager->projectInfos(), modelManager->importPaths(), updateSemantic); m_messageCollector.setFuture(future); } diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp index 545761ad7e117c87efc76615a12230fc96c49739..bc4c1cfc94d26434ff34b88f7bf6c85c7fae9da0 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.cpp +++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp @@ -170,14 +170,16 @@ ModelManagerInterface::WorkingCopy ModelManager::workingCopy() const return workingCopy; } -Snapshot ModelManager::snapshot(bool preferValid) const +Snapshot ModelManager::snapshot() const { QMutexLocker locker(&m_mutex); + return _validSnapshot; +} - if (preferValid) - return _validSnapshot; - else - return _newestSnapshot; +Snapshot ModelManager::newestSnapshot() const +{ + QMutexLocker locker(&m_mutex); + return _newestSnapshot; } void ModelManager::updateSourceFiles(const QStringList &files, diff --git a/src/plugins/qmljstools/qmljsmodelmanager.h b/src/plugins/qmljstools/qmljsmodelmanager.h index 0a8c26fdbd1d007dd41e1c8d96a4ac4281ed27ce..a6803a008ff1e836be196fdb953bf0d55d52b257 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.h +++ b/src/plugins/qmljstools/qmljsmodelmanager.h @@ -69,7 +69,8 @@ public: void delayedInitialization(); virtual WorkingCopy workingCopy() const; - virtual QmlJS::Snapshot snapshot(bool preferValid = true) const; + virtual QmlJS::Snapshot snapshot() const; + virtual QmlJS::Snapshot newestSnapshot() const; virtual void updateSourceFiles(const QStringList &files, bool emitDocumentOnDiskChanged);