| 1 | // Copyright (C) 2022 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
| 3 | |
| 4 | #ifndef QQMLJSLITERALBINDINGCHECK_P_H |
| 5 | #define QQMLJSLITERALBINDINGCHECK_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | |
| 17 | #include <QtCore/qglobal.h> |
| 18 | #include <QtQmlCompiler/qqmlsa.h> |
| 19 | |
| 20 | #include <qtqmlcompilerexports.h> |
| 21 | #include "qqmljsvaluetypefromstringcheck_p.h" |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | class QQmlJSImportVisitor; |
| 26 | class QQmlJSTypeResolver; |
| 27 | |
| 28 | class Q_QMLCOMPILER_EXPORT LiteralBindingCheckBase : public QQmlSA::PropertyPass |
| 29 | { |
| 30 | public: |
| 31 | using QQmlSA::PropertyPass::PropertyPass; |
| 32 | |
| 33 | void onBinding(const QQmlSA::Element &element, const QString &propertyName, |
| 34 | const QQmlSA::Binding &binding, const QQmlSA::Element &bindingScope, |
| 35 | const QQmlSA::Element &value) override; |
| 36 | |
| 37 | protected: |
| 38 | virtual QQmlJSStructuredTypeError check(const QString &typeName, const QString &value) const = 0; |
| 39 | |
| 40 | QQmlSA::Property getProperty(const QString &propertyName, const QQmlSA::Binding &binding, |
| 41 | const QQmlSA::Element &bindingScope) const; |
| 42 | }; |
| 43 | |
| 44 | class Q_QMLCOMPILER_EXPORT QQmlJSLiteralBindingCheck: public LiteralBindingCheckBase |
| 45 | { |
| 46 | public: |
| 47 | QQmlJSLiteralBindingCheck(QQmlSA::PassManager *manager); |
| 48 | |
| 49 | void onBinding(const QQmlSA::Element &element, const QString &propertyName, |
| 50 | const QQmlSA::Binding &binding, const QQmlSA::Element &bindingScope, |
| 51 | const QQmlSA::Element &value) override; |
| 52 | |
| 53 | private: |
| 54 | QQmlJSTypeResolver *m_resolver; |
| 55 | |
| 56 | protected: |
| 57 | QQmlJSStructuredTypeError check(const QString &typeName, const QString &value) const override; |
| 58 | }; |
| 59 | |
| 60 | QT_END_NAMESPACE |
| 61 | |
| 62 | #endif // QQMLJSLITERALBINDINGCHECK_P_H |
| 63 | |