forked from qt-creator/qt-creator
QmlJS: Fixing warnings
Correcting ImportKey::compare(). The compare function was not stable and QMap did not work properly. Done with: Fawzi Change-Id: I11790215cba6944bf9f04be0c3844b35ea54ea70 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
@@ -314,7 +314,7 @@ int ImportKey::compare(const ImportKey &other) const
|
|||||||
QString v2 = other.splitPath.at(i);
|
QString v2 = other.splitPath.at(i);
|
||||||
if (v1 < v2)
|
if (v1 < v2)
|
||||||
return -1;
|
return -1;
|
||||||
if (v2 > v1)
|
if (v1 > v2)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (len1 < len2)
|
if (len1 < len2)
|
||||||
@@ -626,7 +626,7 @@ void ImportDependencies::iterateOnCandidateImports(
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
QStringList imp = m_importCache.value(key.flatKey());
|
const QStringList imp = m_importCache.value(key.flatKey());
|
||||||
foreach (const QString &cImportName, imp) {
|
foreach (const QString &cImportName, imp) {
|
||||||
CoreImport cImport = coreImport(cImportName);
|
CoreImport cImport = coreImport(cImportName);
|
||||||
if (vContext.languageIsCompatible(cImport.language)) {
|
if (vContext.languageIsCompatible(cImport.language)) {
|
||||||
@@ -928,4 +928,38 @@ QSet<ImportKey> ImportDependencies::subdirImports(
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImportDependencies::checkConsistency() const
|
||||||
|
{
|
||||||
|
QMapIterator<ImportKey, QStringList> j(m_importCache);
|
||||||
|
while (j.hasNext()) {
|
||||||
|
j.next();
|
||||||
|
foreach (const QString &s, j.value()) {
|
||||||
|
bool found = false;
|
||||||
|
foreach (const Export &e, m_coreImports.value(s).possibleExports)
|
||||||
|
if (e.exportName == j.key())
|
||||||
|
found = true;
|
||||||
|
Q_ASSERT(found);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QMapIterator<QString,CoreImport> i(m_coreImports);
|
||||||
|
while (i.hasNext()) {
|
||||||
|
i.next();
|
||||||
|
foreach (const Export &e, i.value().possibleExports) {
|
||||||
|
if (!m_importCache.value(e.exportName).contains(i.key())) {
|
||||||
|
qDebug() << e.exportName.toString();
|
||||||
|
qDebug() << i.key();
|
||||||
|
|
||||||
|
QMapIterator<ImportKey, QStringList> j(m_importCache);
|
||||||
|
while (j.hasNext()) {
|
||||||
|
j.next();
|
||||||
|
qDebug() << j.key().toString() << j.value();
|
||||||
|
}
|
||||||
|
qDebug() << m_importCache.contains(e.exportName);
|
||||||
|
qDebug() << m_importCache.value(e.exportName);
|
||||||
|
}
|
||||||
|
Q_ASSERT(m_importCache.value(e.exportName).contains(i.key()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace QmlJS
|
} // namespace QmlJS
|
||||||
|
|||||||
@@ -223,6 +223,7 @@ 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;
|
||||||
|
void checkConsistency() const;
|
||||||
private:
|
private:
|
||||||
void removeImportCacheEntry(const ImportKey &importKey, const QString &importId);
|
void removeImportCacheEntry(const ImportKey &importKey, const QString &importId);
|
||||||
|
|
||||||
|
|||||||
@@ -950,13 +950,13 @@ void ModelManager::importScan(QFutureInterface<void> &future,
|
|||||||
int totalWork(progressRange), workDone(0);
|
int totalWork(progressRange), workDone(0);
|
||||||
future.setProgressRange(0, progressRange); // update max length while iterating?
|
future.setProgressRange(0, progressRange); // update max length while iterating?
|
||||||
const bool libOnly = true; // FIXME remove when tested more
|
const bool libOnly = true; // FIXME remove when tested more
|
||||||
|
const Snapshot snapshot = modelManager->snapshot();
|
||||||
while (!pathsToScan.isEmpty() && !future.isCanceled()) {
|
while (!pathsToScan.isEmpty() && !future.isCanceled()) {
|
||||||
ScanItem toScan = pathsToScan.last();
|
ScanItem toScan = pathsToScan.last();
|
||||||
pathsToScan.pop_back();
|
pathsToScan.pop_back();
|
||||||
int pathBudget = (maxScanDepth + 2 - toScan.depth);
|
int pathBudget = (maxScanDepth + 2 - toScan.depth);
|
||||||
if (!scannedPaths.contains(toScan.path)) {
|
if (!scannedPaths.contains(toScan.path)) {
|
||||||
QStringList importedFiles;
|
QStringList importedFiles;
|
||||||
const Snapshot snapshot = modelManager->snapshot();
|
|
||||||
if (!findNewQmlLibraryInPath(toScan.path, snapshot, modelManager, &importedFiles,
|
if (!findNewQmlLibraryInPath(toScan.path, snapshot, modelManager, &importedFiles,
|
||||||
&scannedPaths, &newLibraries, true)
|
&scannedPaths, &newLibraries, true)
|
||||||
&& !libOnly && snapshot.documentsInDirectory(toScan.path).isEmpty())
|
&& !libOnly && snapshot.documentsInDirectory(toScan.path).isEmpty())
|
||||||
|
|||||||
Reference in New Issue
Block a user