forked from qt-creator/qt-creator
qmljs: split scan function
allows to more easily scan the various qml dialects Change-Id: I9f8c44459e05e4658d3814c624e0f07762c83279 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -963,6 +963,41 @@ QmlLanguageBundles ModelManagerInterface::extendedBundles() const
|
|||||||
return m_extendedBundles;
|
return m_extendedBundles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModelManagerInterface::maybeScan(const QStringList &importPaths,
|
||||||
|
Language::Enum defaultLanguage)
|
||||||
|
{
|
||||||
|
QStringList pathToScan;
|
||||||
|
{
|
||||||
|
QMutexLocker l(&m_mutex);
|
||||||
|
foreach (QString importPath, importPaths)
|
||||||
|
if (!m_scannedPaths.contains(importPath)) {
|
||||||
|
pathToScan.append(importPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathToScan.count() > 1) {
|
||||||
|
QFuture<void> result = QtConcurrent::run(&ModelManagerInterface::importScan,
|
||||||
|
workingCopyInternal(), pathToScan,
|
||||||
|
this, defaultLanguage,
|
||||||
|
true);
|
||||||
|
|
||||||
|
if (m_synchronizer.futures().size() > 10) {
|
||||||
|
QList<QFuture<void> > futures = m_synchronizer.futures();
|
||||||
|
|
||||||
|
m_synchronizer.clearFutures();
|
||||||
|
|
||||||
|
foreach (const QFuture<void> &future, futures) {
|
||||||
|
if (! (future.isFinished() || future.isCanceled()))
|
||||||
|
m_synchronizer.addFuture(future);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_synchronizer.addFuture(result);
|
||||||
|
|
||||||
|
addTaskInternal(result, tr("QML import scan"), Constants::TASK_IMPORT_SCAN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ModelManagerInterface::updateImportPaths()
|
void ModelManagerInterface::updateImportPaths()
|
||||||
{
|
{
|
||||||
QStringList allImportPaths;
|
QStringList allImportPaths;
|
||||||
@@ -1026,36 +1061,7 @@ void ModelManagerInterface::updateImportPaths()
|
|||||||
|
|
||||||
if (!m_shouldScanImports)
|
if (!m_shouldScanImports)
|
||||||
return;
|
return;
|
||||||
QStringList pathToScan;
|
maybeScan(allImportPaths, Language::Qml);
|
||||||
{
|
|
||||||
QMutexLocker l(&m_mutex);
|
|
||||||
foreach (QString importPath, allImportPaths)
|
|
||||||
if (!m_scannedPaths.contains(importPath)) {
|
|
||||||
pathToScan.append(importPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathToScan.count() > 1) {
|
|
||||||
QFuture<void> result = QtConcurrent::run(&ModelManagerInterface::importScan,
|
|
||||||
workingCopyInternal(), pathToScan,
|
|
||||||
this, Language::Qml,
|
|
||||||
true);
|
|
||||||
|
|
||||||
if (m_synchronizer.futures().size() > 10) {
|
|
||||||
QList<QFuture<void> > futures = m_synchronizer.futures();
|
|
||||||
|
|
||||||
m_synchronizer.clearFutures();
|
|
||||||
|
|
||||||
foreach (const QFuture<void> &future, futures) {
|
|
||||||
if (! (future.isFinished() || future.isCanceled()))
|
|
||||||
m_synchronizer.addFuture(future);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_synchronizer.addFuture(result);
|
|
||||||
|
|
||||||
addTaskInternal(result, tr("QML import scan"), Constants::TASK_IMPORT_SCAN);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelManagerInterface::ProjectInfo ModelManagerInterface::defaultProjectInfo() const
|
ModelManagerInterface::ProjectInfo ModelManagerInterface::defaultProjectInfo() const
|
||||||
|
|||||||
@@ -244,6 +244,7 @@ protected:
|
|||||||
CPlusPlus::Snapshot snapshot,
|
CPlusPlus::Snapshot snapshot,
|
||||||
QHash<QString, QPair<CPlusPlus::Document::Ptr, bool> > documents);
|
QHash<QString, QPair<CPlusPlus::Document::Ptr, bool> > documents);
|
||||||
|
|
||||||
|
void maybeScan(const QStringList &importPaths, Language::Enum defaultLanguage);
|
||||||
void updateImportPaths();
|
void updateImportPaths();
|
||||||
void loadQmlTypeDescriptionsInternal(const QString &path);
|
void loadQmlTypeDescriptionsInternal(const QString &path);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user