diff --git a/src/plugins/qmljseditor/qmljseditordocument.cpp b/src/plugins/qmljseditor/qmljseditordocument.cpp index 68b235d0c18..711b5c18403 100644 --- a/src/plugins/qmljseditor/qmljseditordocument.cpp +++ b/src/plugins/qmljseditor/qmljseditordocument.cpp @@ -587,12 +587,17 @@ void QmlJSEditorDocumentPrivate::acceptNewSemanticInfo(const SemanticInfo &seman void QmlJSEditorDocumentPrivate::updateOutlineModel() { - if (q->isSemanticInfoOutdated()) + if (isSemanticInfoOutdated()) return; // outline update will be retriggered when semantic info is updated m_outlineModel->update(m_semanticInfo); } +bool QmlJSEditorDocumentPrivate::isSemanticInfoOutdated() const +{ + return m_semanticInfo.revision() != q->document()->revision(); +} + static void cleanMarks(QVector *marks, TextEditor::TextDocument *doc) { // if doc is null, this method is improperly called, so better do nothing that leave an @@ -664,7 +669,7 @@ void QmlJSEditorDocumentPrivate::setSemanticWarningSource(QmllsStatus::Source ne m_semanticHighlighter->setEnableWarnings(false); cleanDiagnosticMarks(); cleanSemanticMarks(); - if (!q->isSemanticInfoOutdated()) { + if (m_semanticInfo.isValid() && !isSemanticInfoOutdated()) { // clean up underlines for warning messages m_semanticHighlightingNecessary = false; m_semanticHighlighter->rerun(m_semanticInfo); @@ -690,7 +695,7 @@ void QmlJSEditorDocumentPrivate::setSemanticHighlightSource(QmllsStatus::Source break; case QmllsStatus::Source::EmbeddedCodeModel: m_semanticHighlighter->setEnableHighlighting(true); - if (!q->isSemanticInfoOutdated()) { + if (m_semanticInfo.isValid() && !isSemanticInfoOutdated()) { m_semanticHighlightingNecessary = false; m_semanticHighlighter->rerun(m_semanticInfo); } @@ -835,7 +840,7 @@ const SemanticInfo &QmlJSEditorDocument::semanticInfo() const bool QmlJSEditorDocument::isSemanticInfoOutdated() const { - return d->m_semanticInfo.revision() != document()->revision(); + return d->isSemanticInfoOutdated(); } QVector QmlJSEditorDocument::diagnosticRanges() const diff --git a/src/plugins/qmljseditor/qmljseditordocument_p.h b/src/plugins/qmljseditor/qmljseditordocument_p.h index 7be1ec6d345..2cc21fe9fb6 100644 --- a/src/plugins/qmljseditor/qmljseditordocument_p.h +++ b/src/plugins/qmljseditor/qmljseditordocument_p.h @@ -48,6 +48,7 @@ public: void onDocumentUpdated(QmlJS::Document::Ptr doc); void reupdateSemanticInfo(); void acceptNewSemanticInfo(const QmlJSTools::SemanticInfo &semanticInfo); + bool isSemanticInfoOutdated() const; void updateOutlineModel(); void createTextMarks(const QList &diagnostics);