![]() |
Qt 6.x
The Qt SDK
|
\inmodule QtQmlCompiler More...
#include <qqmlsa.h>
Public Member Functions | |
GenericPass (PassManager *manager) | |
Creates a generic pass. | |
virtual | ~GenericPass () |
void | emitWarning (QAnyStringView diagnostic, QQmlJS::LoggerWarningId id) |
Emits a warning message diagnostic about an issue of type id. | |
void | emitWarning (QAnyStringView diagnostic, QQmlJS::LoggerWarningId id, QQmlSA::SourceLocation srcLocation) |
Emits warning message diagnostic about an issue of type id located at srcLocation. | |
void | emitWarning (QAnyStringView diagnostic, QQmlJS::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. | |
Element | resolveTypeInFileScope (QAnyStringView typeName) |
Returns the type corresponding to typeName inside the currently analysed file. | |
Element | resolveAttachedInFileScope (QAnyStringView typeName) |
Returns the attached type corresponding to typeName used inside the currently analysed file. | |
Element | resolveType (QAnyStringView moduleName, QAnyStringView typeName) |
Returns the type of typeName defined in module moduleName. | |
Element | resolveBuiltinType (QAnyStringView typeName) const |
Returns the type of the built-in type identified by typeName. | |
Element | resolveAttached (QAnyStringView moduleName, QAnyStringView typeName) |
Returns the attached type of typeName defined in module moduleName. | |
Element | resolveLiteralType (const Binding &binding) |
Returns the element representing the type of literal in binding. | |
Element | resolveIdToElement (QAnyStringView id, const Element &context) |
Returns the element in context that has id id. | |
QString | resolveElementToId (const Element &element, const Element &context) |
Returns the id of element in a given context. | |
QString | sourceCode (QQmlSA::SourceLocation location) |
Returns the source code located within location. | |
\inmodule QtQmlCompiler
The base class for static analysis passes.
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.
QQmlSA::GenericPass::GenericPass | ( | PassManager * | manager | ) |
Creates a generic pass.
Definition at line 844 of file qqmlsa.cpp.
|
virtualdefault |
void QQmlSA::GenericPass::emitWarning | ( | QAnyStringView | diagnostic, |
QQmlJS::LoggerWarningId | id | ||
) |
Emits a warning message diagnostic about an issue of type id.
Definition at line 850 of file qqmlsa.cpp.
References emitWarning().
Referenced by emitWarning(), VarBindingTypeValidatorPass::onBinding(), QQmlSA::DebugPropertyPass::onBinding(), AttachedPropertyReuse::onRead(), QQmlSA::DebugPropertyPass::onRead(), QQmlSA::DebugPropertyPass::onWrite(), QQmlSA::DebugElementPass::run(), ForbiddenChildrenPropertyValidatorPass::run(), ControlsNativeValidatorPass::run(), AnchorsValidatorPass::run(), ControlsSwipeDelegateValidatorPass::run(), and PropertyChangesValidatorPass::run().
void QQmlSA::GenericPass::emitWarning | ( | QAnyStringView | diagnostic, |
QQmlJS::LoggerWarningId | id, | ||
QQmlSA::SourceLocation | srcLocation | ||
) |
Emits warning message diagnostic about an issue of type id located at srcLocation.
Definition at line 859 of file qqmlsa.cpp.
References d, QQmlJSLogger::log(), QQmlJSImportVisitor::logger(), QQmlSA::SourceLocationPrivate::sourceLocation(), QAnyStringView::toString(), and QQmlSA::PassManagerPrivate::visitor().
void QQmlSA::GenericPass::emitWarning | ( | QAnyStringView | diagnostic, |
QQmlJS::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.
Definition at line 873 of file qqmlsa.cpp.
References d, QQmlSA::FixSuggestionPrivate::fixSuggestion(), QQmlJSLogger::log(), QQmlJSImportVisitor::logger(), QQmlSA::SourceLocationPrivate::sourceLocation(), QAnyStringView::toString(), and QQmlSA::PassManagerPrivate::visitor().
Element QQmlSA::GenericPass::resolveAttached | ( | QAnyStringView | moduleName, |
QAnyStringView | typeName | ||
) |
Returns the attached type of typeName defined in module moduleName.
Definition at line 948 of file qqmlsa.cpp.
References QQmlJSScope::createQQmlSAElement(), resolveType(), QQmlJSScope::scope(), and typeName.
Referenced by AttachedPropertyTypeValidatorPass::addWarning().
Element QQmlSA::GenericPass::resolveAttachedInFileScope | ( | QAnyStringView | typeName | ) |
Returns the attached type corresponding to typeName used inside the currently analysed file.
Definition at line 900 of file qqmlsa.cpp.
References QQmlJSScope::createQQmlSAElement(), resolveTypeInFileScope(), QQmlJSScope::scope(), and typeName.
Referenced by AttachedPropertyReuse::onRead().
Element QQmlSA::GenericPass::resolveBuiltinType | ( | QAnyStringView | typeName | ) | const |
Returns the type of the built-in type identified by typeName.
Built-in types encompasses {C++} types which the QML engine can handle without any imports (e.g. \l QDateTime and \l QString), global EcmaScript objects like
Number
, as well as the \l{global Qt object} {QML Global Object}.
Definition at line 930 of file qqmlsa.cpp.
References QQmlJSImporter::builtinInternalNames(), QQmlJSScope::createQQmlSAElement(), d, QQmlJSImporter::importBuiltins(), QQmlJSImportVisitor::importer(), QQmlJSScope::ContextualTypes::type(), typeName, and QQmlSA::PassManagerPrivate::visitor().
Referenced by VarBindingTypeValidatorPass::VarBindingTypeValidatorPass().
QString QQmlSA::GenericPass::resolveElementToId | ( | const Element & | element, |
const Element & | context | ||
) |
Returns the id of element in a given context.
Definition at line 979 of file qqmlsa.cpp.
References QQmlJSImportVisitor::addressableScopes(), context, d, QQmlJSScopesById::id(), QQmlJSScope::scope(), and QQmlSA::PassManagerPrivate::visitor().
Referenced by AttachedPropertyReuse::onRead().
Element QQmlSA::GenericPass::resolveIdToElement | ( | QAnyStringView | id, |
const Element & | context | ||
) |
Returns the element in context that has id id.
Definition at line 967 of file qqmlsa.cpp.
References QQmlJSImportVisitor::addressableScopes(), context, QQmlJSScope::createQQmlSAElement(), d, QQmlJSScope::scope(), QQmlJSScopesById::scope(), toString(), and QQmlSA::PassManagerPrivate::visitor().
Referenced by PropertyChangesValidatorPass::run().
Returns the element representing the type of literal in binding.
If the binding does not contain a literal value, a null Element is returned.
Definition at line 958 of file qqmlsa.cpp.
References d, QQmlSA::Binding::literalType(), and QQmlSA::PassManagerPrivate::resolver().
Referenced by VarBindingTypeValidatorPass::onBinding().
Element QQmlSA::GenericPass::resolveType | ( | QAnyStringView | moduleName, |
QAnyStringView | typeName | ||
) |
Returns the type of typeName defined in module moduleName.
If an attached type and and a non-attached type share the same name (e.g. ListView
), the \l Element corresponding to the non-attached type is returned. To obtain the attached type, use \l resolveAttached.
Definition at line 914 of file qqmlsa.cpp.
References QQmlJSScope::createQQmlSAElement(), d, QQmlJSImportVisitor::importer(), QQmlJSImporter::importModule(), QAnyStringView::toString(), QQmlJSScope::ContextualTypes::type(), typeName, and QQmlSA::PassManagerPrivate::visitor().
Referenced by ControlsNativeValidatorPass::ControlsNativeValidatorPass(), VarBindingTypeValidatorPass::VarBindingTypeValidatorPass(), ForbiddenChildrenPropertyValidatorPass::addWarning(), AttachedPropertyTypeValidatorPass::addWarning(), and resolveAttached().
Element QQmlSA::GenericPass::resolveTypeInFileScope | ( | QAnyStringView | typeName | ) |
Returns the type corresponding to typeName inside the currently analysed file.
Definition at line 888 of file qqmlsa.cpp.
References QQmlJSScope::createQQmlSAElement(), d, QQmlJSImportVisitor::imports(), QQmlJSScope::ContextualTypes::type(), typeName, and QQmlSA::PassManagerPrivate::visitor().
Referenced by AttachedPropertyReuse::onRead(), and resolveAttachedInFileScope().
QString QQmlSA::GenericPass::sourceCode | ( | QQmlSA::SourceLocation | location | ) |
Returns the source code located within location.
Definition at line 990 of file qqmlsa.cpp.
References QQmlJSLogger::code(), d, QQmlJSImportVisitor::logger(), QString::mid(), and QQmlSA::PassManagerPrivate::visitor().
Referenced by PropertyChangesValidatorPass::run().