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
23QT_BEGIN_NAMESPACE
24
25class QQmlJSImportVisitor;
26class QQmlJSTypeResolver;
27
28class Q_QMLCOMPILER_EXPORT LiteralBindingCheckBase : public QQmlSA::PropertyPass
29{
30public:
31 using QQmlSA::PropertyPass::PropertyPass;
32
33protected:
34 virtual QQmlJSStructuredTypeError check(const QString &typeName, const QString &value) const = 0;
35
36 QQmlSA::Property getProperty(const QString &propertyName, const QQmlSA::Binding &binding,
37 const QQmlSA::Element &bindingScope) const;
38
39 void warnOnCheckedBinding(const QQmlSA::Binding &binding, const QQmlSA::Element &propertyType);
40};
41
42class Q_QMLCOMPILER_EXPORT QQmlJSLiteralBindingCheck: public LiteralBindingCheckBase
43{
44public:
45 QQmlJSLiteralBindingCheck(QQmlSA::PassManager *manager);
46
47 void onBinding(const QQmlSA::Element &element, const QString &propertyName,
48 const QQmlSA::Binding &binding, const QQmlSA::Element &bindingScope,
49 const QQmlSA::Element &value) override;
50
51private:
52 QQmlJSTypeResolver *m_resolver;
53
54protected:
55 QQmlJSStructuredTypeError check(const QString &typeName, const QString &value) const override;
56};
57
58QT_END_NAMESPACE
59
60#endif // QQMLJSLITERALBINDINGCHECK_P_H
61

source code of qtdeclarative/src/qmlcompiler/qqmljsliteralbindingcheck_p.h