forked from qt-creator/qt-creator
QmlJS: Rename SemanticHighlighter -> SemanticInfoUpdater.
Since it doesn't do any highlighting... Change-Id: I45d20735535fa1885153a725d0ca894326ce53db Reviewed-on: http://codereview.qt.nokia.com/2862 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
@@ -37,7 +37,7 @@
|
|||||||
#include "qmljseditorplugin.h"
|
#include "qmljseditorplugin.h"
|
||||||
#include "qmloutlinemodel.h"
|
#include "qmloutlinemodel.h"
|
||||||
#include "qmljsfindreferences.h"
|
#include "qmljsfindreferences.h"
|
||||||
#include "qmljssemantichighlighter.h"
|
#include "qmljssemanticinfoupdater.h"
|
||||||
#include "qmljsautocompleter.h"
|
#include "qmljsautocompleter.h"
|
||||||
#include "qmljscompletionassist.h"
|
#include "qmljscompletionassist.h"
|
||||||
#include "qmljsquickfixassist.h"
|
#include "qmljsquickfixassist.h"
|
||||||
@@ -661,8 +661,8 @@ QmlJSTextEditorWidget::QmlJSTextEditorWidget(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
qRegisterMetaType<QmlJSEditor::SemanticInfo>("QmlJSEditor::SemanticInfo");
|
qRegisterMetaType<QmlJSEditor::SemanticInfo>("QmlJSEditor::SemanticInfo");
|
||||||
|
|
||||||
m_semanticHighlighter = new SemanticHighlighter(this);
|
m_semanticInfoUpdater = new SemanticInfoUpdater(this);
|
||||||
m_semanticHighlighter->start();
|
m_semanticInfoUpdater->start();
|
||||||
|
|
||||||
setParenthesesMatchingEnabled(true);
|
setParenthesesMatchingEnabled(true);
|
||||||
setMarksVisible(true);
|
setMarksVisible(true);
|
||||||
@@ -680,10 +680,10 @@ QmlJSTextEditorWidget::QmlJSTextEditorWidget(QWidget *parent) :
|
|||||||
m_updateUsesTimer->setSingleShot(true);
|
m_updateUsesTimer->setSingleShot(true);
|
||||||
connect(m_updateUsesTimer, SIGNAL(timeout()), this, SLOT(updateUsesNow()));
|
connect(m_updateUsesTimer, SIGNAL(timeout()), this, SLOT(updateUsesNow()));
|
||||||
|
|
||||||
m_semanticRehighlightTimer = new QTimer(this);
|
m_localReparseTimer = new QTimer(this);
|
||||||
m_semanticRehighlightTimer->setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL);
|
m_localReparseTimer->setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL);
|
||||||
m_semanticRehighlightTimer->setSingleShot(true);
|
m_localReparseTimer->setSingleShot(true);
|
||||||
connect(m_semanticRehighlightTimer, SIGNAL(timeout()), this, SLOT(forceSemanticRehighlightIfCurrentEditor()));
|
connect(m_localReparseTimer, SIGNAL(timeout()), this, SLOT(forceReparseIfCurrentEditor()));
|
||||||
|
|
||||||
connect(this, SIGNAL(textChanged()), this, SLOT(updateDocument()));
|
connect(this, SIGNAL(textChanged()), this, SLOT(updateDocument()));
|
||||||
|
|
||||||
@@ -719,15 +719,15 @@ QmlJSTextEditorWidget::QmlJSTextEditorWidget(QWidget *parent) :
|
|||||||
m_oldCursorPosition = -1;
|
m_oldCursorPosition = -1;
|
||||||
|
|
||||||
if (m_modelManager) {
|
if (m_modelManager) {
|
||||||
m_semanticHighlighter->setModelManager(m_modelManager);
|
m_semanticInfoUpdater->setModelManager(m_modelManager);
|
||||||
connect(m_modelManager, SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
|
connect(m_modelManager, SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
|
||||||
this, SLOT(onDocumentUpdated(QmlJS::Document::Ptr)));
|
this, SLOT(onDocumentUpdated(QmlJS::Document::Ptr)));
|
||||||
connect(m_modelManager, SIGNAL(libraryInfoUpdated(QString,QmlJS::LibraryInfo)),
|
connect(m_modelManager, SIGNAL(libraryInfoUpdated(QString,QmlJS::LibraryInfo)),
|
||||||
this, SLOT(forceSemanticRehighlightIfCurrentEditor()));
|
this, SLOT(forceReparseIfCurrentEditor()));
|
||||||
connect(this->document(), SIGNAL(modificationChanged(bool)), this, SLOT(modificationChanged(bool)));
|
connect(this->document(), SIGNAL(modificationChanged(bool)), this, SLOT(modificationChanged(bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(m_semanticHighlighter, SIGNAL(changed(QmlJSEditor::SemanticInfo)),
|
connect(m_semanticInfoUpdater, SIGNAL(updated(QmlJSEditor::SemanticInfo)),
|
||||||
this, SLOT(updateSemanticInfo(QmlJSEditor::SemanticInfo)));
|
this, SLOT(updateSemanticInfo(QmlJSEditor::SemanticInfo)));
|
||||||
|
|
||||||
connect(this, SIGNAL(refactorMarkerClicked(TextEditor::RefactorMarker)),
|
connect(this, SIGNAL(refactorMarkerClicked(TextEditor::RefactorMarker)),
|
||||||
@@ -739,8 +739,8 @@ QmlJSTextEditorWidget::QmlJSTextEditorWidget(QWidget *parent) :
|
|||||||
QmlJSTextEditorWidget::~QmlJSTextEditorWidget()
|
QmlJSTextEditorWidget::~QmlJSTextEditorWidget()
|
||||||
{
|
{
|
||||||
hideContextPane();
|
hideContextPane();
|
||||||
m_semanticHighlighter->abort();
|
m_semanticInfoUpdater->abort();
|
||||||
m_semanticHighlighter->wait();
|
m_semanticInfoUpdater->wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
SemanticInfo QmlJSTextEditorWidget::semanticInfo() const
|
SemanticInfo QmlJSTextEditorWidget::semanticInfo() const
|
||||||
@@ -853,15 +853,15 @@ void QmlJSTextEditorWidget::onDocumentUpdated(QmlJS::Document::Ptr doc)
|
|||||||
|| doc->editorRevision() != document()->revision()) {
|
|| doc->editorRevision() != document()->revision()) {
|
||||||
// maybe a dependency changed: schedule a potential rehighlight
|
// maybe a dependency changed: schedule a potential rehighlight
|
||||||
// will not rehighlight if the current editor changes away from this file
|
// will not rehighlight if the current editor changes away from this file
|
||||||
m_semanticRehighlightTimer->start();
|
m_localReparseTimer->start();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doc->ast()) {
|
if (doc->ast()) {
|
||||||
// got a correctly parsed (or recovered) file.
|
// got a correctly parsed (or recovered) file.
|
||||||
|
|
||||||
const SemanticHighlighterSource source = currentSource(/*force = */ true);
|
const SemanticInfoUpdaterSource source = currentSource(/*force = */ true);
|
||||||
m_semanticHighlighter->rehighlight(source);
|
m_semanticInfoUpdater->update(source);
|
||||||
} else {
|
} else {
|
||||||
// show parsing errors
|
// show parsing errors
|
||||||
QList<QTextEdit::ExtraSelection> selections;
|
QList<QTextEdit::ExtraSelection> selections;
|
||||||
@@ -1496,28 +1496,28 @@ void QmlJSTextEditorWidget::setTabSettings(const TextEditor::TabSettings &ts)
|
|||||||
TextEditor::BaseTextEditorWidget::setTabSettings(ts);
|
TextEditor::BaseTextEditorWidget::setTabSettings(ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSTextEditorWidget::forceSemanticRehighlight()
|
void QmlJSTextEditorWidget::forceReparse()
|
||||||
{
|
{
|
||||||
m_semanticHighlighter->rehighlight(currentSource(/* force = */ true));
|
m_semanticInfoUpdater->update(currentSource(/* force = */ true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSEditor::QmlJSTextEditorWidget::forceSemanticRehighlightIfCurrentEditor()
|
void QmlJSEditor::QmlJSTextEditorWidget::forceReparseIfCurrentEditor()
|
||||||
{
|
{
|
||||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||||
if (editorManager->currentEditor() == editor())
|
if (editorManager->currentEditor() == editor())
|
||||||
forceSemanticRehighlight();
|
forceReparse();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSTextEditorWidget::semanticRehighlight()
|
void QmlJSTextEditorWidget::reparse()
|
||||||
{
|
{
|
||||||
m_semanticHighlighter->rehighlight(currentSource());
|
m_semanticInfoUpdater->update(currentSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSTextEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo)
|
void QmlJSTextEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo)
|
||||||
{
|
{
|
||||||
if (semanticInfo.revision() != document()->revision()) {
|
if (semanticInfo.revision() != document()->revision()) {
|
||||||
// got outdated semantic info
|
// got outdated semantic info
|
||||||
semanticRehighlight();
|
reparse();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1620,7 +1620,7 @@ QVector<QString> QmlJSTextEditorWidget::highlighterFormatCategories()
|
|||||||
return categories;
|
return categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
SemanticHighlighterSource QmlJSTextEditorWidget::currentSource(bool force)
|
SemanticInfoUpdaterSource QmlJSTextEditorWidget::currentSource(bool force)
|
||||||
{
|
{
|
||||||
int line = 0, column = 0;
|
int line = 0, column = 0;
|
||||||
convertPosition(position(), &line, &column);
|
convertPosition(position(), &line, &column);
|
||||||
@@ -1633,7 +1633,7 @@ SemanticHighlighterSource QmlJSTextEditorWidget::currentSource(bool force)
|
|||||||
code = toPlainText(); // get the source code only when needed.
|
code = toPlainText(); // get the source code only when needed.
|
||||||
|
|
||||||
const unsigned revision = document()->revision();
|
const unsigned revision = document()->revision();
|
||||||
SemanticHighlighterSource source(snapshot, fileName, code,
|
SemanticInfoUpdaterSource source(snapshot, fileName, code,
|
||||||
line, column, revision);
|
line, column, revision);
|
||||||
source.force = force;
|
source.force = force;
|
||||||
return source;
|
return source;
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ class FindReferences;
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class QmlOutlineModel;
|
class QmlOutlineModel;
|
||||||
class SemanticHighlighter;
|
class SemanticInfoUpdater;
|
||||||
struct SemanticHighlighterSource;
|
struct SemanticInfoUpdaterSource;
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
struct QMLJSEDITOR_EXPORT Declaration
|
struct QMLJSEDITOR_EXPORT Declaration
|
||||||
@@ -140,7 +140,7 @@ public: // attributes
|
|||||||
private:
|
private:
|
||||||
QSharedPointer<const QmlJS::ScopeChain> m_rootScopeChain;
|
QSharedPointer<const QmlJS::ScopeChain> m_rootScopeChain;
|
||||||
|
|
||||||
friend class Internal::SemanticHighlighter;
|
friend class Internal::SemanticInfoUpdater;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QMLJSEDITOR_EXPORT QmlJSTextEditorWidget : public TextEditor::BaseTextEditorWidget
|
class QMLJSEDITOR_EXPORT QmlJSTextEditorWidget : public TextEditor::BaseTextEditorWidget
|
||||||
@@ -170,7 +170,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void setTabSettings(const TextEditor::TabSettings &ts);
|
virtual void setTabSettings(const TextEditor::TabSettings &ts);
|
||||||
void forceSemanticRehighlight();
|
void forceReparse();
|
||||||
void followSymbolUnderCursor();
|
void followSymbolUnderCursor();
|
||||||
void findUsages();
|
void findUsages();
|
||||||
void renameUsages();
|
void renameUsages();
|
||||||
@@ -197,8 +197,8 @@ private slots:
|
|||||||
void updateUses();
|
void updateUses();
|
||||||
void updateUsesNow();
|
void updateUsesNow();
|
||||||
|
|
||||||
void semanticRehighlight();
|
void reparse();
|
||||||
void forceSemanticRehighlightIfCurrentEditor();
|
void forceReparseIfCurrentEditor();
|
||||||
void updateSemanticInfo(const QmlJSEditor::SemanticInfo &semanticInfo);
|
void updateSemanticInfo(const QmlJSEditor::SemanticInfo &semanticInfo);
|
||||||
void onCursorPositionChanged();
|
void onCursorPositionChanged();
|
||||||
void onRefactorMarkerClicked(const TextEditor::RefactorMarker &marker);
|
void onRefactorMarkerClicked(const TextEditor::RefactorMarker &marker);
|
||||||
@@ -221,7 +221,7 @@ private:
|
|||||||
void setSelectedElements();
|
void setSelectedElements();
|
||||||
QString wordUnderCursor() const;
|
QString wordUnderCursor() const;
|
||||||
|
|
||||||
Internal::SemanticHighlighterSource currentSource(bool force = false);
|
Internal::SemanticInfoUpdaterSource currentSource(bool force = false);
|
||||||
QModelIndex indexForPosition(unsigned cursorPosition, const QModelIndex &rootIndex = QModelIndex()) const;
|
QModelIndex indexForPosition(unsigned cursorPosition, const QModelIndex &rootIndex = QModelIndex()) const;
|
||||||
bool hideContextPane();
|
bool hideContextPane();
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ private:
|
|||||||
|
|
||||||
QTimer *m_updateDocumentTimer;
|
QTimer *m_updateDocumentTimer;
|
||||||
QTimer *m_updateUsesTimer;
|
QTimer *m_updateUsesTimer;
|
||||||
QTimer *m_semanticRehighlightTimer;
|
QTimer *m_localReparseTimer;
|
||||||
QTimer *m_updateOutlineTimer;
|
QTimer *m_updateOutlineTimer;
|
||||||
QTimer *m_updateOutlineIndexTimer;
|
QTimer *m_updateOutlineIndexTimer;
|
||||||
QTimer *m_cursorPositionTimer;
|
QTimer *m_cursorPositionTimer;
|
||||||
@@ -241,7 +241,7 @@ private:
|
|||||||
QTextCharFormat m_occurrencesUnusedFormat;
|
QTextCharFormat m_occurrencesUnusedFormat;
|
||||||
QTextCharFormat m_occurrenceRenameFormat;
|
QTextCharFormat m_occurrenceRenameFormat;
|
||||||
|
|
||||||
Internal::SemanticHighlighter *m_semanticHighlighter;
|
Internal::SemanticInfoUpdater *m_semanticInfoUpdater;
|
||||||
SemanticInfo m_semanticInfo;
|
SemanticInfo m_semanticInfo;
|
||||||
|
|
||||||
QList<TextEditor::QuickFixOperation::Ptr> m_quickFixes;
|
QList<TextEditor::QuickFixOperation::Ptr> m_quickFixes;
|
||||||
|
|||||||
@@ -29,14 +29,14 @@ HEADERS += \
|
|||||||
qmljscomponentnamedialog.h \
|
qmljscomponentnamedialog.h \
|
||||||
qmljsfindreferences.h \
|
qmljsfindreferences.h \
|
||||||
qmljseditoreditable.h \
|
qmljseditoreditable.h \
|
||||||
qmljssemantichighlighter.h \
|
|
||||||
qmljsautocompleter.h \
|
qmljsautocompleter.h \
|
||||||
jsfilewizard.h \
|
jsfilewizard.h \
|
||||||
qmljssnippetprovider.h \
|
qmljssnippetprovider.h \
|
||||||
qmljsreuse.h \
|
qmljsreuse.h \
|
||||||
qmljsquickfixassist.h \
|
qmljsquickfixassist.h \
|
||||||
qmljscompletionassist.h \
|
qmljscompletionassist.h \
|
||||||
qmljsquickfix.h
|
qmljsquickfix.h \
|
||||||
|
qmljssemanticinfoupdater.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
qmljseditor.cpp \
|
qmljseditor.cpp \
|
||||||
@@ -59,14 +59,14 @@ SOURCES += \
|
|||||||
qmljscomponentnamedialog.cpp \
|
qmljscomponentnamedialog.cpp \
|
||||||
qmljsfindreferences.cpp \
|
qmljsfindreferences.cpp \
|
||||||
qmljseditoreditable.cpp \
|
qmljseditoreditable.cpp \
|
||||||
qmljssemantichighlighter.cpp \
|
|
||||||
qmljsautocompleter.cpp \
|
qmljsautocompleter.cpp \
|
||||||
jsfilewizard.cpp \
|
jsfilewizard.cpp \
|
||||||
qmljssnippetprovider.cpp \
|
qmljssnippetprovider.cpp \
|
||||||
qmljsreuse.cpp \
|
qmljsreuse.cpp \
|
||||||
qmljsquickfixassist.cpp \
|
qmljsquickfixassist.cpp \
|
||||||
qmljscompletionassist.cpp \
|
qmljscompletionassist.cpp \
|
||||||
qmljsquickfix.cpp
|
qmljsquickfix.cpp \
|
||||||
|
qmljssemanticinfoupdater.cpp
|
||||||
|
|
||||||
RESOURCES += qmljseditor.qrc
|
RESOURCES += qmljseditor.qrc
|
||||||
OTHER_FILES += QmlJSEditor.mimetypes.xml
|
OTHER_FILES += QmlJSEditor.mimetypes.xml
|
||||||
@@ -74,3 +74,7 @@ OTHER_FILES += QmlJSEditor.mimetypes.xml
|
|||||||
FORMS += \
|
FORMS += \
|
||||||
quicktoolbarsettingspage.ui \
|
quicktoolbarsettingspage.ui \
|
||||||
qmljscomponentnamedialog.ui
|
qmljscomponentnamedialog.ui
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ void QmlJSEditorPlugin::currentEditorChanged(Core::IEditor *editor)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
else if (QmlJSTextEditorWidget *textEditor = qobject_cast<QmlJSTextEditorWidget *>(editor->widget())) {
|
else if (QmlJSTextEditorWidget *textEditor = qobject_cast<QmlJSTextEditorWidget *>(editor->widget())) {
|
||||||
textEditor->forceSemanticRehighlight();
|
textEditor->forceReparse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "qmljssemantichighlighter.h"
|
#include "qmljssemanticinfoupdater.h"
|
||||||
|
|
||||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||||
#include <qmljs/qmljsdocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
@@ -41,39 +41,39 @@
|
|||||||
namespace QmlJSEditor {
|
namespace QmlJSEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
SemanticHighlighter::SemanticHighlighter(QObject *parent)
|
SemanticInfoUpdater::SemanticInfoUpdater(QObject *parent)
|
||||||
: QThread(parent),
|
: QThread(parent),
|
||||||
m_done(false),
|
m_done(false),
|
||||||
m_modelManager(0)
|
m_modelManager(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SemanticHighlighter::~SemanticHighlighter()
|
SemanticInfoUpdater::~SemanticInfoUpdater()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SemanticHighlighter::abort()
|
void SemanticInfoUpdater::abort()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
m_done = true;
|
m_done = true;
|
||||||
m_condition.wakeOne();
|
m_condition.wakeOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SemanticHighlighter::rehighlight(const SemanticHighlighterSource &source)
|
void SemanticInfoUpdater::update(const SemanticInfoUpdaterSource &source)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
m_source = source;
|
m_source = source;
|
||||||
m_condition.wakeOne();
|
m_condition.wakeOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SemanticHighlighter::isOutdated()
|
bool SemanticInfoUpdater::isOutdated()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
const bool outdated = ! m_source.fileName.isEmpty() || m_done;
|
const bool outdated = ! m_source.fileName.isEmpty() || m_done;
|
||||||
return outdated;
|
return outdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SemanticHighlighter::run()
|
void SemanticInfoUpdater::run()
|
||||||
{
|
{
|
||||||
setPriority(QThread::LowestPriority);
|
setPriority(QThread::LowestPriority);
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ void SemanticHighlighter::run()
|
|||||||
m_condition.wait(&m_mutex);
|
m_condition.wait(&m_mutex);
|
||||||
|
|
||||||
const bool done = m_done;
|
const bool done = m_done;
|
||||||
const SemanticHighlighterSource source = m_source;
|
const SemanticInfoUpdaterSource source = m_source;
|
||||||
m_source.clear();
|
m_source.clear();
|
||||||
|
|
||||||
m_mutex.unlock();
|
m_mutex.unlock();
|
||||||
@@ -99,12 +99,12 @@ void SemanticHighlighter::run()
|
|||||||
m_lastSemanticInfo = info;
|
m_lastSemanticInfo = info;
|
||||||
m_mutex.unlock();
|
m_mutex.unlock();
|
||||||
|
|
||||||
emit changed(info);
|
emit updated(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SemanticInfo SemanticHighlighter::semanticInfo(const SemanticHighlighterSource &source)
|
SemanticInfo SemanticInfoUpdater::semanticInfo(const SemanticInfoUpdaterSource &source)
|
||||||
{
|
{
|
||||||
m_mutex.lock();
|
m_mutex.lock();
|
||||||
const int revision = m_lastSemanticInfo.revision();
|
const int revision = m_lastSemanticInfo.revision();
|
||||||
@@ -146,7 +146,7 @@ SemanticInfo SemanticHighlighter::semanticInfo(const SemanticHighlighterSource &
|
|||||||
return semanticInfo;
|
return semanticInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SemanticHighlighter::setModelManager(QmlJS::ModelManagerInterface *modelManager)
|
void SemanticInfoUpdater::setModelManager(QmlJS::ModelManagerInterface *modelManager)
|
||||||
{
|
{
|
||||||
m_modelManager = modelManager;
|
m_modelManager = modelManager;
|
||||||
}
|
}
|
||||||
@@ -30,8 +30,8 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#ifndef SEMANTICHIGHLIGHTER_H
|
#ifndef SEMANTICINFOUPDATER_H
|
||||||
#define SEMANTICHIGHLIGHTER_H
|
#define SEMANTICINFOUPDATER_H
|
||||||
|
|
||||||
#include "qmljseditor.h"
|
#include "qmljseditor.h"
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
namespace QmlJSEditor {
|
namespace QmlJSEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
struct SemanticHighlighterSource
|
struct SemanticInfoUpdaterSource
|
||||||
{
|
{
|
||||||
QmlJS::Snapshot snapshot;
|
QmlJS::Snapshot snapshot;
|
||||||
QString fileName;
|
QString fileName;
|
||||||
@@ -53,11 +53,11 @@ struct SemanticHighlighterSource
|
|||||||
int revision;
|
int revision;
|
||||||
bool force;
|
bool force;
|
||||||
|
|
||||||
SemanticHighlighterSource()
|
SemanticInfoUpdaterSource()
|
||||||
: line(0), column(0), revision(0), force(false)
|
: line(0), column(0), revision(0), force(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
SemanticHighlighterSource(const QmlJS::Snapshot &snapshot,
|
SemanticInfoUpdaterSource(const QmlJS::Snapshot &snapshot,
|
||||||
const QString &fileName,
|
const QString &fileName,
|
||||||
const QString &code,
|
const QString &code,
|
||||||
int line, int column,
|
int line, int column,
|
||||||
@@ -79,33 +79,33 @@ struct SemanticHighlighterSource
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SemanticHighlighter: public QThread
|
class SemanticInfoUpdater: public QThread
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SemanticHighlighter(QObject *parent = 0);
|
SemanticInfoUpdater(QObject *parent = 0);
|
||||||
virtual ~SemanticHighlighter();
|
virtual ~SemanticInfoUpdater();
|
||||||
|
|
||||||
void abort();
|
void abort();
|
||||||
void rehighlight(const SemanticHighlighterSource &source);
|
void update(const SemanticInfoUpdaterSource &source);
|
||||||
void setModelManager(QmlJS::ModelManagerInterface *modelManager);
|
void setModelManager(QmlJS::ModelManagerInterface *modelManager);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void changed(const QmlJSEditor::SemanticInfo &semanticInfo);
|
void updated(const QmlJSEditor::SemanticInfo &semanticInfo);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void run();
|
virtual void run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isOutdated();
|
bool isOutdated();
|
||||||
SemanticInfo semanticInfo(const SemanticHighlighterSource &source);
|
SemanticInfo semanticInfo(const SemanticInfoUpdaterSource &source);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMutex m_mutex;
|
QMutex m_mutex;
|
||||||
QWaitCondition m_condition;
|
QWaitCondition m_condition;
|
||||||
bool m_done;
|
bool m_done;
|
||||||
SemanticHighlighterSource m_source;
|
SemanticInfoUpdaterSource m_source;
|
||||||
SemanticInfo m_lastSemanticInfo;
|
SemanticInfo m_lastSemanticInfo;
|
||||||
QmlJS::ModelManagerInterface *m_modelManager;
|
QmlJS::ModelManagerInterface *m_modelManager;
|
||||||
};
|
};
|
||||||
@@ -113,4 +113,4 @@ private:
|
|||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace QmlJSEditor
|
} // namespace QmlJSEditor
|
||||||
|
|
||||||
#endif // SEMANTICHIGHLIGHTER_H
|
#endif // SEMANTICINFOUPDATER_H
|
||||||
Reference in New Issue
Block a user