aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2025-04-07 16:57:53 +0200
committerSami Shalayel <sami.shalayel@qt.io>2025-05-22 09:19:51 +0200
commit4d31fd579914bf0f263dfb4cc580ded9a9434388 (patch)
tree92c2dcc2c26a2c329a9574a056515db45ae613b8 /tools
parent892ff6c8e2f47abad92b99f48b6c045a90f26d8f (diff)
QQmlJSLinter: add crude context properties warnings
Warn in QQmlJSTypePropagator::generate_LoadQmlContextPropertyLookup() about usages of context properties that were found. Also treat context properties as var. Add the (C++) location of the "setContextProperty()" call to the warning, and also hint that a property is assumed to be a context property when inside a top-level component (capital C Component, inline component or implicitly wrapped as component) because it is not declared as required property. Still print the accompanying unqualified warnings next to the new context property warning. Add a test. Later patches will add the support to qmlls and qmllint by passing the workspace folders to the new functionality. Task-number: QTBUG-128232 Change-Id: I26e39e0bce8c6e9f203962a091209c7acd15d445 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmllint/main.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/qmllint/main.cpp b/tools/qmllint/main.cpp
index 62210a5a9d..a865d96bba 100644
--- a/tools/qmllint/main.cpp
+++ b/tools/qmllint/main.cpp
@@ -428,9 +428,11 @@ All warnings can be set to three levels:
lintResult = linter.lintModule(filename, silent, useJson ? &jsonFiles : nullptr,
qmlImportPaths, resourceFiles);
} else {
+ // TODO: collect root urls here
+ const QQmlJS::ContextProperties contextProperties;
lintResult = linter.lintFile(filename, nullptr, silent || isFixing,
useJson ? &jsonFiles : nullptr, qmlImportPaths,
- qmldirFiles, resourceFiles, categories);
+ qmldirFiles, resourceFiles, categories, contextProperties);
}
success &= (lintResult == QQmlJSLinter::LintSuccess || lintResult == QQmlJSLinter::HasWarnings);
if (success) {