aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmljseditor
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@digia.com>2014-01-23 15:28:06 +0100
committerEike Ziller <eike.ziller@digia.com>2014-01-29 10:15:55 +0100
commit782e0d37c3bec77dbeb03e3a39245d10732a6586 (patch)
tree1e494d33928c9f1250406160ae1500918ef69518 /src/plugins/qmljseditor
parent3422995521959e70c84e519df45867333d4ced2d (diff)
QmlJSEditor: Move reparse trigger to document
Change-Id: I65bb9002a44343bb1d13b9c5c92f5057c1d5b25e Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
Diffstat (limited to 'src/plugins/qmljseditor')
-rw-r--r--src/plugins/qmljseditor/qmljseditor.cpp20
-rw-r--r--src/plugins/qmljseditor/qmljseditor.h3
-rw-r--r--src/plugins/qmljseditor/qmljseditor.pro3
-rw-r--r--src/plugins/qmljseditor/qmljseditor.qbs1
-rw-r--r--src/plugins/qmljseditor/qmljseditordocument.cpp40
-rw-r--r--src/plugins/qmljseditor/qmljseditordocument.h8
-rw-r--r--src/plugins/qmljseditor/qmljseditordocument_p.h60
-rw-r--r--src/plugins/qmljseditor/qmljseditorplugin.cpp1
8 files changed, 105 insertions, 31 deletions
diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp
index bc59272e198..03f8532b730 100644
--- a/src/plugins/qmljseditor/qmljseditor.cpp
+++ b/src/plugins/qmljseditor/qmljseditor.cpp
@@ -479,11 +479,6 @@ void QmlJSTextEditorWidget::ctor()
setAutoCompleter(new AutoCompleter);
setLanguageSettingsId(QmlJSTools::Constants::QML_JS_SETTINGS_ID);
- m_updateDocumentTimer = new QTimer(this);
- m_updateDocumentTimer->setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL);
- m_updateDocumentTimer->setSingleShot(true);
- connect(m_updateDocumentTimer, SIGNAL(timeout()), this, SLOT(reparseDocumentNow()));
-
m_updateUsesTimer = new QTimer(this);
m_updateUsesTimer->setInterval(UPDATE_USES_DEFAULT_INTERVAL);
m_updateUsesTimer->setSingleShot(true);
@@ -494,8 +489,6 @@ void QmlJSTextEditorWidget::ctor()
m_updateSemanticInfoTimer->setSingleShot(true);
connect(m_updateSemanticInfoTimer, SIGNAL(timeout()), this, SLOT(updateSemanticInfoNow()));
- connect(this, SIGNAL(textChanged()), this, SLOT(reparseDocument()));
-
connect(this, SIGNAL(textChanged()), this, SLOT(updateUses()));
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateUses()));
@@ -610,19 +603,6 @@ bool QmlJSEditor::open(QString *errorString, const QString &fileName, const QStr
return b;
}
-void QmlJSTextEditorWidget::reparseDocument()
-{
- m_updateDocumentTimer->start();
-}
-
-void QmlJSTextEditorWidget::reparseDocumentNow()
-{
- m_updateDocumentTimer->stop();
-
- const QString fileName = baseTextDocument()->filePath();
- m_modelManager->updateSourceFiles(QStringList() << fileName, false);
-}
-
static void appendExtraSelectionsForMessages(
QList<QTextEdit::ExtraSelection> *selections,
const QList<DiagnosticMessage> &messages,
diff --git a/src/plugins/qmljseditor/qmljseditor.h b/src/plugins/qmljseditor/qmljseditor.h
index ce2ce7ed57f..ebaa0f4966f 100644
--- a/src/plugins/qmljseditor/qmljseditor.h
+++ b/src/plugins/qmljseditor/qmljseditor.h
@@ -119,8 +119,6 @@ public:
TextEditor::IAssistInterface *createAssistInterface(TextEditor::AssistKind assistKind,
TextEditor::AssistReason reason) const;
public slots:
- void reparseDocument();
- void reparseDocumentNow();
void updateSemanticInfo();
void updateSemanticInfoNow();
void findUsages();
@@ -177,7 +175,6 @@ private:
QModelIndex indexForPosition(unsigned cursorPosition, const QModelIndex &rootIndex = QModelIndex()) const;
bool hideContextPane();
- QTimer *m_updateDocumentTimer;
QTimer *m_updateUsesTimer;
QTimer *m_updateSemanticInfoTimer;
QTimer *m_updateOutlineTimer;
diff --git a/src/plugins/qmljseditor/qmljseditor.pro b/src/plugins/qmljseditor/qmljseditor.pro
index 57fc3342807..6b93b7913db 100644
--- a/src/plugins/qmljseditor/qmljseditor.pro
+++ b/src/plugins/qmljseditor/qmljseditor.pro
@@ -36,7 +36,8 @@ HEADERS += \
qmljssemanticinfoupdater.h \
qmljssemantichighlighter.h \
qmljswrapinloader.h \
- qmljseditordocument.h
+ qmljseditordocument.h \
+ qmljseditordocument_p.h
SOURCES += \
qmljseditor.cpp \
diff --git a/src/plugins/qmljseditor/qmljseditor.qbs b/src/plugins/qmljseditor/qmljseditor.qbs
index f9501ed4031..4ff7cabba63 100644
--- a/src/plugins/qmljseditor/qmljseditor.qbs
+++ b/src/plugins/qmljseditor/qmljseditor.qbs
@@ -38,6 +38,7 @@ QtcPlugin {
"qmljseditorconstants.h",
"qmljseditordocument.cpp",
"qmljseditordocument.h",
+ "qmljseditordocument_p.h",
"qmljseditoreditable.cpp",
"qmljseditoreditable.h",
"qmljseditorfactory.cpp",
diff --git a/src/plugins/qmljseditor/qmljseditordocument.cpp b/src/plugins/qmljseditor/qmljseditordocument.cpp
index bd56c3c677a..f7dad8ffa4c 100644
--- a/src/plugins/qmljseditor/qmljseditordocument.cpp
+++ b/src/plugins/qmljseditor/qmljseditordocument.cpp
@@ -29,22 +29,54 @@
#include "qmljseditordocument.h"
+#include "qmljseditordocument_p.h"
#include "qmljshighlighter.h"
#include <qmljstools/qmljsqtstylecodeformatter.h>
+#include <qmljstools/qmljsmodelmanager.h>
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
+namespace {
+
+enum {
+ UPDATE_DOCUMENT_DEFAULT_INTERVAL = 100
+};
+
+}
+
+QmlJSEditorDocumentPrivate::QmlJSEditorDocumentPrivate(QmlJSEditorDocument *parent)
+ : m_q(parent)
+{
+ m_updateDocumentTimer = new QTimer(this);
+ m_updateDocumentTimer->setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL);
+ m_updateDocumentTimer->setSingleShot(true);
+ connect(m_q->document(), SIGNAL(contentsChanged()), m_updateDocumentTimer, SLOT(start()));
+ connect(m_updateDocumentTimer, SIGNAL(timeout()), this, SLOT(reparseDocument()));
+}
+
+void QmlJSEditorDocumentPrivate::invalidateFormatterCache()
+{
+ QmlJSTools::CreatorCodeFormatter formatter(m_q->tabSettings());
+ formatter.invalidateCache(m_q->document());
+}
+
+void QmlJSEditorDocumentPrivate::reparseDocument()
+{
+ QmlJS::ModelManagerInterface::instance()->updateSourceFiles(QStringList() << m_q->filePath(),
+ false);
+}
+
QmlJSEditorDocument::QmlJSEditorDocument()
+ : m_d(new QmlJSEditorDocumentPrivate(this))
{
connect(this, SIGNAL(tabSettingsChanged()),
- this, SLOT(invalidateFormatterCache()));
+ m_d, SLOT(invalidateFormatterCache()));
setSyntaxHighlighter(new Highlighter(document()));
}
-void QmlJSEditorDocument::invalidateFormatterCache()
+QmlJSEditorDocument::~QmlJSEditorDocument()
{
- QmlJSTools::CreatorCodeFormatter formatter(tabSettings());
- formatter.invalidateCache(document());
+ delete m_d;
}
diff --git a/src/plugins/qmljseditor/qmljseditordocument.h b/src/plugins/qmljseditor/qmljseditordocument.h
index 1f0f5637d10..5970f3ee3e6 100644
--- a/src/plugins/qmljseditor/qmljseditordocument.h
+++ b/src/plugins/qmljseditor/qmljseditordocument.h
@@ -35,13 +35,17 @@
namespace QmlJSEditor {
namespace Internal {
+class QmlJSEditorDocumentPrivate;
+
class QmlJSEditorDocument : public TextEditor::BaseTextDocument
{
Q_OBJECT
public:
QmlJSEditorDocument();
-private slots:
- void invalidateFormatterCache();
+ ~QmlJSEditorDocument();
+
+private:
+ QmlJSEditorDocumentPrivate *m_d;
};
} // Internal
diff --git a/src/plugins/qmljseditor/qmljseditordocument_p.h b/src/plugins/qmljseditor/qmljseditordocument_p.h
new file mode 100644
index 00000000000..c425d358f08
--- /dev/null
+++ b/src/plugins/qmljseditor/qmljseditordocument_p.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef QMLJSEDITORDOCUMENT_P_H
+#define QMLJSEDITORDOCUMENT_P_H
+
+#include <QObject>
+#include <QTimer>
+
+namespace QmlJSEditor {
+namespace Internal {
+
+class QmlJSEditorDocument;
+
+class QmlJSEditorDocumentPrivate : public QObject
+{
+ Q_OBJECT
+
+public:
+ QmlJSEditorDocumentPrivate(QmlJSEditorDocument *parent);
+
+public slots:
+ void invalidateFormatterCache();
+ void reparseDocument();
+
+public:
+ QmlJSEditorDocument *m_q;
+ QTimer *m_updateDocumentTimer;
+};
+
+} // Internal
+} // QmlJSEditor
+
+#endif // QMLJSEDITORDOCUMENT_P_H
diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp
index 0820dd4b663..b12d1ec85ce 100644
--- a/src/plugins/qmljseditor/qmljseditorplugin.cpp
+++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp
@@ -320,7 +320,6 @@ void QmlJSEditorPlugin::currentEditorChanged(Core::IEditor *editor)
this, SLOT(checkCurrentEditorSemanticInfoUpToDate()));
connect(newTextEditor, SIGNAL(semanticInfoUpdated()),
this, SLOT(checkCurrentEditorSemanticInfoUpToDate()));
- newTextEditor->reparseDocumentNow();
}
}