summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/qmljsinspector/qmljsinspector.cpp4
-rw-r--r--src/plugins/qmljsinspector/qmljslivetextpreview.cpp54
-rw-r--r--src/plugins/qmljsinspector/qmljslivetextpreview.h1
3 files changed, 40 insertions, 19 deletions
diff --git a/src/plugins/qmljsinspector/qmljsinspector.cpp b/src/plugins/qmljsinspector/qmljsinspector.cpp
index 57aed3284a..56b0ad772e 100644
--- a/src/plugins/qmljsinspector/qmljsinspector.cpp
+++ b/src/plugins/qmljsinspector/qmljsinspector.cpp
@@ -143,7 +143,7 @@ Inspector::Inspector(QObject *parent)
connect(m_clientProxy, SIGNAL(aboutToReloadEngines()), SLOT(aboutToReloadEngines()));
connect(m_clientProxy, SIGNAL(enginesChanged()), SLOT(updateEngineList()));
connect(m_clientProxy, SIGNAL(aboutToDisconnect()), SLOT(disconnectWidgets()));
- connect(m_clientProxy, SIGNAL(objectTreeUpdated(QDeclarativeDebugObjectReference)),SLOT(objectTreeUpdated(QDeclarativeDebugObjectReference)));
+ connect(m_clientProxy, SIGNAL(objectTreeUpdated(QDeclarativeDebugObjectReference)), SLOT(objectTreeUpdated(QDeclarativeDebugObjectReference)));
connect(Debugger::DebuggerPlugin::instance(),
SIGNAL(stateChanged(int)), this, SLOT(debuggerStateChanged(int)));
@@ -632,5 +632,3 @@ void QmlJSInspector::Internal::Inspector::objectTreeUpdated(const QDeclarativeDe
m_textPreview->m_initialTable = allDebugIds;
m_textPreview->m_debugIds.clear();
}
-
-
diff --git a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp
index 6733d5289a..b43bdf6946 100644
--- a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp
+++ b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp
@@ -52,15 +52,30 @@ void QmlJSLiveTextPreview::updateDocuments()
SLOT(documentChanged(QmlJS::Document::Ptr)));
}
+QList<QDeclarativeDebugObjectReference > QmlJSLiveTextPreview::objectReferencesForOffset(quint32 offset) const
+{
+ QList<QDeclarativeDebugObjectReference > result;
+ QHashIterator<QmlJS::AST::UiObjectMember*, QList<QDeclarativeDebugObjectReference > > iter(m_debugIds);
+ while(iter.hasNext()) {
+ iter.next();
+ QmlJS::AST::UiObjectMember *member = iter.key();
+ if (member->firstSourceLocation().offset == offset) {
+ result = iter.value();
+ break;
+ }
+ }
+ return result;
+}
+
void QmlJSLiveTextPreview::changeSelectedElements(QList<int> offsets, const QString &wordAtCursor)
{
- if (!m_currentEditor)
+ if (!m_currentEditor || !m_previousDoc)
return;
+ if (m_debugIds.isEmpty())
+ m_debugIds = m_initialTable.value(m_previousDoc->fileName());
+
ClientProxy *clientProxy = ClientProxy::instance();
- QUrl url = QUrl::fromLocalFile(m_currentEditor.data()->file()->fileName());
- QmlJS::Document::Ptr doc = modelManager()->snapshot().document(m_currentEditor.data()->file()->fileName());
- ScriptBindingParser info(doc, clientProxy->objectReferences(url));
QDeclarativeDebugObjectReference objectRefUnderCursor;
@@ -73,20 +88,21 @@ void QmlJSLiveTextPreview::changeSelectedElements(QList<int> offsets, const QStr
}
QList<QDeclarativeDebugObjectReference> selectedReferences;
+ bool containsReference = false;
foreach(int offset, offsets) {
if (offset >= 0) {
- QDeclarativeDebugObjectReference ref = info.objectReferenceForOffset(offset);
- if (ref.debugId() != -1)
- selectedReferences << ref;
- }
- }
-
- bool containsReference = false;
- foreach(const QDeclarativeDebugObjectReference &ref, selectedReferences) {
- if (ref.debugId() == objectRefUnderCursor.debugId()) {
- containsReference = true;
- break;
+ QList<QDeclarativeDebugObjectReference> list = objectReferencesForOffset(offset);
+
+ if (!containsReference) {
+ foreach(const QDeclarativeDebugObjectReference &ref, list) {
+ if (ref.debugId() == objectRefUnderCursor.debugId()) {
+ containsReference = true;
+ break;
+ }
+ }
+ }
+ selectedReferences << list;
}
}
@@ -103,12 +119,15 @@ void QmlJSLiveTextPreview::setEditor(Core::IEditor *editor)
disconnect(m_currentEditor.data(), SIGNAL(selectedElementsChanged(QList<int>, QString)), this, SLOT(changeSelectedElements(QList<int>, QString)));
m_currentEditor.clear();
m_previousDoc.clear();
+ m_debugIds.clear();
}
+
if (editor) {
m_currentEditor = qobject_cast<QmlJSEditor::Internal::QmlJSTextEditor*>(editor->widget());
if (m_currentEditor) {
connect(m_currentEditor.data(), SIGNAL(selectedElementsChanged(QList<int>, QString)), SLOT(changeSelectedElements(QList<int>, QString)));
m_previousDoc = m_snapshot.document(editor->file()->fileName());
+ m_debugIds = m_initialTable.value(editor->file()->fileName());
}
}
}
@@ -122,8 +141,11 @@ void QmlJSLiveTextPreview::documentChanged(QmlJS::Document::Ptr doc)
return;
if (doc && m_previousDoc && doc->fileName() == m_previousDoc->fileName()) {
+ if (m_debugIds.isEmpty())
+ m_debugIds = m_initialTable.value(doc->fileName());
Delta delta;
- delta(doc, m_previousDoc);
+ m_debugIds = delta(m_previousDoc, doc, m_debugIds);
+
m_previousDoc = doc;
}
}
diff --git a/src/plugins/qmljsinspector/qmljslivetextpreview.h b/src/plugins/qmljsinspector/qmljslivetextpreview.h
index 5f4469d1b5..6df8b13972 100644
--- a/src/plugins/qmljsinspector/qmljslivetextpreview.h
+++ b/src/plugins/qmljsinspector/qmljslivetextpreview.h
@@ -52,6 +52,7 @@ private slots:
void setEditor(Core::IEditor *editor);
private:
+ QList<QDeclarativeDebugObjectReference > objectReferencesForOffset(quint32 offset) const;
QVariant castToLiteral(const QString &expression, QmlJS::AST::UiScriptBinding *scriptBinding);
private: