diff options
author | Fawzi Mohamed <fawzi.mohamed@digia.com> | 2014-06-30 12:49:06 +0200 |
---|---|---|
committer | Fawzi Mohamed <fawzi.mohamed@digia.com> | 2014-07-04 14:05:16 +0200 |
commit | ef54a29c7b47a73d74df27e0465892bf04935647 (patch) | |
tree | 3549fdd46a4296cf1a554a0511bebd69e1373945 | |
parent | 04d655dee0c2c5d4b1b8e6ac15c75a17776298fc (diff) |
qmljs: add possible exports given by its path if no other exports found
Change-Id: I23c99aacf0c76fe9ceca0c7c05c17102b90244cd
Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
-rw-r--r-- | src/libs/qmljs/qmljsdocument.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libs/qmljs/qmljsdocument.cpp b/src/libs/qmljs/qmljsdocument.cpp index 34c2e7370c..b81ce57b21 100644 --- a/src/libs/qmljs/qmljsdocument.cpp +++ b/src/libs/qmljs/qmljsdocument.cpp @@ -578,6 +578,32 @@ void Snapshot::insertLibraryInfo(const QString &path, const LibraryInfo &info) cImport.possibleExports << Export(importKey, requiredPath, true); } } + if (cImport.possibleExports.isEmpty()) { + QRegExp vNr(QLatin1String("^(.+)\\.([0-9]+)(?:\\.([0-9]+))?$")); + QRegExp safeName(QLatin1String("^[a-zA-Z_][[a-zA-Z0-9_]*$")); + int majorVersion = LanguageUtils::ComponentVersion::NoVersion; + int minorVersion = LanguageUtils::ComponentVersion::NoVersion; + if (vNr.indexIn(splitPath.last()) == 0) { + splitPath.last() = vNr.cap(1); + bool ok; + majorVersion = vNr.cap(2).toInt(&ok); + if (!ok) + majorVersion = LanguageUtils::ComponentVersion::NoVersion; + minorVersion = vNr.cap(3).toInt(&ok); + if (vNr.cap(3).isEmpty() || !ok) + minorVersion = LanguageUtils::ComponentVersion::NoVersion; + } + + for (int iPath = splitPath.size(); iPath != 0; ) { + --iPath; + if (safeName.indexIn(splitPath.at(iPath)) != 0) + break; + ImportKey iKey(ImportType::Library, QStringList(splitPath.mid(iPath)).join(QLatin1Char('.')), + majorVersion, minorVersion); + cImport.possibleExports.append(Export(iKey, QStringList(splitPath.mid(0, iPath)) + .join(QLatin1Char('/')), true)); + } + } foreach (const QmlDirParser::Component &component, info.components()) { foreach (const Export &e, cImport.possibleExports) // renaming of type name not really represented here... fix? |