forked from qt-creator/qt-creator
qmljs: fix import cache
correct update of m_importCache Change-Id: I70a2c6777c8f0e8df7b130fcff96cd67f83ca3e4 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -719,10 +719,15 @@ void ImportDependencies::addCoreImport(const CoreImport &import)
|
|||||||
CoreImport newImport = import;
|
CoreImport newImport = import;
|
||||||
if (m_coreImports.contains(import.importId)) {
|
if (m_coreImports.contains(import.importId)) {
|
||||||
CoreImport oldVal = m_coreImports.value(import.importId);
|
CoreImport oldVal = m_coreImports.value(import.importId);
|
||||||
foreach (const Export &e, oldVal.possibleExports)
|
foreach (const Export &e, oldVal.possibleExports) {
|
||||||
if (!e.intrinsic)
|
if (e.intrinsic)
|
||||||
|
removeImportCacheEntry(e.exportName, import.importId);
|
||||||
|
else
|
||||||
newImport.possibleExports.append(e);
|
newImport.possibleExports.append(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
foreach (const Export &e, import.possibleExports)
|
||||||
|
m_importCache[e.exportName].append(import.importId);
|
||||||
m_coreImports.insert(newImport.importId, newImport);
|
m_coreImports.insert(newImport.importId, newImport);
|
||||||
if (debugImportDependencies) {
|
if (debugImportDependencies) {
|
||||||
QDebug dbg(qDebug());
|
QDebug dbg(qDebug());
|
||||||
@@ -741,16 +746,30 @@ void ImportDependencies::removeCoreImport(const QString &importId)
|
|||||||
CoreImport &cImport = m_coreImports[importId];
|
CoreImport &cImport = m_coreImports[importId];
|
||||||
QList<Export> newExports;
|
QList<Export> newExports;
|
||||||
foreach (const Export &e, cImport.possibleExports)
|
foreach (const Export &e, cImport.possibleExports)
|
||||||
if (!e.intrinsic)
|
if (e.intrinsic)
|
||||||
|
removeImportCacheEntry(e.exportName, importId);
|
||||||
|
else
|
||||||
newExports.append(e);
|
newExports.append(e);
|
||||||
if (newExports.size()>0)
|
if (newExports.size()>0)
|
||||||
cImport.possibleExports = newExports;
|
cImport.possibleExports = newExports;
|
||||||
else
|
else
|
||||||
m_coreImports.remove(importId);
|
m_coreImports.remove(importId);
|
||||||
|
|
||||||
if (debugImportDependencies)
|
if (debugImportDependencies)
|
||||||
qDebug() << "removed import with id:"<< importId;
|
qDebug() << "removed import with id:"<< importId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImportDependencies::removeImportCacheEntry(const ImportKey &importKey, const QString &importId)
|
||||||
|
{
|
||||||
|
QStringList &cImp = m_importCache[importKey];
|
||||||
|
if (!cImp.removeOne(importId)) {
|
||||||
|
qDebug() << "missing possibleExport backpointer for " << importKey.toString() << " to "
|
||||||
|
<< importId;
|
||||||
|
}
|
||||||
|
if (cImp.isEmpty())
|
||||||
|
m_importCache.remove(importKey);
|
||||||
|
}
|
||||||
|
|
||||||
void ImportDependencies::addExport(const QString &importId, const ImportKey &importKey,
|
void ImportDependencies::addExport(const QString &importId, const ImportKey &importKey,
|
||||||
const QString &requiredPath)
|
const QString &requiredPath)
|
||||||
{
|
{
|
||||||
@@ -759,10 +778,12 @@ void ImportDependencies::addExport(const QString &importId, const ImportKey &imp
|
|||||||
newImport.language = Language::Unknown;
|
newImport.language = Language::Unknown;
|
||||||
newImport.possibleExports.append(Export(importKey, requiredPath, false));
|
newImport.possibleExports.append(Export(importKey, requiredPath, false));
|
||||||
m_coreImports.insert(newImport.importId, newImport);
|
m_coreImports.insert(newImport.importId, newImport);
|
||||||
|
m_importCache[importKey].append(importId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CoreImport &importValue = m_coreImports[importId];
|
CoreImport &importValue = m_coreImports[importId];
|
||||||
importValue.possibleExports.append(Export(importKey, requiredPath, false));
|
importValue.possibleExports.append(Export(importKey, requiredPath, false));
|
||||||
|
m_importCache[importKey].append(importId);
|
||||||
if (debugImportDependencies)
|
if (debugImportDependencies)
|
||||||
qDebug() << "added export "<< importKey.toString() << " for id " <<importId
|
qDebug() << "added export "<< importKey.toString() << " for id " <<importId
|
||||||
<< " (" << requiredPath << ")";
|
<< " (" << requiredPath << ")";
|
||||||
@@ -787,13 +808,7 @@ void ImportDependencies::removeExport(const QString &importId, const ImportKey &
|
|||||||
qDebug() << "missing possibleExport for " << importKey.toString() << " when removing export of "
|
qDebug() << "missing possibleExport for " << importKey.toString() << " when removing export of "
|
||||||
<< importId;
|
<< importId;
|
||||||
} else {
|
} else {
|
||||||
QStringList &cImp = m_importCache[importKey];
|
removeImportCacheEntry(importKey, importId);
|
||||||
if (!cImp.removeOne(importId)) {
|
|
||||||
qDebug() << "missing possibleExport backpointer for " << importKey.toString() << " to "
|
|
||||||
<< importId;
|
|
||||||
}
|
|
||||||
if (cImp.isEmpty())
|
|
||||||
m_importCache.remove(importKey);
|
|
||||||
}
|
}
|
||||||
if (debugImportDependencies)
|
if (debugImportDependencies)
|
||||||
qDebug() << "removed export "<< importKey.toString() << " for id " << importId
|
qDebug() << "removed export "<< importKey.toString() << " for id " << importId
|
||||||
|
|||||||
@@ -224,6 +224,8 @@ public:
|
|||||||
QSet<ImportKey> libraryImports(const ViewerContext &viewContext) const;
|
QSet<ImportKey> libraryImports(const ViewerContext &viewContext) const;
|
||||||
QSet<ImportKey> subdirImports(const ImportKey &baseKey, const ViewerContext &viewContext) const;
|
QSet<ImportKey> subdirImports(const ImportKey &baseKey, const ViewerContext &viewContext) const;
|
||||||
private:
|
private:
|
||||||
|
void removeImportCacheEntry(const ImportKey &importKey, const QString &importId);
|
||||||
|
|
||||||
QMap<ImportKey, QStringList> m_importCache;
|
QMap<ImportKey, QStringList> m_importCache;
|
||||||
QMap<QString, CoreImport> m_coreImports;
|
QMap<QString, CoreImport> m_coreImports;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user