From d94ec776a743009502260b9e6748d44c2791f151 Mon Sep 17 00:00:00 2001 From: Sami Shalayel Date: Thu, 26 Oct 2023 17:49:14 +0200 Subject: 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 --- tools/qmltc/main.cpp | 11 +++++++++++ tools/qmltc/qmltctyperesolver.cpp | 3 --- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'tools') 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 #include #include +#include +#include #include // 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; + PassManagerPtr passMan(QQmlSA::PassManagerPrivate::createPassManager(&visitor, &typeResolver), + &QQmlSA::PassManagerPrivate::deletePassManager); + passMan->registerPropertyPass(std::make_unique(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 objects; -- cgit v1.2.3