diff options
| author | Sami Shalayel <sami.shalayel@qt.io> | 2024-10-15 09:14:11 +0200 |
|---|---|---|
| committer | Sami Shalayel <sami.shalayel@qt.io> | 2024-10-24 14:19:22 +0200 |
| commit | b027c76d1265a98f4143aea0627fec7b6be5720f (patch) | |
| tree | cba67b18e30e54ede8f70fb23947d30532df2121 /src/qmlcompiler/qqmljsimportvisitor.cpp | |
| parent | f4e2177d498b8d71440cd3c4ca73e120450400e7 (diff) | |
QQmlJSMetaProperty: add sourcelocation if defined in QML
Add sourcelocation to properties defined in QML, such that tools like
qmllint have a valid sourcelocation they can issue warnings on.
Fix the warnings:
* "Cannot deduce type of alias",
* "Cannot resolve alias"
* "Alias is part of an alias cycle"
to use the new sourcelocation.
Also adapt the tests to the new sourcelocations.
Fixes: QTBUG-128932
Pick-to: 6.8
Change-Id: Iec434324af1244c6952f0d5afc8a42f569a750e4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsimportvisitor.cpp')
| -rw-r--r-- | src/qmlcompiler/qqmljsimportvisitor.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp index 9766ab9cd0..5b732ef023 100644 --- a/src/qmlcompiler/qqmljsimportvisitor.cpp +++ b/src/qmlcompiler/qqmljsimportvisitor.cpp @@ -302,11 +302,11 @@ void QQmlJSImportVisitor::resolveAliasesAndIds() if (foundProperty) { m_logger->log(QStringLiteral("Cannot deduce type of alias \"%1\"") .arg(property.propertyName()), - qmlMissingType, object->sourceLocation()); + qmlMissingType, property.sourceLocation()); } else { m_logger->log(QStringLiteral("Cannot resolve alias \"%1\"") .arg(property.propertyName()), - qmlUnresolvedAlias, object->sourceLocation()); + qmlUnresolvedAlias, property.sourceLocation()); } Q_ASSERT(property.index() >= 0); // this property is already in object @@ -367,7 +367,7 @@ void QQmlJSImportVisitor::resolveAliasesAndIds() continue; m_logger->log(QStringLiteral("Alias \"%1\" is part of an alias cycle") .arg(property.propertyName()), - qmlAliasCycle, object->sourceLocation()); + qmlAliasCycle, property.sourceLocation()); } } } @@ -1667,6 +1667,8 @@ bool QQmlJSImportVisitor::visit(UiPublicMember *publicMember) prop.setIsList(publicMember->typeModifier == QLatin1String("list")); prop.setIsWritable(!publicMember->isReadonly()); prop.setAliasExpression(aliasExpr); + prop.setSourceLocation( + combine(publicMember->firstSourceLocation(), publicMember->colonToken)); const auto type = isAlias ? QQmlJSScope::ConstPtr() : m_rootScopeImports.type(typeName).scope; if (type) { |
