QQmlSA Namespace

为 QML 程序提供静态分析工具。更多

Header: #include <QQmlSA>
CMake: find_package(Qt6 REQUIRED COMPONENTS QmlCompiler)
target_link_libraries(mytarget PRIVATE Qt6::QmlCompiler)
状态: 技术预览技术预览

类别

class Binding
class Element
class ElementPass
class FixSuggestion
class GenericPass
class LintPlugin
class LoggerWarningId
class Method
class PassManager
class Property
class PropertyPass
class SourceLocation

类型

enum class AccessSemantics { Reference, Value, None, Sequence }
enum class BindingType { Invalid, BoolLiteral, NumberLiteral, StringLiteral, RegExpLiteral, …, GroupProperty }
enum class MethodType { Signal, Slot, Method, StaticMethod }
enum class ScopeType { JSFunctionScope, JSLexicalScope, QMLScope, GroupedPropertyScope, AttachedPropertyScope, EnumScope }
enum class ScriptBindingKind { Invalid, PropertyBinding, SignalHandler, ChangeHandler }

详细说明

绑定

代表特定类型的单一 QML 属性绑定。更多...

元素

代表一个 QML 类型。更多

ElementPass

元素上所有静态分析传递的基类。更多

FixSuggestion

源代码中问题的建议修复。更多

通用传递

静态分析通行证的基类。更多

LintPlugin

所有静态分析插件的基类。更多

LoggerWarningId

用于在QQmlSA 框架中唯一标识警告类别的字符串字面的封装。更多

方法

代表 QML 方法。更多

PassManager

可以用静态分析传递分析一个元素及其子元素。更多

属性

代表一个 QML 属性。更多

PropertyPass

所有属性静态分析传递的基类。更多

SourceLocation

代表源代码中的位置或区域。更多

类型文档

enum class QQmlSA::AccessSemantics

描述类型的访问和共享方式。

常量说明
QQmlSA::AccessSemantics::Reference0该类型的行为类似于对象类型
QQmlSA::AccessSemantics::Value1该类型的行为类似于值类型
QQmlSA::AccessSemantics::None2类型是命名空间,或无效
QQmlSA::AccessSemantics::Sequence3类型表现为序列类型

另请参阅 QML 类型系统

enum class QQmlSA::BindingType

描述QQmlSA::Binding 的类型。

常量说明
QQmlSA::BindingType::Invalid0没有绑定
QQmlSA::BindingType::BoolLiteral1绑定为 bool 字面
QQmlSA::BindingType::NumberLiteral2绑定为数字字面
QQmlSA::BindingType::StringLiteral3绑定为字符串字面
QQmlSA::BindingType::RegExpLiteral4绑定为正则表达式字面
QQmlSA::BindingType::Null5绑定为空字面
QQmlSA::BindingType::Translation6绑定为翻译
QQmlSA::BindingType::TranslationById7绑定是按 ID 的翻译
QQmlSA::BindingType::Script8绑定为正则脚本
QQmlSA::BindingType::Object9绑定对象
QQmlSA::BindingType::Interceptor10绑定是一个拦截器,可拦截写入行为等属性的内容
QQmlSA::BindingType::ValueSource11绑定是一个属性值源
QQmlSA::BindingType::AttachedProperty12绑定是一个附加对象
QQmlSA::BindingType::GroupProperty13绑定是分组属性

enum class QQmlSA::MethodType

描述QQmlSA::Method 的类型。

常量说明
QQmlSA::MethodType::Signal0该方法是一个信号
QQmlSA::MethodType::Slot1方法是槽
QQmlSA::MethodType::Method2该方法是Q_INVOKABLE 方法
QQmlSA::MethodType::StaticMethod3该方法是Q_INVOKABLE 静态方法

enum class QQmlSA::ScopeType

描述 QML 作用域的类型。

常量描述
QQmlSA::ScopeType::JSFunctionScope0作用域是 JavaScript 函数:
Item {
    function f() : int { <- begin
        return 1
    } <- end
}
QQmlSA::ScopeType::JSLexicalScope1作用域是 JavaScript 词法作用域:
property int i: { <- begin
    let a = 1
    { <- begin
        console.log("hello")
    } <- end
    return a
} <- end
QQmlSA::ScopeType::QMLScope2作用域是 QML 对象:
Item { <- begin
    x: 50
} <- end
QQmlSA::ScopeType::GroupedPropertyScope3范围是分组属性
Text {
    font { <- begin
        pixelSize: 12
        bold: true
    } <- end
}
QQmlSA::ScopeType::AttachedPropertyScope4范围是附加属性
Item {
    Component.onCompleted: console.log("Hello")
    ^^^^^^^^^
             \ Scope of attached property Component
}
QQmlSA::ScopeType::EnumScope5范围是 QML枚举
enum E { <- begin
    A,
    B,
    C
} <- end

每个条目都显示了 QML 代码中匹配类型的示例作用域。

enum class QQmlSA::ScriptBindingKind

描述QQmlSA::Binding 类型为Script 的脚本类型。

常量说明
QQmlSA::ScriptBindingKind::Invalid0绑定的脚本无效
QQmlSA::ScriptBindingKind::PropertyBinding1绑定已绑定到一个属性
QQmlSA::ScriptBindingKind::SignalHandler2绑定是一个信号处理器
QQmlSA::ScriptBindingKind::ChangeHandler3绑定为更改处理程序

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