PassManager Class

class QQmlSA::PassManager

静的解析パスで要素とその子を解析することができます。さらに...

ヘッダ #include <PassManager>
CMake: find_package(Qt6 REQUIRED COMPONENTS QmlCompiler)
target_link_libraries(mytarget PRIVATE Qt6::QmlCompiler)
ステータステクニカルプレビュー

パブリック関数

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)

詳細説明

メンバ関数の説明

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

root 、そのすべての子要素を通過する。

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

バインディングをソース位置から返します。

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

エレメントパスのリストを返します。

bool PassManager::hasImportedModule(QAnyStringView module) const

解析対象の QML にmodule というモジュールがインポートされていればtrue を、そうでなければfalse を返します。

これは特定のモジュールに特化したパスの登録をスキップするために使用できます。

if (passManager->hasImportedModule("QtPositioning"))
    passManager->registerElementPass(
       std::make_unique<PositioningPass>(passManager)
    );

registerPropertyPass() およびregisterElementPass()も参照してください

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

category の警告が有効な場合はtrue を、そうでない場合はfalse を返す。

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

プロパティ・パスのリストを返す。

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

すべての要素に対して実行される静的解析pass を登録する。

bool PassManager::registerPropertyPass(std::shared_ptr<QQmlSA::PropertyPass> pass, QAnyStringView moduleName, QAnyStringView typeName, QAnyStringView propertyName = QAnyStringView(), bool allowInheritance = true)

プロパティの静的解析パスを登録する。pass は、moduleNametypeNamepropertyName にマッチするすべてのプロパティに対して実行されます。

propertyName を省略すると、typeNamemoduleName にマッチするすべてのプロパティに対してこのパスが登録されます。

allowInheritancetrue に設定することは、型に対するフィルタリングがtypeName から派生する型も受け付けることを意味します。

pass を として渡すと、複数の要素で同じパスを再利用できます:std::shared_ptr

auto titleValiadorPass = std::make_shared<TitleValidatorPass>(manager);
manager->registerPropertyPass(titleValidatorPass,
                              "QtQuick", "Window", "title");
manager->registerPropertyPass(titleValidatorPass,
                              "QtQuick.Controls", "Dialog", "title");

注意: あまりに多くの項目に対して分析パスを実行すると、コストが高くなる可能性があります。このため、一般的には、moduleNametypeNamepropertyName を使用して、パスのプロパティのセットを絞り込むとよいでしょう。

パスの追加に成功した場合はtrue を、失敗した場合はfalse を返します。moduleNametypeName で指定されたElement が存在しない場合、パスの追加は失敗します。

PropertyPassも参照してください

© 2025 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.