PassManager Class
class QQmlSA::PassManagerCan analyze an element and its children with static analysis passes. More...
Header: | #include <PassManager> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS QmlCompiler) target_link_libraries(mytarget PRIVATE Qt6::QmlCompiler) |
Status: | Technical Preview |
Public Functions
void | analyze(const QQmlSA::Element &root) |
std::unordered_map<quint32, QQmlSA::BindingInfo> | bindingsByLocation() const |
std::vector<std::shared_ptr<QQmlSA::ElementPass>> | elementPasses() const |
bool | hasImportedModule(QAnyStringView module) const |
bool | isCategoryEnabled(QQmlSA::LoggerWarningId category) const |
std::multimap<QString, QQmlSA::PropertyPassInfo> | propertyPasses() const |
void | registerElementPass(std::unique_ptr<QQmlSA::ElementPass> pass) |
bool | registerPropertyPass(std::shared_ptr<QQmlSA::PropertyPass> pass, QAnyStringView moduleName, QAnyStringView typeName, QAnyStringView propertyName = QAnyStringView(), bool allowInheritance = true) |
Member Function Documentation
void PassManager::analyze(const QQmlSA::Element &root)
Runs the element passes over root and all its children.
std::unordered_map<quint32, QQmlSA::BindingInfo> PassManager::bindingsByLocation() const
Returns bindings by their source location.
std::vector<std::shared_ptr<QQmlSA::ElementPass>> PassManager::elementPasses() const
Returns the list of element passes.
bool PassManager::hasImportedModule(QAnyStringView module) const
Returns true
if the module named module has been imported by the QML to be analyzed, false
otherwise.
This can be used to skip registering a pass which is specific to a specific module.
if (passManager->hasImportedModule("QtPositioning")) passManager->registerElementPass( std::make_unique<PositioningPass>(passManager) );
See also registerPropertyPass() and registerElementPass().
bool PassManager::isCategoryEnabled(QQmlSA::LoggerWarningId category) const
Returns true
if warnings of category are enabled, false
otherwise.
std::multimap<QString, QQmlSA::PropertyPassInfo> PassManager::propertyPasses() const
Returns the list of property passes.
void PassManager::registerElementPass(std::unique_ptr<QQmlSA::ElementPass> pass)
Registers a static analysis pass to be run on all elements.
bool PassManager::registerPropertyPass(std::shared_ptr<QQmlSA::PropertyPass> pass, QAnyStringView moduleName, QAnyStringView typeName, QAnyStringView propertyName = QAnyStringView(), bool allowInheritance = true)
Registers a static analysis pass for properties. The pass will be run on every property matching the moduleName, typeName and propertyName.
Omitting the propertyName will register this pass for all properties matching the typeName and moduleName.
Setting allowInheritance to true
means that the filtering on the type also accepts types deriving from typeName.
pass is passed as a std::shared_ptr
to allow reusing the same pass on multiple elements:
auto titleValiadorPass = std::make_shared<TitleValidatorPass>(manager); manager->registerPropertyPass(titleValidatorPass, "QtQuick", "Window", "title"); manager->registerPropertyPass(titleValidatorPass, "QtQuick.Controls", "Dialog", "title");
Note: Running analysis passes on too many items can be expensive. This is why it is generally good to filter down the set of properties of a pass using the moduleName, typeName and propertyName.
Returns true
if the pass was successfully added, false
otherwise. Adding a pass fails when the Element specified by moduleName and typeName does not exist.
See also PropertyPass.
© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.