diff options
Diffstat (limited to 'src/qmlcompiler')
| -rw-r--r-- | src/qmlcompiler/qqmljslinter.cpp | 12 | ||||
| -rw-r--r-- | src/qmlcompiler/qqmljslogger.cpp | 3 | ||||
| -rw-r--r-- | src/qmlcompiler/qqmljsloggingutils.h | 1 |
3 files changed, 16 insertions, 0 deletions
diff --git a/src/qmlcompiler/qqmljslinter.cpp b/src/qmlcompiler/qqmljslinter.cpp index 561190a2db..0a90376296 100644 --- a/src/qmlcompiler/qqmljslinter.cpp +++ b/src/qmlcompiler/qqmljslinter.cpp @@ -56,6 +56,18 @@ public: declarationLocation, true, true, {}, {}, accessLocation.startLine); } + void reportFunctionUsedBeforeDeclaration(const QString &name, const QString &fileName, + QQmlJS::SourceLocation declarationLocation, + QQmlJS::SourceLocation accessLocation) override + { + Q_UNUSED(fileName) + + m_logger->log("Function '%1' is used here before its declaration."_L1.arg(name), + qmlFunctionUsedBeforeDeclaration, accessLocation); + m_logger->log("Note: declaration of '%1' here"_L1.arg(name), + qmlFunctionUsedBeforeDeclaration, declarationLocation); + } + private: QQmlJSLogger *m_logger; }; diff --git a/src/qmlcompiler/qqmljslogger.cpp b/src/qmlcompiler/qqmljslogger.cpp index ff2a77a044..03db79e658 100644 --- a/src/qmlcompiler/qqmljslogger.cpp +++ b/src/qmlcompiler/qqmljslogger.cpp @@ -92,6 +92,9 @@ using namespace Qt::StringLiterals; QtWarningMsg, true, false) \ X(qmlVarUsedBeforeDeclaration, "var-used-before-declaration", "VarUsedBeforeDeclaration", \ "Warn if a variable is used before declaration", QtWarningMsg, false, false) \ + X(qmlFunctionUsedBeforeDeclaration, "function-used-before-declaration", \ + "FunctionUsedBeforeDeclaration", "Warn if a function is used before declaration", \ + QtWarningMsg, true, false) \ X(qmlInvalidLintDirective, "invalid-lint-directive", "InvalidLintDirective", \ "Warn if an invalid qmllint comment is found", QtWarningMsg, false, false) \ X(qmlUseProperFunction, "use-proper-function", "UseProperFunction", \ diff --git a/src/qmlcompiler/qqmljsloggingutils.h b/src/qmlcompiler/qqmljsloggingutils.h index 078b7d1a45..56d4ac49b5 100644 --- a/src/qmlcompiler/qqmljsloggingutils.h +++ b/src/qmlcompiler/qqmljsloggingutils.h @@ -70,6 +70,7 @@ extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlCompiler; extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlAttachedPropertyReuse; extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlPlugin; extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlVarUsedBeforeDeclaration; +extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlFunctionUsedBeforeDeclaration; extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlInvalidLintDirective; extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlUseProperFunction; extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlAccessSingleton; |
