QmlJS: Fix library-by-path imports.

Fixes the problem 5426c3ac2c and
7b25f438c6 worked around.

Reviewed-by: Erik Verbruggen
This commit is contained in:
Christian Kamm
2011-04-20 10:46:04 +02:00
parent e40a0ca990
commit e21311132b
4 changed files with 87 additions and 39 deletions

View File

@@ -183,27 +183,6 @@ void Link::populateImportedTypes(TypeEnvironment *typeEnv, Document::Ptr doc)
foreach (const ImportInfo &info, doc->bind()->imports()) {
ObjectValue *import = d->importCache.value(ImportCacheKey(info));
//### Hack: if this document is in a library, and if there is an qmldir file in the same directory, and if the prefix is an import-path, the import means to import everything in this library.
if (info.ast() && info.ast()->fileName && info.ast()->fileName->asString() == QLatin1String(".")) {
const QString importInfoName(info.name());
if (QFileInfo(QDir(importInfoName), QLatin1String("qmldir")).exists()) {
foreach (const QString &importPath, d->importPaths) {
if (importInfoName.startsWith(importPath)) {
// Got it.
const QString cleanPath = QFileInfo(importInfoName).canonicalFilePath();
const QString forcedPackageName = cleanPath.mid(importPath.size() + 1).replace('/', '.').replace('\\', '.');
import = importNonFile(doc, info, forcedPackageName);
if (import)
d->importCache.insert(ImportCacheKey(info), import);
break;
}
}
}
}
//### End of hack.
if (!import) {
switch (info.type()) {
case ImportInfo::FileImport: