本页内容

QQmlSA::GenericPass Class

class QQmlSA::GenericPass

静态分析通过的基类。更多...

头文件: #include <qqmlsa.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS QmlCompiler)
target_link_libraries(mytarget PRIVATE Qt6::QmlCompiler)
由以下类继承:

QQmlSA::ElementPass 以及QQmlSA::PropertyPass

状态: 技术预览

该类处于技术预览阶段,内容可能会发生变更。

公共函数

GenericPass(QQmlSA::PassManager *manager)
virtual ~GenericPass()
void emitWarning(QAnyStringView diagnostic, QQmlSA::LoggerWarningId id)
void emitWarning(QAnyStringView diagnostic, QQmlSA::LoggerWarningId id, QQmlSA::SourceLocation srcLocation)
void emitWarning(QAnyStringView diagnostic, QQmlSA::LoggerWarningId id, QQmlSA::SourceLocation srcLocation, const QQmlSA::FixSuggestion &fix)
QQmlSA::Element resolveAttached(QAnyStringView moduleName, QAnyStringView typeName)
QQmlSA::Element resolveAttachedInFileScope(QAnyStringView typeName)
QQmlSA::Element resolveBuiltinType(QAnyStringView typeName) const
QString resolveElementToId(const QQmlSA::Element &element, const QQmlSA::Element &context)
QQmlSA::Element resolveIdToElement(QAnyStringView id, const QQmlSA::Element &context)
QQmlSA::Element resolveLiteralType(const QQmlSA::Binding &binding)
QQmlSA::Element resolveType(QAnyStringView moduleName, QAnyStringView typeName)
QQmlSA::Element resolveTypeInFileScope(QAnyStringView typeName)
QString sourceCode(QQmlSA::SourceLocation location)

详细描述

该类包含更具体的处理阶段所使用的通用功能。自定义处理阶段不应直接从该类派生,而应从其子类之一派生。

另请参阅 ElementPass 和PropertyPass 。

成员函数文档

GenericPass::GenericPass(QQmlSA::PassManager *manager)

创建一张通用通行证。

[virtual noexcept] GenericPass::~GenericPass()

销毁该GenericPass 实例。

void GenericPass::emitWarning(QAnyStringView diagnostic, QQmlSA::LoggerWarningId id)

会显示一条关于类型为id 的问题的警告消息:diagnostic 。

void GenericPass::emitWarning(QAnyStringView diagnostic, QQmlSA::LoggerWarningId id, QQmlSA::SourceLocation srcLocation)

显示警告消息diagnostic ,提示位于srcLocation 的问题类型为id 。

void GenericPass::emitWarning(QAnyStringView diagnostic, QQmlSA::LoggerWarningId id, QQmlSA::SourceLocation srcLocation, const QQmlSA::FixSuggestion &fix)

显示一条警告消息diagnostic ,指出位于srcLocation 的问题类型为id ,并提供了建议的修复方案fix 。

QQmlSA::Element GenericPass::resolveAttached(QAnyStringView moduleName, QAnyStringView typeName)

返回模块moduleName 中定义的typeName 的关联类型。

QQmlSA::Element GenericPass::resolveAttachedInFileScope(QAnyStringView typeName)

返回与当前正在分析的文件中使用的typeName 对应的附加类型。

QQmlSA::Element GenericPass::resolveBuiltinType(QAnyStringView typeName) const

返回由typeName 标识的内置类型的类型。内置类型包括C++ 中那些QML引擎无需任何导入即可处理的类型(例如QDateTime 和QString )、诸如Number 之类的全局ECMAScript对象,以及全局Qt对象。

QString GenericPass::resolveElementToId(const QQmlSA::Element &element, const QQmlSA::Element &context)

返回给定context 中element 的ID。

QQmlSA::Element GenericPass::resolveIdToElement(QAnyStringView id, const QQmlSA::Element &context)

返回context 中 id 为id 的元素。

QQmlSA::Element GenericPass::resolveLiteralType(const QQmlSA::Binding &binding)

返回表示binding 中字面量类型的元素。如果该绑定不包含字面量值,则返回一个 null 类型的 Element。

QQmlSA::Element GenericPass::resolveType(QAnyStringView moduleName, QAnyStringView typeName)

返回在模块moduleName 中定义的 `typeName ` 的类型。如果一个已关联类型和一个未关联类型具有相同名称(例如,ListView ),则返回对应于未关联类型的 `Element `。要获取已关联类型,请使用 `resolveAttached`。

QQmlSA::Element GenericPass::resolveTypeInFileScope(QAnyStringView typeName)

返回当前正在分析的文件中与typeName 对应的类型。

QString GenericPass::sourceCode(QQmlSA::SourceLocation location)

返回位于location 中的源代码。

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