Merge remote-tracking branch 'origin/5.0'

Conflicts:
	src/plugins/clangtools/clangtoolssettings.cpp
	src/plugins/clangtools/executableinfo.cpp
	src/plugins/clangtools/executableinfo.h

Change-Id: Id8caf63e3e594792467d3447870086bd2d8f73b9
This commit is contained in:
Eike Ziller
2021-09-13 15:36:51 +02:00
98 changed files with 1321 additions and 445 deletions

View File

@@ -158,11 +158,13 @@ ObjectValue *Bind::bindObject(UiQualifiedId *qualifiedTypeNameId, UiObjectInitia
_rootObjectValue = objectValue;
_inlineComponents[_currentComponentName] = objectValue;
if (!_currentComponentName.isEmpty()) {
if (_currentComponentName.contains('.'))
if (_currentComponentName.contains('.')) {
parentComponentName = _currentComponentName.mid(0,_currentComponentName.lastIndexOf('.'));
else
nextRoot = _inlineComponents.value(parentComponentName);
} else {
parentComponentName = "";
nextRoot = _inlineComponents.value(parentComponentName);
nextRoot = _rootObjectValue;
}
// we add the inline component inside its parent
nextRoot->setMember(_currentComponentName.mid(_currentComponentName.lastIndexOf('.') + 1), objectValue);
_rootObjectValue->setClassName(_doc->componentName() + "." + _currentComponentName); // use :: instead of .?

View File

@@ -213,6 +213,29 @@ bool QmlJS::maybeModuleVersion(const QString &version) {
return version.isEmpty() || version == undefinedVersion || re.match(version).hasMatch();
}
const QStringList QmlJS::splitVersion(const QString &version)
{
// Successively removing minor and major version numbers.
QStringList result;
int versionEnd = version.length();
while (versionEnd > 0) {
result.append(version.left(versionEnd));
// remove numbers and then potential . at the end
const int oldVersionEnd = versionEnd;
while (versionEnd > 0 && version.at(versionEnd - 1).isDigit())
--versionEnd;
// handle e.g. -1, because an import "QtQuick 2" results in version "2.-1"
if (versionEnd > 0 && version.at(versionEnd - 1) == '-')
--versionEnd;
if (versionEnd > 0 && version.at(versionEnd - 1) == '.')
--versionEnd;
// bail out if we didn't proceed because version string contains invalid characters
if (versionEnd == oldVersionEnd)
break;
}
return result;
}
/*!
* \brief Get the path of a module
* \param name
@@ -242,24 +265,19 @@ QStringList QmlJS::modulePaths(const QString &name, const QString &version,
const QString sanitizedVersion = version == undefinedVersion ? QString() : version;
const QStringList parts = name.split('.', Qt::SkipEmptyParts);
auto mkpath = [] (const QStringList &xs) -> QString { return xs.join(QLatin1Char('/')); };
// Regular expression for building candidates by successively removing minor and major
// version numbers. It does not match the undefined version, so it has to be applied to the
// sanitized version.
const QRegularExpression re("\\.?\\d+$");
auto mkpath = [](const QStringList &xs) -> QString { return xs.join(QLatin1Char('/')); };
QStringList result;
QString candidate;
for (QString ver = sanitizedVersion; !ver.isEmpty(); ver.remove(re)) {
for (const QString &path: importPaths) {
for (const QString &versionPart : splitVersion(sanitizedVersion)) {
for (const QString &path : importPaths) {
for (int i = parts.count() - 1; i >= 0; --i) {
candidate = QDir::cleanPath(
QString::fromLatin1("%1/%2.%3/%4").arg(path,
mkpath(parts.mid(0, i + 1)),
ver,
mkpath(parts.mid(i + 1))));
candidate = QDir::cleanPath(QString::fromLatin1("%1/%2.%3/%4")
.arg(path,
mkpath(parts.mid(0, i + 1)),
versionPart,
mkpath(parts.mid(i + 1))));
if (QDir(candidate).exists())
result << candidate;
}

View File

@@ -57,6 +57,7 @@ QMLJS_EXPORT DiagnosticMessage errorMessage(const SourceLocation &loc,
QMLJS_EXPORT bool maybeModuleVersion(const QString &version);
QMLJS_EXPORT const QStringList splitVersion(const QString &version);
QMLJS_EXPORT QStringList modulePaths(const QString &moduleImportName, const QString &version,
const QStringList &importPaths);