Commit 2aa7df6d authored by Thomas Hartmann's avatar Thomas Hartmann Committed by Fawzi Mohamed
Browse files

QmlJS: Move ensuredGetDocumentForPath to ModelManagerInterface



The new function does properly update the latest snapshot.

Change-Id: If3148701e2f98c39a0822d1395b43f4fa7ee1949
Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@digia.com>
parent bafe7dbb
......@@ -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;
......
......@@ -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);
......
......@@ -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
......
Markdown is supported
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