Commit 9c1cb774 authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS: Improve ModelManagerInterface API, add docs.

Change-Id: Ic65d767cbad85de89dffaac66d9e80d8d467f04a
Reviewed-on: http://codereview.qt.nokia.com/3851

Reviewed-by: default avatarLeandro T. C. Melo <leandro.melo@nokia.com>
parent 930e7b71
......@@ -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)
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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,
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment