GenericPass Class

class QQmlSA::GenericPass

The base class for static analysis passes. More...

Header: #include <GenericPass>
CMake: find_package(Qt6 REQUIRED COMPONENTS QmlCompiler)
target_link_libraries(mytarget PRIVATE Qt6::QmlCompiler)
Inherited By:

QQmlSA::ElementPass and QQmlSA::PropertyPass

Status: Technical Preview

Public Functions

GenericPass(QQmlSA::PassManager *manager)
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)

Detailed Description

This class contains common functionality used by more specific passses. Custom passes should not directly derive from it, but rather from one of its subclasses.

See also ElementPass and PropertyPass.

Member Function Documentation

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

Creates a generic pass.

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

Emits a warning message diagnostic about an issue of type id.

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

Emits warning message diagnostic about an issue of type id located at srcLocation.

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

Emits a warning message diagnostic about an issue of type id located at srcLocation and with suggested fix fix.

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

Returns the attached type of typeName defined in module moduleName.

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

Returns the attached type corresponding to typeName used inside the currently analysed file.

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

Returns the type of the built-in type identified by typeName. Built-in types encompass C++ types which the QML engine can handle without any imports (e.g. QDateTime and QString), global EcmaScript objects like Number, as well as the global Qt object.

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

Returns the id of element in a given context.

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

Returns the element in context that has id id.

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

Returns the element representing the type of literal in binding. If the binding does not contain a literal value, a null Element is returned.

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

Returns the type of typeName defined in module moduleName. If an attached type and a non-attached type share the same name (for example, ListView), the Element corresponding to the non-attached type is returned. To obtain the attached type, use resolveAttached.

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

Returns the type corresponding to typeName inside the currently analysed file.

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

Returns the source code located within location.