QString ObjectPropertiesView::propertyBaseClass(const QDeclarativeDebugObjectReference &object, const QDeclarativeDebugPropertyReference &property, int &depth) { ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance(); QmlJSEditor::ModelManagerInterface *modelManager = pluginManager->getObject<QmlJSEditor::ModelManagerInterface>(); QmlJS::Snapshot snapshot = modelManager->snapshot(); QmlJS::Document::Ptr document = snapshot.document(object.source().url().path()); if (document.isNull()) { QFile inFile(object.source().url().path()); QString contents; if (inFile.open(QIODevice::ReadOnly)) { QTextStream ins(&inFile); contents = ins.readAll(); inFile.close(); } document = QmlJS::Document::create(object.source().url().path()); document->setSource(contents); if (!document->parse()) return QString(); snapshot.insert(document); } PropertyTypeFinder find(document, snapshot, modelManager->importPaths()); QString baseClassName = find(object.source().lineNumber(), object.source().columnNumber(), property.name()); if (baseClassName.isEmpty()) { if (!object.idString().isEmpty()) baseClassName = object.idString(); else baseClassName = QString("<%1>").arg(object.className()); } depth = find.depth(); return baseClassName; }
void tst_QDeclarativeDebug::recursiveCompareObjects(const QDeclarativeDebugObjectReference &a, const QDeclarativeDebugObjectReference &b) const { QCOMPARE(a.debugId(), b.debugId()); QCOMPARE(a.className(), b.className()); QCOMPARE(a.name(), b.name()); QCOMPARE(a.contextDebugId(), b.contextDebugId()); QCOMPARE(a.source().url(), b.source().url()); QCOMPARE(a.source().lineNumber(), b.source().lineNumber()); QCOMPARE(a.source().columnNumber(), b.source().columnNumber()); QCOMPARE(a.properties().count(), b.properties().count()); QCOMPARE(a.children().count(), b.children().count()); QList<QDeclarativeDebugPropertyReference> aprops = a.properties(); QList<QDeclarativeDebugPropertyReference> bprops = b.properties(); for (int i=0; i<aprops.count(); i++) compareProperties(aprops[i], bprops[i]); for (int i=0; i<a.children().count(); i++) recursiveCompareObjects(a.children()[i], b.children()[i]); }