qmlls: move isSematicInfoOutdated to private object

this avoid use of the (still unintialized q->d) in settingsChanged in
the constructor

Change-Id: Idd756fc88df166124c34a6177a9d598604634057
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Fawzi Mohamed
2022-10-13 14:13:00 +02:00
parent 8f9d582c6c
commit e27af202fc
2 changed files with 10 additions and 4 deletions

View File

@@ -587,12 +587,17 @@ void QmlJSEditorDocumentPrivate::acceptNewSemanticInfo(const SemanticInfo &seman
void QmlJSEditorDocumentPrivate::updateOutlineModel() void QmlJSEditorDocumentPrivate::updateOutlineModel()
{ {
if (q->isSemanticInfoOutdated()) if (isSemanticInfoOutdated())
return; // outline update will be retriggered when semantic info is updated return; // outline update will be retriggered when semantic info is updated
m_outlineModel->update(m_semanticInfo); m_outlineModel->update(m_semanticInfo);
} }
bool QmlJSEditorDocumentPrivate::isSemanticInfoOutdated() const
{
return m_semanticInfo.revision() != q->document()->revision();
}
static void cleanMarks(QVector<TextEditor::TextMark *> *marks, TextEditor::TextDocument *doc) static void cleanMarks(QVector<TextEditor::TextMark *> *marks, TextEditor::TextDocument *doc)
{ {
// if doc is null, this method is improperly called, so better do nothing that leave an // 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); m_semanticHighlighter->setEnableWarnings(false);
cleanDiagnosticMarks(); cleanDiagnosticMarks();
cleanSemanticMarks(); cleanSemanticMarks();
if (!q->isSemanticInfoOutdated()) { if (m_semanticInfo.isValid() && !isSemanticInfoOutdated()) {
// clean up underlines for warning messages // clean up underlines for warning messages
m_semanticHighlightingNecessary = false; m_semanticHighlightingNecessary = false;
m_semanticHighlighter->rerun(m_semanticInfo); m_semanticHighlighter->rerun(m_semanticInfo);
@@ -690,7 +695,7 @@ void QmlJSEditorDocumentPrivate::setSemanticHighlightSource(QmllsStatus::Source
break; break;
case QmllsStatus::Source::EmbeddedCodeModel: case QmllsStatus::Source::EmbeddedCodeModel:
m_semanticHighlighter->setEnableHighlighting(true); m_semanticHighlighter->setEnableHighlighting(true);
if (!q->isSemanticInfoOutdated()) { if (m_semanticInfo.isValid() && !isSemanticInfoOutdated()) {
m_semanticHighlightingNecessary = false; m_semanticHighlightingNecessary = false;
m_semanticHighlighter->rerun(m_semanticInfo); m_semanticHighlighter->rerun(m_semanticInfo);
} }
@@ -835,7 +840,7 @@ const SemanticInfo &QmlJSEditorDocument::semanticInfo() const
bool QmlJSEditorDocument::isSemanticInfoOutdated() const bool QmlJSEditorDocument::isSemanticInfoOutdated() const
{ {
return d->m_semanticInfo.revision() != document()->revision(); return d->isSemanticInfoOutdated();
} }
QVector<QTextLayout::FormatRange> QmlJSEditorDocument::diagnosticRanges() const QVector<QTextLayout::FormatRange> QmlJSEditorDocument::diagnosticRanges() const

View File

@@ -48,6 +48,7 @@ public:
void onDocumentUpdated(QmlJS::Document::Ptr doc); void onDocumentUpdated(QmlJS::Document::Ptr doc);
void reupdateSemanticInfo(); void reupdateSemanticInfo();
void acceptNewSemanticInfo(const QmlJSTools::SemanticInfo &semanticInfo); void acceptNewSemanticInfo(const QmlJSTools::SemanticInfo &semanticInfo);
bool isSemanticInfoOutdated() const;
void updateOutlineModel(); void updateOutlineModel();
void createTextMarks(const QList<QmlJS::DiagnosticMessage> &diagnostics); void createTextMarks(const QList<QmlJS::DiagnosticMessage> &diagnostics);