QQmlSA Namespace

Provides tools for static analysis on QML programs. 更多...

头: #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

类型

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

详细描述

class Binding

Represents a single QML property binding for a specific type. 更多...

class Element

表示 QML 类型。 更多...

class ElementPass

Base class for all static analysis passes on elements. 更多...

class FixSuggestion

Represents a suggested fix for an issue in the source code. 更多...

class GenericPass

The base class for static analysis passes. 更多...

class LintPlugin

Base class for all static analysis plugins. 更多...

class LoggerWarningId

A wrapper around a string literal to uniquely identify warning categories in the QQmlSA 框架。 更多...

class Method

Represents a QML method. 更多...

class PassManager

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

class Property

Represents a QML property. 更多...

class PropertyPass

Base class for all static analysis passes on properties. 更多...

class SourceLocation

Represents a location or region in the source code. 更多...

类型文档编制

enum class QQmlSA:: AccessSemantics

Describes how a type is accessed and shared.

常量 描述
QQmlSA::AccessSemantics::Reference 0 The type behaves like an Object type
QQmlSA::AccessSemantics::Value 1 The type behaves like a Value type
QQmlSA::AccessSemantics::None 2 The type is a namespace , or is invalid
QQmlSA::AccessSemantics::Sequence 3 The type behaves like a Sequence type

另请参阅 QML 类型系统 .

enum class QQmlSA:: BindingType

Describes the type of a QQmlSA::Binding .

常量 描述
QQmlSA::BindingType::Invalid 0 There is no binding
QQmlSA::BindingType::BoolLiteral 1 The binding is a bool literal
QQmlSA::BindingType::NumberLiteral 2 The binding is a number literal
QQmlSA::BindingType::StringLiteral 3 The binding is a string literal
QQmlSA::BindingType::RegExpLiteral 4 The binding is a regular expression literal
QQmlSA::BindingType::Null 5 The binding is a null literal
QQmlSA::BindingType::Translation 6 The binding is a translation
QQmlSA::BindingType::TranslationById 7 The binding is a translation by id
QQmlSA::BindingType::Script 8 The binding is a regular script
QQmlSA::BindingType::Object 9 The binging is an 对象
QQmlSA::BindingType::Interceptor 10 The binding is an interceptor that can intercept writes to properties such as 行为
QQmlSA::BindingType::ValueSource 11 The binging is a property value source
QQmlSA::BindingType::AttachedProperty 12 The binding is an attached object
QQmlSA::BindingType::GroupProperty 13 The binding is a grouped property

enum class QQmlSA:: MethodType

Describes the type of a QQmlSA::Method .

常量 描述
QQmlSA::MethodType::Signal 0 The method is a signal
QQmlSA::MethodType::Slot 1 The method is a slot
QQmlSA::MethodType::Method 2 The method is a Q_INVOKABLE 方法
QQmlSA::MethodType::StaticMethod 3 The method is a Q_INVOKABLE static method

enum class QQmlSA:: ScopeType

Describes the type of QML scope.

常量 描述
QQmlSA::ScopeType::JSFunctionScope 0 The scope is a JavaScript function:
Item {
function f() : int { <- begin
return 1
} <- end
}
								
QQmlSA::ScopeType::JSLexicalScope 1 The scope is a JavaScript lexical scope:
property int i: { <- begin
let a = 1
{ <- begin
console.log("hello")
} <- end
return a
} <- end
								
QQmlSA::ScopeType::QMLScope 2 The scope is a QML Object:
Item { <- begin
x: 50
} <- end
								
QQmlSA::ScopeType::GroupedPropertyScope 3 The scope is a grouped property :
Text {
font { <- begin
pixelSize: 12
bold: true
} <- end
}
								
QQmlSA::ScopeType::AttachedPropertyScope 4 The scope is an attached property :
Item {
Component.onCompleted: console.log("Hello")
^^^^^^^^^
\ Scope of attached property Component
}
								
QQmlSA::ScopeType::EnumScope 5 The scope is a QML enum :
enum E { <- begin
A,
B,
C
} <- end
								

Each entry is shown with an example scope of the matching type in QML code.

enum class QQmlSA:: ScriptBindingKind

Describes the script type of a QQmlSA::Binding 类型 Script .

常量 描述
QQmlSA::ScriptBindingKind::Invalid 0 The binding has an invalid script
QQmlSA::ScriptBindingKind::PropertyBinding 1 The binding is bound to a property
QQmlSA::ScriptBindingKind::SignalHandler 2 The binding is a 信号处理程序
QQmlSA::ScriptBindingKind::ChangeHandler 3 The binding is a change handler