diff options
author | Thomas Hartmann <Thomas.Hartmann@digia.com> | 2014-06-26 13:52:36 +0200 |
---|---|---|
committer | Fawzi Mohamed <fawzi.mohamed@digia.com> | 2014-06-26 17:49:28 +0200 |
commit | 2aa7df6dff4725c42fe983f100289c700702a50c (patch) | |
tree | 14314c7fade3a9d4eeb9dd407789e26365708254 /src | |
parent | bafe7dbb0bb4622e98f7c3dbb9201a5c92f066b1 (diff) | |
download | qt-creator-2aa7df6dff4725c42fe983f100289c700702a50c.tar.gz |
QmlJS: Move ensuredGetDocumentForPath to ModelManagerInterface
The new function does properly update the latest snapshot.
Change-Id: If3148701e2f98c39a0822d1395b43f4fa7ee1949
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/qmljs/qmljsmodelmanagerinterface.cpp | 13 | ||||
-rw-r--r-- | src/libs/qmljs/qmljsmodelmanagerinterface.h | 3 | ||||
-rw-r--r-- | src/plugins/qmldesigner/qmldesignerplugin.cpp | 14 |
3 files changed, 18 insertions, 12 deletions
diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp index 34ca7fa672..98015f8171 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp @@ -1379,6 +1379,19 @@ void ModelManagerInterface::joinAllThreads() future.waitForFinished(); } +Document::Ptr ModelManagerInterface::ensuredGetDocumentForPath(const QString &filePath) +{ + QmlJS::Document::Ptr document = newestSnapshot().document(filePath); + if (!document) { + document = QmlJS::Document::create(filePath, QmlJS::Language::Qml); + QMutexLocker lock(&m_mutex); + + m_newestSnapshot.insert(document); + } + + return document; +} + void ModelManagerInterface::resetCodeModel() { QStringList documents; diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.h b/src/libs/qmljs/qmljsmodelmanagerinterface.h index 425f7bc2eb..6e53c21746 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.h +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.h @@ -199,6 +199,9 @@ public: // Blocks until all parsing threads are done. Used for testing. void joinAllThreads(); + + QmlJS::Document::Ptr ensuredGetDocumentForPath(const QString &filePath); + public slots: virtual void resetCodeModel(); void removeProjectInfo(ProjectExplorer::Project *project); diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp index 447746f26a..a251f9c6f2 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.cpp +++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp @@ -347,22 +347,12 @@ void QmlDesignerPlugin::resetModelSelection() currentDesignDocument()->rewriterView()->setSelectedModelNodes(QList<ModelNode>()); } -static QmlJS::Document::Ptr documentForFilePath(const QString &filePath) -{ - QmlJS::Document::Ptr document = QmlJS::ModelManagerInterface::instance()->snapshot().document(filePath); - if (!document) { - document = QmlJS::Document::create(filePath, QmlJS::Language::Qml); - QmlJS::ModelManagerInterface::instance()->snapshot().insert(document); - } - - return document; -} - static bool checkIfEditorIsQtQuick(Core::IEditor *editor) { if (editor) if (editor && editor->document()->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) { - QmlJS::Document::Ptr document = documentForFilePath(editor->document()->filePath()); + QmlJS::ModelManagerInterface *modelManager = QmlJS::ModelManagerInterface::instance(); + QmlJS::Document::Ptr document = modelManager->ensuredGetDocumentForPath(editor->document()->filePath()); if (!document.isNull()) return document->language() == QmlJS::Language::QmlQtQuick1 || document->language() == QmlJS::Language::QmlQtQuick2 |