qmldir parser: Handle internal types with versions

There is no reason why internal types cannot have versions.

Fixes: QTCREATORBUG-28755
Change-Id: I419f2e052634b603dfc5b2bfff155167cf6f9304
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Ulf Hermann
2023-02-03 12:36:49 +01:00
parent 37488c69b8
commit ccbee9bf42

View File

@@ -268,14 +268,28 @@ bool QmlDirParser::parse(const QString &source)
_classNames.append(sections[1]); _classNames.append(sections[1]);
} else if (sections[0] == QLatin1String("internal")) { } else if (sections[0] == QLatin1String("internal")) {
if (sectionCount != 3) { if (sectionCount == 3) {
reportError(lineNumber, 0,
QStringLiteral("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1));
continue;
}
Component entry(sections[1], sections[2], -1, -1); Component entry(sections[1], sections[2], -1, -1);
entry.internal = true; entry.internal = true;
_components.insert(entry.typeName, entry); _components.insert(entry.typeName, entry);
} else if (sectionCount == 4) {
int major, minor;
if (parseVersion(sections[2], &major, &minor)) {
Component entry(sections[1], sections[3], major, minor);
entry.internal = true;
_components.insert(entry.typeName, entry);
} else {
reportError(lineNumber, 0,
QStringLiteral("invalid version %1, expected <major>.<minor>")
.arg(sections[2]));
continue;
}
} else {
reportError(lineNumber, 0,
QStringLiteral("internal types require 2 or 3 arguments, "
"but %1 were provided").arg(sectionCount - 1));
continue;
}
} else if (sections[0] == QLatin1String("singleton")) { } else if (sections[0] == QLatin1String("singleton")) {
if (sectionCount < 3 || sectionCount > 4) { if (sectionCount < 3 || sectionCount > 4) {
reportError(lineNumber, 0, reportError(lineNumber, 0,