aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2023-10-26 17:49:14 +0200
committerSami Shalayel <sami.shalayel@qt.io>2024-04-05 17:45:42 +0200
commitd94ec776a743009502260b9e6748d44c2791f151 (patch)
treeaadf4990e8f38940801a1ffd027ccdd9549a5172 /tools
parentadb1fb57d8f4a8cb894457af6506f301d5401032 (diff)
Make qmljsliteralbindingcheck a QQmlSA::PropertyPass
Use the private API to convert QQmlSA objects into QQmlJS elements wherever it was not possible to use the QQmlSA objects: The static method canConvertForLiteralBinding has a comment that seems to say 'we need this so dont touch this' so do not change its code. Furthermore, it requires a QQmlJSTypeResolver, so obtain it from the PassManager's private struct. It seems that QQmlJSLiteralBindingCheck was the only user of QQmlJSMetaPropertyBinding::literalTypeName, so move it to QQmlJSLiteralBindingCheck instead of adding literalTypeName to the QQmlSA interface. Make QQmlJSLinter always create the passManager, even when there are no plugins available, such that the QQmlJSLiteralBindingCheck can be run using the QQmlSA interface. Also fix Qmltc to use the new QQmlJSLiteralBindingCheck api. Change-Id: I27dfc63d411e38740e2993ccf9af352271ae6d47 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmltc/main.cpp11
-rw-r--r--tools/qmltc/qmltctyperesolver.cpp3
2 files changed, 11 insertions, 3 deletions
diff --git a/tools/qmltc/main.cpp b/tools/qmltc/main.cpp
index fb3c55a344..0541203571 100644
--- a/tools/qmltc/main.cpp
+++ b/tools/qmltc/main.cpp
@@ -24,6 +24,8 @@
#include <QtQml/private/qqmljsastvisitor_p.h>
#include <QtQml/private/qqmljsast_p.h>
#include <QtQml/private/qqmljsdiagnosticmessage_p.h>
+#include <QtQmlCompiler/qqmlsa.h>
+#include <QtQmlCompiler/private/qqmljsliteralbindingcheck_p.h>
#include <cstdlib> // EXIT_SUCCESS, EXIT_FAILURE
@@ -279,6 +281,15 @@ int main(int argc, char **argv)
QmltcTypeResolver typeResolver { &importer };
typeResolver.init(&visitor, qmlParser.rootNode());
+ using PassManagerPtr =
+ std::unique_ptr<QQmlSA::PassManager,
+ decltype(&QQmlSA::PassManagerPrivate::deletePassManager)>;
+ PassManagerPtr passMan(QQmlSA::PassManagerPrivate::createPassManager(&visitor, &typeResolver),
+ &QQmlSA::PassManagerPrivate::deletePassManager);
+ passMan->registerPropertyPass(std::make_unique<QQmlJSLiteralBindingCheck>(passMan.get()),
+ QString(), QString(), QString());
+ passMan->analyze(QQmlJSScope::createQQmlSAElement(visitor.result()));
+
if (logger.hasErrors())
return EXIT_FAILURE;
diff --git a/tools/qmltc/qmltctyperesolver.cpp b/tools/qmltc/qmltctyperesolver.cpp
index 045f3af088..a7bf9debac 100644
--- a/tools/qmltc/qmltctyperesolver.cpp
+++ b/tools/qmltc/qmltctyperesolver.cpp
@@ -18,9 +18,6 @@ void QmltcTypeResolver::init(QmltcVisitor *visitor, QQmlJS::AST::Node *program)
{
QQmlJSTypeResolver::init(visitor, program);
- QQmlJSLiteralBindingCheck literalCheck;
- literalCheck.run(visitor, this);
-
m_root = visitor->result();
QQueue<QQmlJSScope::Ptr> objects;