diff options
-rw-r--r-- | src/qmlcompiler/qqmljsimportvisitor.cpp | 2 | ||||
-rw-r--r-- | src/qmlcompiler/qqmljsimportvisitor_p.h | 10 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/data/multiGrouped.qml | 6 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 1 |
4 files changed, 18 insertions, 1 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp index 54dd5654c9..51561e748d 100644 --- a/src/qmlcompiler/qqmljsimportvisitor.cpp +++ b/src/qmlcompiler/qqmljsimportvisitor.cpp @@ -118,6 +118,7 @@ void QQmlJSImportVisitor::enterEnvironment(QQmlJSScope::ScopeType type, const QS setScopeName(m_currentScope, type, name); m_currentScope->setIsComposite(true); m_currentScope->setSourceLocation(location); + m_scopesByIrLocation.insert({ location.startLine, location.startColumn }, m_currentScope); } bool QQmlJSImportVisitor::enterEnvironmentNonUnique(QQmlJSScope::ScopeType type, @@ -142,6 +143,7 @@ bool QQmlJSImportVisitor::enterEnvironmentNonUnique(QQmlJSScope::ScopeType type, return false; } // enter found scope + m_scopesByIrLocation.insert({ location.startLine, location.startColumn }, *it); m_currentScope = *it; return true; } diff --git a/src/qmlcompiler/qqmljsimportvisitor_p.h b/src/qmlcompiler/qqmljsimportvisitor_p.h index cc1ccb3f3a..8908b60f76 100644 --- a/src/qmlcompiler/qqmljsimportvisitor_p.h +++ b/src/qmlcompiler/qqmljsimportvisitor_p.h @@ -46,7 +46,7 @@ #include <private/qqmljsast_p.h> #include <private/qqmljsdiagnosticmessage_p.h> #include <private/qqmljsimporter_p.h> - +#include <private/qv4compileddata_p.h> QT_BEGIN_NAMESPACE @@ -66,6 +66,10 @@ public: QHash<QString, QQmlJSScope::ConstPtr> imports() const { return m_rootScopeImports; } QHash<QString, QQmlJSScope::ConstPtr> addressableScopes() const { return m_scopesById; } + QHash<QV4::CompiledData::Location, QQmlJSScope::ConstPtr> scopesBylocation() const + { + return m_scopesByIrLocation; + } static QString implicitImportDirectory( const QString &localFile, QQmlJSResourceFileMapper *mapper); @@ -145,6 +149,10 @@ protected: QHash<QString, QQmlJSScope::ConstPtr> m_scopesById; QHash<QString, QQmlJSScope::ConstPtr> m_rootScopeImports; + // We need to record the locations as IR locations because those contain less data. + // This way we can look up objects by IR location later. + QHash<QV4::CompiledData::Location, QQmlJSScope::ConstPtr> m_scopesByIrLocation; + // Maps all qmlNames to the source location of their import QMultiHash<QString, QQmlJS::SourceLocation> m_importTypeLocationMap; // Contains all import source locations (could be extracted from above but that is expensive) diff --git a/tests/auto/qml/qmllint/data/multiGrouped.qml b/tests/auto/qml/qmllint/data/multiGrouped.qml new file mode 100644 index 0000000000..ab6bd5bd02 --- /dev/null +++ b/tests/auto/qml/qmllint/data/multiGrouped.qml @@ -0,0 +1,6 @@ +import QtQuick + +Item { + anchors.verticalCenter: parent.verticalCenter + anchors { right: parent.left } +} diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index 09e2683236..2a441086ad 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -810,6 +810,7 @@ void TestQmllint::cleanQmlCode_data() QTest::newRow("required property in Component") << QStringLiteral("requiredPropertyInComponent.qml"); QTest::newRow("connectionNoParent") << QStringLiteral("connectionNoParent.qml"); // QTBUG-97600 QTest::newRow("on binding in grouped property") << QStringLiteral("onBindingInGroupedProperty.qml"); + QTest::newRow("multipleGrouped") << QStringLiteral("multiGrouped.qml"); } void TestQmllint::cleanQmlCode() |