aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/qml/qmllint/data/Signal.qml13
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp1
-rw-r--r--tools/qmllint/findwarnings.cpp31
3 files changed, 34 insertions, 11 deletions
diff --git a/tests/auto/qml/qmllint/data/Signal.qml b/tests/auto/qml/qmllint/data/Signal.qml
new file mode 100644
index 0000000000..c462b90bc2
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/Signal.qml
@@ -0,0 +1,13 @@
+import QtQuick 2.15
+
+Rectangle {
+ id: messenger
+
+ signal send( string person, string notice)
+
+ onSend: function(person, notice) {
+ console.log("For " + person + ", the notice is: " + notice)
+ }
+
+ Component.onCompleted: messenger.send("Tom", "the door is ajar.")
+}
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index 7466043389..705ff7686f 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -230,6 +230,7 @@ void TestQmllint::cleanQmlCode_data()
QTest::newRow("AttachedType") << QStringLiteral("AttachedType.qml");
QTest::newRow("qmldirImportAndDepend") << QStringLiteral("qmldirImportAndDepend/good.qml");
QTest::newRow("ParentEnum") << QStringLiteral("parentEnum.qml");
+ QTest::newRow("Signals") << QStringLiteral("Signal.qml");
}
void TestQmllint::cleanQmlCode()
diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp
index b18cd82047..83e0c63653 100644
--- a/tools/qmllint/findwarnings.cpp
+++ b/tools/qmllint/findwarnings.cpp
@@ -496,19 +496,28 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiScriptBinding *uisb)
bool FindWarningVisitor::visit(QQmlJS::AST::UiPublicMember *uipm)
{
- // property bool inactive: !active
- // extract name inactive
- MetaProperty property(
+ if (uipm->type == QQmlJS::AST::UiPublicMember::Signal) {
+ MetaMethod method;
+ method.setMethodType(MetaMethod::Signal);
+ method.setMethodName(uipm->name.toString());
+ QQmlJS::AST::UiParameterList *param = uipm->parameters;
+ while (param) {
+ method.addParameter(param->name.toString(), param->type->name.toString());
+ param = param->next;
+ }
+ m_currentScope->addMethod(method);
+ } else {
+ // property bool inactive: !active
+ // extract name inactive
+ MetaProperty property(
uipm->name.toString(),
- // TODO: signals, complex types etc.
+ // TODO: complex types etc.
uipm->memberType ? uipm->memberType->name.toString() : QString(),
- uipm->typeModifier == QLatin1String("list"),
- !uipm->isReadonlyMember,
- false,
- uipm->memberType ? (uipm->memberType->name == QLatin1String("alias")) : false,
- 0);
- property.setType(m_exportedName2Scope.value(property.typeName()));
- m_currentScope->insertPropertyIdentifier(property);
+ uipm->typeModifier == QLatin1String("list"), !uipm->isReadonlyMember, false,
+ uipm->memberType ? (uipm->memberType->name == QLatin1String("alias")) : false, 0);
+ property.setType(m_exportedName2Scope.value(property.typeName()));
+ m_currentScope->insertPropertyIdentifier(property);
+ }
return true;
}