QmlJS: Use "import" commands from qmldir files

qmldir files can have lines like "import QtQml". These were already
parsed, but not stored in LibraryInfo. Store them.

When imports are resolved in Link and a library has such an import, also
load the module it refers to, with the same version and "as" scope.

Add a test to verify the behavior works.

Change-Id: I80b260bfaa36a9e5de0849fa5632b3361077ef01
Task-number: QTCREATORBUG-23986
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Christian Kamm
2020-05-10 15:57:22 +02:00
parent 338fa26bc3
commit f64146741d
15 changed files with 749 additions and 12 deletions

View File

@@ -382,6 +382,7 @@ LibraryInfo::LibraryInfo(const QmlDirParser &parser, const QByteArray &fingerpri
, _components(parser.components().values())
, _plugins(parser.plugins())
, _typeinfos(parser.typeInfos())
, _imports(parser.imports())
, _fingerprint(fingerprint)
{
if (_fingerprint.isEmpty())
@@ -444,6 +445,11 @@ QByteArray LibraryInfo::calculateFingerprint() const
foreach (const ModuleApiInfo &moduleInfo, _moduleApis)
moduleInfo.addToHash(hash); // make it order independent?
len = _imports.size();
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
foreach (const QString &import, _imports)
hash.addData(import.toUtf8()); // import order matters, keep order-dependent
QByteArray res(hash.result());
res.append('L');
return res;