diff options
Diffstat (limited to 'tools/qmllint/checkidentifiers.cpp')
-rw-r--r-- | tools/qmllint/checkidentifiers.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/qmllint/checkidentifiers.cpp b/tools/qmllint/checkidentifiers.cpp index e2ac8981f5..1e889926a1 100644 --- a/tools/qmllint/checkidentifiers.cpp +++ b/tools/qmllint/checkidentifiers.cpp @@ -299,6 +299,27 @@ void CheckIdentifiers::operator()( auto qmlScope = QQmlJSScope::findCurrentQMLScope(currentScope); if (qmlScope->hasMethod(memberAccessBase.m_name)) { // a property of a JavaScript function, or a method + auto methods = qmlScope->methods(memberAccessBase.m_name); + const QQmlJSMetaMethod &method = methods.constFirst(); + const auto &annotations = method.annotations(); + auto deprecationAnn = std::find_if(annotations.constBegin(), annotations.constEnd(), [](const QQmlJSAnnotation& annotation) { + return annotation.isDeprecation(); + }); + + // Once we encountered one possible method that is not deprecated, + // we can assume that the one beyond that is not what was being referenced + if (deprecationAnn == annotations.constEnd()) + continue; + + QQQmlJSDeprecation deprecation = deprecationAnn->deprecation(); + + QString message = QStringLiteral("Method \"%1(%2)\" is deprecated") + .arg(memberAccessBase.m_name, method.parameterNames().join(QStringLiteral(", "))); + + if (!deprecation.reason.isEmpty()) + message.append(QStringLiteral(" (Reason: %1)").arg(deprecation.reason)); + + m_logger->log(message, Log_Deprecation, memberAccessBase.m_location); continue; } |