Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmljslintercodegen_p.h
Go to the documentation of this file.
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// Qt-Security score:significant
4
5#ifndef QQMLJSLINTERCODEGEN_P_H
6#define QQMLJSLINTERCODEGEN_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17
18#include <QString>
19#include <QFile>
20#include <QList>
21
22#include <variant>
23
24#include <private/qduplicatetracker_p.h>
25#include <private/qqmlirbuilder_p.h>
26#include <private/qqmljscompilepass_p.h>
27#include <private/qqmljscompiler_p.h>
28#include <private/qqmljscontextproperties_p.h>
29#include <private/qqmljsdiagnosticmessage_p.h>
30#include <private/qqmljslintertypepropagator_p.h>
31#include <private/qqmljslogger_p.h>
32#include <private/qqmljsscope_p.h>
33#include <private/qqmljstypepropagator_p.h>
34#include <private/qqmljstyperesolver_p.h>
35#include <private/qqmljsusercontextproperties_p.h>
36
37QT_BEGIN_NAMESPACE
38
39namespace QQmlSA {
40class PassManager;
41};
42
49bool operator==(const IdMemberShadow &lhs, const IdMemberShadow &rhs);
50bool operator!=(const IdMemberShadow &lhs, const IdMemberShadow &rhs);
51size_t qHash(const IdMemberShadow &idShadowsMember, size_t seed = 0);
52
54{
55public:
56 QQmlJSLinterCodegen(QQmlJSImporter *importer, const QString &fileName,
57 const QStringList &qmldirFiles, QQmlJSLogger *logger,
58 const ContextPropertyInfo &contextPropertyInfo);
59
60 void setDocument(const QmlIR::JSCodeGen *codegen, const QmlIR::Document *document) override;
67
68 void setTypeResolver(QQmlJSTypeResolver typeResolver)
69 {
70 m_typeResolver = std::move(typeResolver);
71 }
72
73 void setScopesById(const QQmlJSScopesById scopesByid)
74 {
75 m_scopesById = scopesByid;
76 }
77
78 void setRenamedComponents(const QQmlJS::LinterRenamedComponents *renamedComponents)
79 {
80 m_renamedComponents = renamedComponents;
81 }
82
83 void setKnownUnresolvedTypes(QDuplicateTracker<QQmlJSScope::ConstPtr> *tracker)
84 {
85 m_knownUnresolvedTypes = tracker;
86 }
87
88 QQmlJSTypeResolver *typeResolver() { return &m_typeResolver; }
89
90 void setPassManager(QQmlSA::PassManager *passManager);
91
92 QQmlSA::PassManager *passManager() { return m_passManager; }
93
94private:
95 QQmlSA::PassManager *m_passManager = nullptr;
96
97 void analyzeFunction(const QV4::Compiler::Context *context,
98 QQmlJSCompilePass::Function *function);
99 ContextPropertyInfo m_contextPropertyInfo;
100 QQmlJSScopesById m_scopesById;
101 QSet<IdMemberShadow> m_idMemberShadows;
102 QDuplicateTracker<QQmlJSScope::ConstPtr> *m_knownUnresolvedTypes = nullptr;
103 const QQmlJS::LinterRenamedComponents *m_renamedComponents = nullptr;
104};
105
106QT_END_NAMESPACE
107
108#endif
void reportVarUsedBeforeDeclaration(const QString &name, const QString &fileName, QQmlJS::SourceLocation declarationLocation, QQmlJS::SourceLocation accessLocation) override
void reportFunctionUsedBeforeDeclaration(const QString &name, const QString &fileName, QQmlJS::SourceLocation declarationLocation, QQmlJS::SourceLocation accessLocation) override
UnreachableVisitor * unreachableVisitor() override
CodegenWarningInterface(QQmlJSLogger *logger)
bool visit(QQmlJS::AST::FunctionDeclaration *functionDeclaration) override
void throwRecursionDepthError() override
void setTypeResolver(QQmlJSTypeResolver typeResolver)
QQmlSA::PassManager * passManager()
QQmlJSLinterCodegen(QQmlJSImporter *importer, const QString &fileName, const QStringList &qmldirFiles, QQmlJSLogger *logger, const ContextPropertyInfo &contextPropertyInfo)
QQmlJSTypeResolver * typeResolver()
void setScopesById(const QQmlJSScopesById scopesByid)
void setDocument(const QmlIR::JSCodeGen *codegen, const QmlIR::Document *document) override
void setPassManager(QQmlSA::PassManager *passManager)
void setRenamedComponents(const QQmlJS::LinterRenamedComponents *renamedComponents)
void setKnownUnresolvedTypes(QDuplicateTracker< QQmlJSScope::ConstPtr > *tracker)
const QList< QQmlJS::LoggerCategory > categories() const
bool isInternal() const
Plugin(Plugin &&plugin) noexcept
Plugin(const QStaticPlugin &plugin)
const QString & name() const
const QString & version() const
const QString & author() const
void setEnabled(bool isEnabled)
const QString & description() const
FixResult applyFixes(QString *fixedCode, bool silent)
void setPluginsEnabled(bool enablePlugins)
static std::vector< Plugin > loadPlugins(QStringList paths)
const QQmlJSLogger * logger() const
QQmlJSLinter(const QStringList &importPaths, const QStringList &extraPluginPaths={}, bool useAbsolutePath=false)
std::vector< Plugin > & plugins()
void setPlugins(std::vector< Plugin > plugins)
LintResult lintModule(const QString &uri, const bool silent, QJsonArray *json, const QStringList &qmlImportPaths, const QStringList &resourceFiles)
LintResult lintFile(const QString &filename, const QString *fileContents, const bool silent, QJsonArray *json, const QStringList &qmlImportPaths, const QStringList &qmldirFiles, const QStringList &resourceFiles, const QList< QQmlJS::LoggerCategory > &categories, const QQmlJS::HeuristicContextProperties &contextProperties={})
bool pluginsEnabled() const
UnreachableVisitor(QQmlJSLogger *logger)
void throwRecursionDepthError() override
bool containsFunctionDeclaration(QQmlJS::AST::Node *node)
bool visit(QQmlJS::AST::StatementList *unreachable) override
\inmodule QtQmlCompiler
Combined button and popup list for selecting options.
static void addJsonWarning(QJsonArray &warnings, const QQmlJS::DiagnosticMessage &message, QAnyStringView id, const std::optional< QQmlJSFixSuggestion > &suggestion={})
bool operator==(const IdMemberShadow &lhs, const IdMemberShadow &rhs)
bool operator!=(const IdMemberShadow &lhs, const IdMemberShadow &rhs)
size_t qHash(const IdMemberShadow &idShadowsMember, size_t seed)
QQmlJSScope::ConstPtr memberOwnerScope
QQmlJSScope::ConstPtr idScope