1// Copyright (C) 2021 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 QQMLJSLINTERCODEGEN_P_H
5#define QQMLJSLINTERCODEGEN_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 <QString>
18#include <QFile>
19#include <QList>
20
21#include <variant>
22#include <memory>
23#include <private/qqmljsdiagnosticmessage_p.h>
24#include <private/qqmlirbuilder_p.h>
25#include <private/qqmljsscope_p.h>
26#include <private/qqmljscompiler_p.h>
27
28#include <QtQmlCompiler/private/qqmljstyperesolver_p.h>
29#include <QtQmlCompiler/private/qqmljslogger_p.h>
30#include <QtQmlCompiler/private/qqmljscompilepass_p.h>
31
32QT_BEGIN_NAMESPACE
33
34namespace QQmlSA {
35class PassManager;
36};
37
38class QQmlJSLinterCodegen : public QQmlJSAotCompiler
39{
40public:
41 QQmlJSLinterCodegen(QQmlJSImporter *importer, const QString &fileName,
42 const QStringList &qmldirFiles, QQmlJSLogger *logger);
43
44 void setDocument(const QmlIR::JSCodeGen *codegen, const QmlIR::Document *document) override;
45 std::variant<QQmlJSAotFunction, QQmlJS::DiagnosticMessage>
46 compileBinding(const QV4::Compiler::Context *context, const QmlIR::Binding &irBinding,
47 QQmlJS::AST::Node *astNode) override;
48 std::variant<QQmlJSAotFunction, QQmlJS::DiagnosticMessage>
49 compileFunction(const QV4::Compiler::Context *context, const QString &name,
50 QQmlJS::AST::Node *astNode) override;
51
52 void setTypeResolver(QQmlJSTypeResolver typeResolver)
53 {
54 m_typeResolver = std::move(typeResolver);
55 }
56
57 QQmlJSTypeResolver *typeResolver() { return &m_typeResolver; }
58
59 void setPassManager(QQmlSA::PassManager *passManager) { m_passManager = passManager; }
60
61 QQmlSA::PassManager *passManager() { return m_passManager; }
62
63private:
64 QQmlSA::PassManager *m_passManager = nullptr;
65
66 bool analyzeFunction(const QV4::Compiler::Context *context,
67 QQmlJSCompilePass::Function *function, QQmlJS::DiagnosticMessage *error);
68};
69
70QT_END_NAMESPACE
71
72#endif
73

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