6#include <private/qqmljsimportvisitor_p.h>
7#include <private/qqmljstyperesolver_p.h>
8#include <private/qqmljsmetatypes_p.h>
9#include <private/qqmlsa_p.h>
10#include <private/qqmlsasourcelocation_p.h>
11#include <private/qqmlstringconverters_p.h>
25 if (resolver->
equals(from, to))
51 m_resolver(
QQmlSA::PassManagerPrivate::resolver(*passManager))
77 Q_UNREACHABLE_RETURN(
QString());
87 const QString unqualifiedPropertyName = [&propertyName]() ->
QString {
88 if (
auto idx = propertyName.
lastIndexOf(u
'.'); idx != -1 && idx != propertyName.
size() - 1)
89 return propertyName.
sliced(idx + 1);
93 return bindingScope.
property(unqualifiedPropertyName);
104 const auto property =
getProperty(propertyName, binding, bindingScope);
111 emitWarning(u
"Cannot assign to read-only property %1"_s.arg(propertyName),
115 if (
auto propertyType =
property.type(); propertyType) {
116 auto construction =
check(propertyType.internalId(), binding.
stringValue());
117 if (construction.isValid()) {
119 u
"Binding is not supported: Type %1 should be constructed using"
120 u
" QML_STRUCTURED_VALUE's construction mechanism, instead of a "
121 u
"string."_s.
arg(propertyType.internalId());
123 if (!construction.code.isNull()) {
125 u
"Replace string by structured value construction"_s,
145 const auto property =
getProperty(propertyName, binding, bindingScope);
150 emitWarning(u
"Cannot assign literal of type %1 to %2"_s.arg(
QQmlSA::Property getProperty(const QString &propertyName, const QQmlSA::Binding &binding, const QQmlSA::Element &bindingScope) const
virtual QQmlJSStructuredTypeError check(const QString &typeName, const QString &value) const =0
void onBinding(const QQmlSA::Element &element, const QString &propertyName, const QQmlSA::Binding &binding, const QQmlSA::Element &bindingScope, const QQmlSA::Element &value) override
Executes whenever a property gets bound to a value.
QQmlJSLiteralBindingCheck(QQmlSA::PassManager *manager)
QQmlJSStructuredTypeError check(const QString &typeName, const QString &value) const override
void onBinding(const QQmlSA::Element &element, const QString &propertyName, const QQmlSA::Binding &binding, const QQmlSA::Element &bindingScope, const QQmlSA::Element &value) override
Executes whenever a property gets bound to a value.
static const QQmlJSScope::ConstPtr & scope(const QQmlSA::Element &)
static QString prettyName(QAnyStringView name)
bool equals(const QQmlJSScope::ConstPtr &a, const QQmlJSScope::ConstPtr &b) const
QQmlJSScope::ConstPtr stringType() const
bool isNumeric(const QQmlJSRegisterContent &type) const
QQmlJSScope::ConstPtr byteArrayType() const
QQmlJSScope::ConstPtr boolType() const
bool canConvertFromTo(const QQmlJSScope::ConstPtr &from, const QQmlJSScope::ConstPtr &to) const
QQmlJSScope::ConstPtr stringListType() const
QQmlJSScope::ConstPtr urlType() const
static QQmlJSStructuredTypeError hasError(const QString &typeName, const QString &value)
BindingType bindingType() const
static bool isLiteralBinding(BindingType)
Returns true if bindingType is a literal type, and false otherwise.
QString stringValue() const
Returns the associated string literal if the content type of this binding is StringLiteral,...
QQmlSA::SourceLocation sourceLocation() const
Returns the location in the QML code where this binding is defined.
Property property(const QString &propertyName) const
Returns the property with the name propertyName if it is found in this Element or its base and extens...
bool hasOwnProperty(const QString &propertyName) const
Returns whether this Element defines a property with the name propertyName which is not defined on it...
void emitWarning(QAnyStringView diagnostic, LoggerWarningId id)
Emits a warning message diagnostic about an issue of type id.
Element resolveLiteralType(const Binding &binding)
Returns the element representing the type of literal in binding.
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QString sliced(qsizetype pos) const &
qsizetype size() const noexcept
Returns the number of characters in this string.
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static bool canConvertForLiteralBinding(QQmlJSTypeResolver *resolver, const QQmlSA::Element &fromElement, const QQmlSA::Element &toElement)
static QString literalPrettyTypeName(QQmlSA::BindingType type)
const QQmlSA::LoggerWarningId qmlReadOnlyProperty
const QQmlSA::LoggerWarningId qmlIncompatibleType