From ea5d923fe040e767112a405c0d83b0f05c31cbb6 Mon Sep 17 00:00:00 2001 From: Roberto Raggi <roberto.raggi@nokia.com> Date: Tue, 14 Dec 2010 15:04:46 +0100 Subject: [PATCH] Don't waste time rehighlighting all the files opened in Creator. --- src/plugins/qmljseditor/qmljseditor.cpp | 3 --- src/plugins/qmljseditor/qmljseditor.h | 2 +- src/plugins/qmljseditor/qmljseditorplugin.cpp | 12 ++++++++++++ src/plugins/qmljseditor/qmljseditorplugin.h | 2 ++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index ba9392b3363..33f754290fa 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -803,9 +803,6 @@ void QmlJSTextEditor::onDocumentUpdated(QmlJS::Document::Ptr doc) { if (file()->fileName() != doc->fileName() || doc->editorRevision() != document()->revision()) { - // didn't get the currently open, or an up to date document. - // trigger a semantic rehighlight anyway, after a time - m_semanticRehighlightTimer->start(); return; } diff --git a/src/plugins/qmljseditor/qmljseditor.h b/src/plugins/qmljseditor/qmljseditor.h index d0ac90101ae..154dbe4eabd 100644 --- a/src/plugins/qmljseditor/qmljseditor.h +++ b/src/plugins/qmljseditor/qmljseditor.h @@ -158,6 +158,7 @@ public: static QVector<QString> highlighterFormatCategories(); public slots: + void forceSemanticRehighlight(); void followSymbolUnderCursor(); void findUsages(); void showContextPane(); @@ -187,7 +188,6 @@ private slots: void renameIdUnderCursor(); void semanticRehighlight(); - void forceSemanticRehighlight(); void updateSemanticInfo(const QmlJSEditor::SemanticInfo &semanticInfo); void onCursorPositionChanged(); void onRefactorMarkerClicked(const TextEditor::RefactorMarker &marker); diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index ef362840621..31385027cdd 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -241,6 +241,8 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e addAutoReleasedObject(new QuickToolBar); addAutoReleasedObject(new Internal::QuickToolBarSettingsPage); + connect(core->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)), SLOT(currentEditorChanged(Core::IEditor*))); + return true; } @@ -340,4 +342,14 @@ void QmlJSEditorPlugin::quickFixNow() } } +void QmlJSEditorPlugin::currentEditorChanged(Core::IEditor *editor) +{ + if (! editor) + return; + + else if (QmlJSTextEditor *textEditor = qobject_cast<QmlJSTextEditor *>(editor->widget())) { + textEditor->forceSemanticRehighlight(); + } +} + Q_EXPORT_PLUGIN(QmlJSEditorPlugin) diff --git a/src/plugins/qmljseditor/qmljseditorplugin.h b/src/plugins/qmljseditor/qmljseditorplugin.h index 786a2f26755..265f69c106b 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.h +++ b/src/plugins/qmljseditor/qmljseditorplugin.h @@ -45,6 +45,7 @@ namespace Core { class Command; class ActionContainer; class ActionManager; +class IEditor; } namespace TextEditor { @@ -95,6 +96,7 @@ public Q_SLOTS: private Q_SLOTS: void quickFix(TextEditor::ITextEditable *editable); void quickFixNow(); + void currentEditorChanged(Core::IEditor *editor); private: Core::Command *addToolAction(QAction *a, Core::ActionManager *am, Core::Context &context, const QString &name, -- GitLab