Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
QQmlSA::PassManager Class Reference

\inmodule QtQmlCompiler More...

#include <qqmlsa.h>

+ Collaboration diagram for QQmlSA::PassManager:

Public Member Functions

 PassManager (QQmlJSImportVisitor *visitor, QQmlJSTypeResolver *resolver)
 Constructs a pass manager given an import visitor and a type resolver.
 
 ~PassManager ()
 
void registerElementPass (std::unique_ptr< ElementPass > pass)
 Registers a static analysis pass to be run on all elements.
 
bool registerPropertyPass (std::shared_ptr< PropertyPass > pass, QAnyStringView moduleName, QAnyStringView typeName, QAnyStringView propertyName=QAnyStringView(), bool allowInheritance=true)
 Registers a static analysis pass for properties.
 
void analyze (const Element &root)
 Runs the element passes over root and all its children.
 
bool hasImportedModule (QAnyStringView name) const
 Returns true if the module named module has been imported by the QML to be analyzed, false otherwise.
 
bool isCategoryEnabled (QQmlJS::LoggerWarningId category) const
 Returns true if warnings of category are enabled, false otherwise.
 
std::vector< std::shared_ptr< ElementPass > > elementPasses () const
 Returns the list of element passes.
 
std::multimap< QString, PropertyPassInfopropertyPasses () const
 Returns the list of property passes.
 
std::unordered_map< quint32, BindingInfobindingsByLocation () const
 Returns bindings by their source location.
 

Friends

struct ::QQmlJSTypePropagator
 

Detailed Description

\inmodule QtQmlCompiler

Can analyze an element and its children with static analysis passes.

Definition at line 308 of file qqmlsa.h.

Constructor & Destructor Documentation

◆ PassManager()

QQmlSA::PassManager::PassManager ( QQmlJSImportVisitor visitor,
QQmlJSTypeResolver resolver 
)

Constructs a pass manager given an import visitor and a type resolver.

Definition at line 1009 of file qqmlsa.cpp.

◆ ~PassManager()

QQmlSA::PassManager::~PassManager ( )
default

Member Function Documentation

◆ analyze()

void QQmlSA::PassManager::analyze ( const Element root)

Runs the element passes over root and all its children.

Definition at line 1154 of file qqmlsa.cpp.

References d.

◆ bindingsByLocation()

std::unordered_map< quint32, BindingInfo > QQmlSA::PassManager::bindingsByLocation ( ) const

Returns bindings by their source location.

Definition at line 1470 of file qqmlsa.cpp.

References d.

◆ elementPasses()

std::vector< std::shared_ptr< ElementPass > > QQmlSA::PassManager::elementPasses ( ) const

Returns the list of element passes.

Definition at line 1452 of file qqmlsa.cpp.

References d.

◆ hasImportedModule()

bool QQmlSA::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(), registerElementPass()

Definition at line 1233 of file qqmlsa.cpp.

References QQmlJSScope::ContextualTypes::hasType(), QQmlJSImportVisitor::imports(), QAnyStringView::toString(), and QQmlSA::PassManagerPrivate::visitor().

+ Here is the call graph for this function:

◆ isCategoryEnabled()

bool QQmlSA::PassManager::isCategoryEnabled ( QQmlJS::LoggerWarningId  category) const

Returns true if warnings of category are enabled, false otherwise.

Definition at line 1241 of file qqmlsa.cpp.

References category(), QQmlJSLogger::isCategoryIgnored(), QQmlJSImportVisitor::logger(), and QQmlSA::PassManagerPrivate::visitor().

+ Here is the call graph for this function:

◆ propertyPasses()

std::multimap< QString, PropertyPassInfo > QQmlSA::PassManager::propertyPasses ( ) const

Returns the list of property passes.

Definition at line 1461 of file qqmlsa.cpp.

References d.

◆ registerElementPass()

void QQmlSA::PassManager::registerElementPass ( std::unique_ptr< ElementPass pass)

Registers a static analysis pass to be run on all elements.

Definition at line 1019 of file qqmlsa.cpp.

References d.

◆ registerPropertyPass()

bool QQmlSA::PassManager::registerPropertyPass ( std::shared_ptr< 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");
QNetworkAccessManager manager
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 \l{QQmlSA::Element}{Element} specified by moduleName and typeName does not exist.

See also
PropertyPass

Definition at line 1088 of file qqmlsa.cpp.

References d, and typeName.

Friends And Related Symbol Documentation

◆ ::QQmlJSTypePropagator

friend struct ::QQmlJSTypePropagator
friend

Definition at line 310 of file qqmlsa.h.


The documentation for this class was generated from the following files: