Properly mark composite singletons in QQmlJSImporter
Change-Id: I9063765b37528489a8e350fe63b2babdd038fe1a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
d009c0088b
commit
213adb6692
|
@ -152,8 +152,12 @@ QQmlJSImporter::Import QQmlJSImporter::readQmldir(const QString &path)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mo = qmlComponents.find(it.key());
|
auto mo = qmlComponents.find(it.key());
|
||||||
if (mo == qmlComponents.end())
|
if (mo == qmlComponents.end()) {
|
||||||
mo = qmlComponents.insert(it.key(), localFile2ScopeTree(filePath));
|
QQmlJSScope::Ptr imported = localFile2ScopeTree(filePath);
|
||||||
|
if (it->singleton)
|
||||||
|
imported->setIsSingleton(true);
|
||||||
|
mo = qmlComponents.insert(it.key(), imported);
|
||||||
|
}
|
||||||
|
|
||||||
(*mo)->addExport(it.key(), reader.typeNamespace(), it->version);
|
(*mo)->addExport(it.key(), reader.typeNamespace(), it->version);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
pragma Singleton
|
||||||
|
import QtQuick 2.0
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
readonly property string stringProp: "stringValue"
|
||||||
|
readonly property int intProp: 10
|
||||||
|
readonly property real realProp: 4.5
|
||||||
|
readonly property color colorProp: "green"
|
||||||
|
readonly property bool boolProp: true
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
import QtQuick 2.0
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
readonly property string stringProp: "stringValue"
|
||||||
|
readonly property int intProp: 10
|
||||||
|
readonly property real realProp: 4.5
|
||||||
|
readonly property color colorProp: "green"
|
||||||
|
readonly property bool boolProp: true
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
module QmlBench
|
||||||
|
singleton Globals 1.0 Globals.qml
|
||||||
|
Locals 1.0 Locals.qml
|
|
@ -0,0 +1,8 @@
|
||||||
|
import QtQml
|
||||||
|
import QmlBench
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
property real x: Globals.realProp
|
||||||
|
property real y: Globals.intProp
|
||||||
|
property bool smooth: Globals.boolProp
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
import QtQml
|
||||||
|
import QmlBench
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
property real x: Locals.realProp
|
||||||
|
}
|
|
@ -520,6 +520,11 @@ void TestQmllint::dirtyQmlCode_data()
|
||||||
<< QStringLiteral("Unused import at %1:1:1")
|
<< QStringLiteral("Unused import at %1:1:1")
|
||||||
<< QString()
|
<< QString()
|
||||||
<< true;
|
<< true;
|
||||||
|
QTest::newRow("TypePropertAccess")
|
||||||
|
<< QStringLiteral("typePropertyAccess.qml")
|
||||||
|
<< QString()
|
||||||
|
<< QString()
|
||||||
|
<< false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQmllint::dirtyQmlCode()
|
void TestQmllint::dirtyQmlCode()
|
||||||
|
@ -537,6 +542,7 @@ void TestQmllint::dirtyQmlCode()
|
||||||
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
QEXPECT_FAIL("anchors3", "We don't see that QQuickItem cannot be assigned to QQuickAnchorLine", Abort);
|
QEXPECT_FAIL("anchors3", "We don't see that QQuickItem cannot be assigned to QQuickAnchorLine", Abort);
|
||||||
QEXPECT_FAIL("nanchors1", "Invalid grouped properties are not always detected", Abort);
|
QEXPECT_FAIL("nanchors1", "Invalid grouped properties are not always detected", Abort);
|
||||||
|
QEXPECT_FAIL("TypePropertAccess", "We cannot discern between types and instances", Abort);
|
||||||
|
|
||||||
if (exitsNormally)
|
if (exitsNormally)
|
||||||
QVERIFY(process.exitCode() == 0);
|
QVERIFY(process.exitCode() == 0);
|
||||||
|
@ -600,6 +606,7 @@ void TestQmllint::cleanQmlCode_data()
|
||||||
QTest::newRow("duplicateQmldirImport") << QStringLiteral("qmldirImport/duplicate.qml");
|
QTest::newRow("duplicateQmldirImport") << QStringLiteral("qmldirImport/duplicate.qml");
|
||||||
QTest::newRow("Used imports") << QStringLiteral("used.qml");
|
QTest::newRow("Used imports") << QStringLiteral("used.qml");
|
||||||
QTest::newRow("Unused imports (multi)") << QStringLiteral("unused_multi.qml");
|
QTest::newRow("Unused imports (multi)") << QStringLiteral("unused_multi.qml");
|
||||||
|
QTest::newRow("compositeSingleton") << QStringLiteral("compositesingleton.qml");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQmllint::cleanQmlCode()
|
void TestQmllint::cleanQmlCode()
|
||||||
|
|
Loading…
Reference in New Issue