QmlJS: Find setContextProperty calls in C++ and expose to QML.

Task-number: QTCREATORBUG-3199

Change-Id: I591490ceafadc0f5a07c63ec063f1bdfa7055f47
Reviewed-on: http://codereview.qt-project.org/4074
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
Christian Kamm
2011-08-25 12:35:55 +02:00
parent c2f31f16dc
commit 10a956a8f7
8 changed files with 327 additions and 71 deletions

View File

@@ -717,7 +717,8 @@ void ModelManager::updateCppQmlTypes(ModelManager *qmlModelManager,
CPlusPlus::CppModelManagerInterface *cppModelManager,
QMap<QString, QPair<CPlusPlus::Document::Ptr, bool> > documents)
{
CppQmlTypeHash newCppTypes = qmlModelManager->cppQmlTypes();
CppDataHash newData = qmlModelManager->cppData();
CPlusPlus::Snapshot snapshot = cppModelManager->snapshot();
FindExportedCppTypes finder(snapshot);
@@ -727,28 +728,33 @@ void ModelManager::updateCppQmlTypes(ModelManager *qmlModelManager,
const bool scan = pair.second;
const QString fileName = doc->fileName();
if (!scan) {
newCppTypes.remove(fileName);
newData.remove(fileName);
continue;
}
QList<LanguageUtils::FakeMetaObject::ConstPtr> exported = finder(doc);
finder(doc);
if (!exported.isEmpty())
newCppTypes[fileName] = exported;
else
newCppTypes.remove(fileName);
QList<LanguageUtils::FakeMetaObject::ConstPtr> exported = finder.exportedTypes();
QMap<QString, QString> contextProperties = finder.contextProperties();
if (exported.isEmpty() && contextProperties.isEmpty()) {
newData.remove(fileName);
} else {
CppData &data = newData[fileName];
data.exportedTypes = exported;
data.contextProperties = contextProperties;
}
doc->releaseSourceAndAST();
}
QMutexLocker locker(&qmlModelManager->m_cppTypesMutex);
qmlModelManager->m_cppTypes = newCppTypes;
QMutexLocker locker(&qmlModelManager->m_cppDataMutex);
qmlModelManager->m_cppDataHash = newData;
}
ModelManagerInterface::CppQmlTypeHash ModelManager::cppQmlTypes() const
ModelManager::CppDataHash ModelManager::cppData() const
{
QMutexLocker locker(&m_cppTypesMutex);
return m_cppTypes;
QMutexLocker locker(&m_cppDataMutex);
return m_cppDataHash;
}
LibraryInfo ModelManager::builtins(const Document::Ptr &doc) const