Skip to content
Snippets Groups Projects
Commit d8d46ed1 authored by Olivier Goffart's avatar Olivier Goffart
Browse files

qmljsinspector: small code cleanup

parent 0fe26e80
No related branches found
No related tags found
No related merge requests found
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
#include <QUrl> #include <QUrl>
#include <QAbstractSocket> #include <QAbstractSocket>
#include <QDebug> #include <QDebug>
#include <QFileInfo>
using namespace QmlJSInspector::Internal; using namespace QmlJSInspector::Internal;
...@@ -199,24 +198,22 @@ QDeclarativeDebugObjectReference ClientProxy::objectReferenceForId(int debugId, ...@@ -199,24 +198,22 @@ QDeclarativeDebugObjectReference ClientProxy::objectReferenceForId(int debugId,
return QDeclarativeDebugObjectReference(); return QDeclarativeDebugObjectReference();
} }
QList<QDeclarativeDebugObjectReference> ClientProxy::objectReferences(const QUrl &url) const QList<QDeclarativeDebugObjectReference> ClientProxy::objectReferences() const
{ {
QList<QDeclarativeDebugObjectReference> result; QList<QDeclarativeDebugObjectReference> result;
foreach(const QDeclarativeDebugObjectReference &it, m_rootObjects) { foreach(const QDeclarativeDebugObjectReference &it, m_rootObjects) {
result.append(objectReferences(url, it)); result.append(objectReferences(it));
} }
return result; return result;
} }
QList<QDeclarativeDebugObjectReference> ClientProxy::objectReferences(const QUrl &url, QList<QDeclarativeDebugObjectReference> ClientProxy::objectReferences(const QDeclarativeDebugObjectReference &objectRef) const
const QDeclarativeDebugObjectReference &objectRef) const
{ {
QList<QDeclarativeDebugObjectReference> result; QList<QDeclarativeDebugObjectReference> result;
if (objectRef.source().url() == url || url.isEmpty()) result.append(objectRef);
result.append(objectRef);
foreach(const QDeclarativeDebugObjectReference &child, objectRef.children()) { foreach(const QDeclarativeDebugObjectReference &child, objectRef.children()) {
result.append(objectReferences(url, child)); result.append(objectReferences(child));
} }
return result; return result;
...@@ -353,6 +350,8 @@ void ClientProxy::buildDebugIdHashRecursive(const QDeclarativeDebugObjectReferen ...@@ -353,6 +350,8 @@ void ClientProxy::buildDebugIdHashRecursive(const QDeclarativeDebugObjectReferen
int lineNum = ref.source().lineNumber(); int lineNum = ref.source().lineNumber();
int colNum = ref.source().columnNumber(); int colNum = ref.source().columnNumber();
int rev = 0; int rev = 0;
// handle the case where the url contains the revision number encoded. (for object created by the debugger)
static QRegExp rx("^(.*)_(\\d+):(\\d+)$"); static QRegExp rx("^(.*)_(\\d+):(\\d+)$");
if (rx.exactMatch(filename)) { if (rx.exactMatch(filename)) {
filename = rx.cap(1); filename = rx.cap(1);
...@@ -365,13 +364,13 @@ void ClientProxy::buildDebugIdHashRecursive(const QDeclarativeDebugObjectReferen ...@@ -365,13 +364,13 @@ void ClientProxy::buildDebugIdHashRecursive(const QDeclarativeDebugObjectReferen
if (isShadowBuild && rev == 0) { if (isShadowBuild && rev == 0) {
QString shadowBuildDir = InspectorUi::instance()->debugProjectBuildDirectory(); QString shadowBuildDir = InspectorUi::instance()->debugProjectBuildDirectory();
//QFileInfo objectFileInfo(filename);
if (filename.startsWith(shadowBuildDir)) { if (filename.startsWith(shadowBuildDir)) {
ProjectExplorer::Project *debugProject = InspectorUi::instance()->debugProject(); ProjectExplorer::Project *debugProject = InspectorUi::instance()->debugProject();
filename = debugProject->projectDirectory() + filename.mid(shadowBuildDir.length()); filename = debugProject->projectDirectory() + filename.mid(shadowBuildDir.length());
} }
} }
// append the debug ids in the hash
m_debugIdHash[qMakePair<QString, int>(filename, rev)][qMakePair<int, int>(lineNum, colNum)].append(ref.debugId()); m_debugIdHash[qMakePair<QString, int>(filename, rev)][qMakePair<int, int>(lineNum, colNum)].append(ref.debugId());
foreach(const QDeclarativeDebugObjectReference &it, ref.children()) foreach(const QDeclarativeDebugObjectReference &it, ref.children())
......
...@@ -67,8 +67,8 @@ public: ...@@ -67,8 +67,8 @@ public:
bool resetBindingForObject(int objectDebugId, const QString &propertyName); bool resetBindingForObject(int objectDebugId, const QString &propertyName);
void clearComponentCache(); void clearComponentCache();
// returns the object references for the given url. // returns the object references
QList<QDeclarativeDebugObjectReference> objectReferences(const QUrl &url = QUrl()) const; QList<QDeclarativeDebugObjectReference> objectReferences() const;
QDeclarativeDebugObjectReference objectReferenceForId(int debugId) const; QDeclarativeDebugObjectReference objectReferenceForId(int debugId) const;
QList<QDeclarativeDebugObjectReference> rootObjectReference() const; QList<QDeclarativeDebugObjectReference> rootObjectReference() const;
DebugIdHash debugIdHash() const { return m_debugIdHash; }; DebugIdHash debugIdHash() const { return m_debugIdHash; };
...@@ -137,7 +137,7 @@ private: ...@@ -137,7 +137,7 @@ private:
bool isDesignClientConnected() const; bool isDesignClientConnected() const;
void reloadEngines(); void reloadEngines();
QList<QDeclarativeDebugObjectReference> objectReferences(const QUrl &url, const QDeclarativeDebugObjectReference &objectRef) const; QList<QDeclarativeDebugObjectReference> objectReferences(const QDeclarativeDebugObjectReference &objectRef) const;
QDeclarativeDebugObjectReference objectReferenceForId(int debugId, const QDeclarativeDebugObjectReference &ref) const; QDeclarativeDebugObjectReference objectReferenceForId(int debugId, const QDeclarativeDebugObjectReference &ref) const;
private: private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment