forked from qt-creator/qt-creator
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>
This commit is contained in:
committed by
Fawzi Mohamed
parent
bafe7dbb0b
commit
2aa7df6dff
@@ -1379,6 +1379,19 @@ void ModelManagerInterface::joinAllThreads()
|
|||||||
future.waitForFinished();
|
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()
|
void ModelManagerInterface::resetCodeModel()
|
||||||
{
|
{
|
||||||
QStringList documents;
|
QStringList documents;
|
||||||
|
@@ -199,6 +199,9 @@ public:
|
|||||||
|
|
||||||
// Blocks until all parsing threads are done. Used for testing.
|
// Blocks until all parsing threads are done. Used for testing.
|
||||||
void joinAllThreads();
|
void joinAllThreads();
|
||||||
|
|
||||||
|
QmlJS::Document::Ptr ensuredGetDocumentForPath(const QString &filePath);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void resetCodeModel();
|
virtual void resetCodeModel();
|
||||||
void removeProjectInfo(ProjectExplorer::Project *project);
|
void removeProjectInfo(ProjectExplorer::Project *project);
|
||||||
|
@@ -347,22 +347,12 @@ void QmlDesignerPlugin::resetModelSelection()
|
|||||||
currentDesignDocument()->rewriterView()->setSelectedModelNodes(QList<ModelNode>());
|
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)
|
static bool checkIfEditorIsQtQuick(Core::IEditor *editor)
|
||||||
{
|
{
|
||||||
if (editor)
|
if (editor)
|
||||||
if (editor && editor->document()->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
|
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())
|
if (!document.isNull())
|
||||||
return document->language() == QmlJS::Language::QmlQtQuick1
|
return document->language() == QmlJS::Language::QmlQtQuick1
|
||||||
|| document->language() == QmlJS::Language::QmlQtQuick2
|
|| document->language() == QmlJS::Language::QmlQtQuick2
|
||||||
|
Reference in New Issue
Block a user