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
qqmljslogger_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 QQMLJSLOGGER_P_H
6#define QQMLJSLOGGER_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
19#include <qtqmlcompilerexports.h>
20
21#include "qcoloroutput_p.h"
23
24#include <private/qqmljsdiagnosticmessage_p.h>
25
26#include <QtCore/qhash.h>
27#include <QtCore/qmap.h>
28#include <QtCore/qstring.h>
29#include <QtCore/qlist.h>
30#include <QtCore/qset.h>
31#include <QtCore/QLoggingCategory>
32
33#include <optional>
34
36
37/*!
38 \internal
39 Used to print the line containing the location of a certain error
40 */
41class Q_QMLCOMPILER_EXPORT IssueLocationWithContext
42{
43public:
44 /*!
45 \internal
46 \param code: The whole text of a translation unit
47 \param location: The location where an error occurred.
48 */
49 IssueLocationWithContext(QStringView code, const QQmlJS::SourceLocation &location) {
50 quint32 before = qMax(0, code.lastIndexOf(QLatin1Char('\n'), location.offset));
51
52 if (before != 0 && before < location.offset)
53 before++;
54
55 m_beforeText = code.mid(before, location.offset - before);
56 m_issueText = code.mid(location.offset, location.length);
57 int after = code.indexOf(QLatin1Char('\n'), location.offset + location.length);
58 m_afterText = code.mid(location.offset + location.length,
59 after - (location.offset+location.length));
60 }
61
62 // returns start of the line till first character of location
63 QStringView beforeText() const { return m_beforeText; }
64 // returns the text at location
65 QStringView issueText() const { return m_issueText; }
66 // returns any text after location until the end of the line is reached
67 QStringView afterText() const { return m_afterText; }
68
69private:
70 QStringView m_beforeText;
71 QStringView m_issueText;
72 QStringView m_afterText;
73};
74
75class Q_QMLCOMPILER_EXPORT QQmlJSFixSuggestion
76{
77public:
78 QQmlJSFixSuggestion() = default;
79 QQmlJSFixSuggestion(const QString &fixDescription, const QQmlJS::SourceLocation &location,
80 const QString &replacement = QString());
81
82 QString fixDescription() const { return m_fixDescription; }
83 QQmlJS::SourceLocation location() const { return m_location; }
84 QString replacement() const { return m_replacement; }
85
86 void setFilename(const QString &filename) { m_filename = filename; }
87 QString filename() const { return m_filename; }
88
89 void setHint(const QString &hint) { m_hint = hint; }
90 QString hint() const { return m_hint; }
91
92 void setAutoApplicable(bool autoApply = true) { m_autoApplicable = autoApply; }
93 bool isAutoApplicable() const { return m_autoApplicable; }
94
95 bool operator==(const QQmlJSFixSuggestion &) const;
96 bool operator!=(const QQmlJSFixSuggestion &) const;
97
98private:
99 QQmlJS::SourceLocation m_location;
100 QString m_fixDescription;
101 QString m_replacement;
102 QString m_filename;
103 QString m_hint;
104 bool m_autoApplicable = false;
105};
106
107struct Message : public QQmlJS::DiagnosticMessage
108{
110
111 // This doesn't need to be an owning-reference since the string is expected to outlive any
112 // Message object by virtue of coming from a LoggerWarningId.
117
118 quint32 lineForDisabling() const { return customLineForDisabling.value_or(loc.startLine); }
119};
120
121class Q_QMLCOMPILER_EXPORT QQmlJSLogger
122{
123 Q_DISABLE_COPY_MOVE(QQmlJSLogger)
124public:
125 QList<QQmlJS::LoggerCategory> categories() const;
127
128 void registerCategory(const QQmlJS::LoggerCategory &category);
129
130 QQmlJSLogger();
131 ~QQmlJSLogger() = default;
132
133 bool hasWarnings() const { return m_numWarnings > 0; }
134 bool hasErrors() const { return m_numErrors > 0; }
135
136 qsizetype numWarnings() const { return m_numWarnings; }
137 qsizetype numErrors() const { return m_numErrors; }
138
139 template<typename F>
141 {
142 for (const Message &msg : m_currentFunctionMessages)
143 f(msg);
144 }
145
146 template<typename F>
147 void iterateAllMessages(F &&f) const
148 {
149 for (const Message &msg : m_archivedMessages)
150 f(msg);
151
152 for (const Message &msg : m_currentFunctionMessages)
153 f(msg);
154 }
155
156 QtMsgType categoryLevel(QQmlJS::LoggerWarningId id) const
157 {
158 return m_categoryLevels[id.name().toString()];
159 }
160 void setCategoryLevel(QQmlJS::LoggerWarningId id, QtMsgType level)
161 {
162 m_categoryLevels[id.name().toString()] = level;
163 m_categoryChanged[id.name().toString()] = true;
164 }
165
166 bool isCategoryIgnored(QQmlJS::LoggerWarningId id) const
167 {
168 return m_categoryIgnored[id.name().toString()];
169 }
170 void setCategoryIgnored(QQmlJS::LoggerWarningId id, bool error)
171 {
172 m_categoryIgnored[id.name().toString()] = error;
173 m_categoryChanged[id.name().toString()] = true;
174 }
175
176 bool isCategoryFatal(QQmlJS::LoggerWarningId id) const
177 {
178 return m_categoryFatal[id.name().toString()];
179 }
180 void setCategoryFatal(QQmlJS::LoggerWarningId id, bool error)
181 {
182 m_categoryFatal[id.name().toString()] = error;
183 m_categoryChanged[id.name().toString()] = true;
184 }
185
186 bool wasCategoryChanged(QQmlJS::LoggerWarningId id) const
187 {
188 return m_categoryChanged[id.name().toString()];
189 }
190
191 QtMsgType compileErrorLevel() const { return m_compileErrorLevel; }
192 void setCompileErrorLevel(QtMsgType level) { m_compileErrorLevel = level; }
193
194 QString compileErrorPrefix() const { return m_compileErrorPrefix; }
195 void setCompileErrorPrefix(const QString &prefix) { m_compileErrorPrefix = prefix; }
196
197 QString compileSkipPrefix() const { return m_compileSkipPrefix; }
198 void setCompileSkipPrefix(const QString &prefix) { m_compileSkipPrefix = prefix; }
199
200 /*! \internal
201
202 Logs \a message with severity deduced from \a category. Prefer using
203 this function in most cases.
204
205 \sa setCategoryLevel
206 */
207 void log(const QString &message, QQmlJS::LoggerWarningId id,
208 const QQmlJS::SourceLocation &srcLocation, bool showContext = true,
209 bool showFileName = true, const std::optional<QQmlJSFixSuggestion> &suggestion = {},
210 const QString overrideFileName = QString(),
211 std::optional<quint32> customLineForDisabling = std::nullopt)
212 {
213 log(Message {
214 QQmlJS::DiagnosticMessage {
215 message,
216 m_categoryLevels[id.name().toString()],
217 srcLocation,
218 },
219 id.name(),
220 suggestion,
221 Message::CompilationStatus::Normal,
222 customLineForDisabling
223 }, showContext, showFileName, overrideFileName);
224 }
225
226 void logCompileError(const QString &message, const QQmlJS::SourceLocation &srcLocation)
227 {
228 if (m_inTransaction)
229 m_hasPendingCompileError = true;
230 else
231 m_hasCompileError = true;
232
233 log(Message {
234 QQmlJS::DiagnosticMessage {
235 m_compileErrorPrefix + message,
236 m_compileErrorLevel,
237 srcLocation
238 },
239 qmlCompiler.name(),
240 {}, // fixSuggestion
241 Message::CompilationStatus::Error
242 });
243
244 }
245
246 void logCompileSkip(const QString &message, const QQmlJS::SourceLocation &srcLocation)
247 {
248 m_hasCompileSkip = true;
249 log(Message {
250 QQmlJS::DiagnosticMessage {
251 m_compileSkipPrefix + message,
252 m_compileSkipLevel,
253 srcLocation
254 },
255 qmlCompiler.name(),
256 {}, // fixSuggestion
257 Message::CompilationStatus::Skip
258 });
259 }
260
261 void processMessages(const QList<QQmlJS::DiagnosticMessage> &messages,
262 const QQmlJS::LoggerWarningId id,
263 const QQmlJS::SourceLocation &sourceLocation = QQmlJS::SourceLocation{});
264
265 void ignoreWarnings(uint32_t line, const QSet<QString> &categories)
266 {
267 m_ignoredWarnings[line] = categories;
268 }
269
270 void setSilent(bool silent) { m_output.setSilent(silent); }
271 bool isSilent() const { return m_output.isSilent(); }
272
273 /*!
274 \internal
275 The logger is disabled when warnings are not relevant, for example when the import visitor runs
276 on a dependency of a linted file. In that case, the warnings should not be created, and
277 expensive QQmlJSUtils::didYouMean call can be saved.
278
279 setSilent() has a different behavior: a silent logger can still be used to process messages as
280 JSON, for example, while a disabled logger won't contain any message.
281 */
282 void setIsDisabled(bool isDisabled) { m_isDisabled = isDisabled; }
283 bool isDisabled() const { return m_isDisabled; }
284
285 void setCode(const QString &code) { m_code = code; }
286 QString code() const { return m_code; }
287
288 void setFilePath(const QString &filePath) { m_filePath = filePath; }
289 QString filePath() const { return m_filePath; }
290
292 {
293 return m_hasCompileError || m_hasPendingCompileError;
294 }
295
297 {
298 return m_hasCompileSkip;
299 }
300
305
307 {
308 for (const Message &message : m_currentFunctionMessages) {
309 if (message.compilationStatus == Message::CompilationStatus::Error)
310 return message.message;
311 }
312
313 return QString();
314 }
315
317 {
318 for (const Message &message : m_currentFunctionMessages) {
319 if (message.compilationStatus == Message::CompilationStatus::Skip)
320 return message.message;
321 }
322
323 return QString();
324 }
325
326 void startTransaction();
327 void commit();
328 void rollback();
329
330 void finalizeFuction();
331
332private:
333 QMap<QString, QQmlJS::LoggerCategory> m_categories;
334
335 void printContext(const QString &overrideFileName, const QQmlJS::SourceLocation &location);
336 void printFix(const QQmlJSFixSuggestion &fix);
337
338 void log(Message diagMsg, bool showContext = false, bool showFileName = true,
339 const QString overrideFileName = QString());
340
341 void countMessage(const Message &message);
342
343 QString m_filePath;
344 QString m_code;
345
346 QColorOutput m_output;
347
348 QHash<QString, QtMsgType> m_categoryLevels;
349 QHash<QString, bool> m_categoryIgnored;
350
351 // If true, triggers qFatal on documents with "pragma Strict"
352 // TODO: Works only for qmlCompiler category so far.
353 QHash<QString, bool> m_categoryFatal;
354
355 QHash<QString, bool> m_categoryChanged;
356
357 QList<Message> m_pendingMessages;
358 QList<Message> m_currentFunctionMessages;
359 QList<Message> m_archivedMessages;
360 QHash<uint32_t, QSet<QString>> m_ignoredWarnings;
361
362 QString m_compileErrorPrefix;
363 QString m_compileSkipPrefix;
364
365 qsizetype m_numWarnings = 0;
366 qsizetype m_numErrors = 0;
367 bool m_inTransaction = false;
368 bool m_hasCompileError = false;
369 bool m_hasPendingCompileError = false;
370 bool m_hasCompileSkip = false;
371 bool m_isDisabled = false;
372
373 QtMsgType m_compileErrorLevel = QtWarningMsg;
374 QtMsgType m_compileSkipLevel = QtInfoMsg;
375};
376
377QT_END_NAMESPACE
378
379#endif // QQMLJSLOGGER_P_H
[custom type definition]
std::optional< QQmlJSFixSuggestion > fixSuggestion
CompilationStatus compilationStatus
quint32 lineForDisabling() const
QAnyStringView id
std::optional< quint32 > customLineForDisabling
friend bool operator==(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept
Returns true if lhs and rhs are equal, otherwise returns false.
Definition qbytearray.h:801
friend bool operator!=(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept
Returns true if lhs and rhs are different, otherwise returns false.
Definition qbytearray.h:812
bool isValid() const
QString fileName() const
If the currently assigned device is a QFile, or if setFileName() has been called, this function retur...
void setFileName(const QString &fileName)
Sets the file name of QImageReader to fileName.
virtual Type type() const =0
Reimplement this function to return the paint engine \l{Type}.
virtual bool isValid() const
virtual QString location() const
bool isDisabled() const
void setCategoryFatal(QQmlJS::LoggerWarningId id, bool error)
QString code() const
void logCompileSkip(const QString &message, const QQmlJS::SourceLocation &srcLocation)
bool currentFunctionWasSkipped() const
bool isSilent() const
void finalizeFuction()
QString compileSkipPrefix() const
qsizetype numErrors() const
bool isCategoryIgnored(QQmlJS::LoggerWarningId id) const
void setCode(const QString &code)
bool currentFunctionHasErrorOrSkip() const
void setFilePath(const QString &filePath)
bool currentFunctionHasCompileError() const
bool hasWarnings() const
void logCompileError(const QString &message, const QQmlJS::SourceLocation &srcLocation)
void setSilent(bool silent)
void setCompileErrorLevel(QtMsgType level)
bool wasCategoryChanged(QQmlJS::LoggerWarningId id) const
void startTransaction()
void setCategoryIgnored(QQmlJS::LoggerWarningId id, bool error)
QString currentFunctionCompileErrorMessage() const
void processMessages(const QList< QQmlJS::DiagnosticMessage > &messages, const QQmlJS::LoggerWarningId id, const QQmlJS::SourceLocation &sourceLocation=QQmlJS::SourceLocation{})
bool isCategoryFatal(QQmlJS::LoggerWarningId id) const
void iterateCurrentFunctionMessages(F &&f) const
QString compileErrorPrefix() const
void setCategoryLevel(QQmlJS::LoggerWarningId id, QtMsgType level)
QtMsgType compileErrorLevel() const
void log(const QString &message, QQmlJS::LoggerWarningId id, const QQmlJS::SourceLocation &srcLocation, bool showContext=true, bool showFileName=true, const std::optional< QQmlJSFixSuggestion > &suggestion={}, const QString overrideFileName=QString(), std::optional< quint32 > customLineForDisabling=std::nullopt)
void iterateAllMessages(F &&f) const
qsizetype numWarnings() const
static const QList< QQmlJS::LoggerCategory > & defaultCategories()
void setIsDisabled(bool isDisabled)
void setCompileErrorPrefix(const QString &prefix)
QString currentFunctionCompileSkipMessage() const
QtMsgType categoryLevel(QQmlJS::LoggerWarningId id) const
QString filePath() const
bool hasErrors() const
void setCompileSkipPrefix(const QString &prefix)
void registerCategory(const QQmlJS::LoggerCategory &category)
void ignoreWarnings(uint32_t line, const QSet< QString > &categories)
QString typeName() const
void setIsFlag(bool isFlag)
void setLineNumber(int lineNumber)
friend bool operator!=(const QQmlJSMetaEnum &a, const QQmlJSMetaEnum &b)
void setName(const QString &name)
QQmlJSMetaEnum()=default
int lineNumber() const
friend size_t qHash(const QQmlJSMetaEnum &e, size_t seed=0)
friend bool operator==(const QQmlJSMetaEnum &a, const QQmlJSMetaEnum &b)
void setTypeName(const QString &typeName)
bool hasKey(const QString &key) const
void setIsScoped(bool v)
void setType(const QSharedPointer< const QQmlJSScope > &type)
QSharedPointer< const QQmlJSScope > type() const
int value(const QString &key) const
bool isQml() const
void setIsQml(bool v)
void addValue(int value)
bool isScoped() const
QList< int > values() const
bool isFlag() const
QString alias() const
QStringList keys() const
bool isValid() const
void addKey(const QString &key)
void setAlias(const QString &alias)
QString name() const
QQmlJSMetaEnum(QString name)
bool hasValues() const
QQmlJSMetaReturnType returnValue() const
QQmlJSMetaMethod()=default
void setReturnType(QWeakPointer< const QQmlJSScope > type)
void setSourceLocation(QQmlJS::SourceLocation location)
QQmlJS::SourceLocation sourceLocation() const
QString methodName() const
QQmlJSMetaMethodType MethodType
void setMethodName(const QString &name)
void setReturnTypeName(const QString &typeName)
QString returnTypeName() const
QQmlJSMetaMethod(QString name, QString returnType=QString())
QList< QQmlJSMetaParameter > parameters() const
void setReturnValue(const QQmlJSMetaReturnType returnValue)
QSharedPointer< const QQmlJSScope > returnType() const
void setIsPointer(bool isPointer)
void setType(QWeakPointer< const QQmlJSScope > type)
void setIsList(bool isList)
friend bool operator!=(const QQmlJSMetaParameter &a, const QQmlJSMetaParameter &b)
friend size_t qHash(const QQmlJSMetaParameter &e, size_t seed=0)
void setName(const QString &name)
void setTypeName(const QString &typeName)
void setTypeQualifier(Constness typeQualifier)
Constness typeQualifier() const
QString typeName() const
QQmlJSMetaParameter(QString name=QString(), QString typeName=QString(), Constness typeQualifier=NonConst, QWeakPointer< const QQmlJSScope > type={})
friend bool operator==(const QQmlJSMetaParameter &a, const QQmlJSMetaParameter &b)
QSharedPointer< const QQmlJSScope > type() const
friend bool operator!=(const QQmlJSMetaProperty &a, const QQmlJSMetaProperty &b)
QString notify() const
QSharedPointer< const QQmlJSScope > aliasTargetScope() const
QString aliasExpression() const
friend bool operator==(const QQmlJSMetaProperty &a, const QQmlJSMetaProperty &b)
void setPropertyName(const QString &propertyName)
QString aliasTargetName() const
void setAnnotations(const QList< QQmlJSAnnotation > &annotation)
void setIsList(bool isList)
QString bindable() const
QSharedPointer< const QQmlJSScope > type() const
void setPrivateClass(const QString &privateClass)
void setRead(const QString &read)
friend size_t qHash(const QQmlJSMetaProperty &prop, size_t seed=0)
void setBindable(const QString &bindable)
void setWrite(const QString &write)
void setIsPropertyConstant(bool isPropertyConstant)
QString reset() const
void setRevision(int revision)
void setIsFinal(bool isFinal)
QString typeName() const
void setAliasTargetScope(const QSharedPointer< const QQmlJSScope > &scope)
void setSourceLocation(const QQmlJS::SourceLocation &newSourceLocation)
QString write() const
void setIsTypeConstant(bool isTypeConstant)
const QList< QQmlJSAnnotation > & annotations() const
QQmlJS::SourceLocation sourceLocation() const
void setTypeName(const QString &typeName)
QQmlJSMetaProperty()=default
void setReset(const QString &reset)
QString privateClass() const
void setIsWritable(bool isWritable)
void setAliasExpression(const QString &aliasString)
void setAliasTargetName(const QString &name)
void setIndex(int index)
void setNotify(const QString &notify)
bool isPropertyConstant() const
bool isTypeConstant() const
void setType(const QSharedPointer< const QQmlJSScope > &type)
QString propertyName() const
void setIsPointer(bool isPointer)
QQmlJSRegisterContent createMethod(const QList< QQmlJSMetaMethod > &methods, const QQmlJSScope::ConstPtr &methodType, ContentVariant variant, QQmlJSRegisterContent scope)
QQmlJSRegisterContent createImportNamespace(uint importNamespaceStringId, const QQmlJSScope::ConstPtr &importNamespaceType, ContentVariant variant, QQmlJSRegisterContent scope)
QQmlJSRegisterContent createProperty(const QQmlJSMetaProperty &property, int baseLookupIndex, int resultLookupIndex, ContentVariant variant, QQmlJSRegisterContent scope)
void adjustType(QQmlJSRegisterContent content, const QQmlJSScope::ConstPtr &adjusted)
void generalizeType(QQmlJSRegisterContent content, const QQmlJSScope::ConstPtr &generalized)
void storeType(QQmlJSRegisterContent content, const QQmlJSScope::ConstPtr &stored)
QQmlJSRegisterContent castTo(QQmlJSRegisterContent content, const QQmlJSScope::ConstPtr &newContainedType)
QQmlJSRegisterContent createEnumeration(const QQmlJSMetaEnum &enumeration, const QString &enumMember, ContentVariant variant, QQmlJSRegisterContent scope)
void setAllocationMode(AllocationMode mode)
QQmlJSRegisterContent storedIn(QQmlJSRegisterContent content, const QQmlJSScope::ConstPtr &newStoredType)
QQmlJSRegisterContent clone(QQmlJSRegisterContent from)
QQmlJSRegisterContent createType(const QQmlJSScope::ConstPtr &type, int resultLookupIndex, ContentVariant variant, QQmlJSRegisterContent scope={})
QQmlJSRegisterContent createConversion(const QList< QQmlJSRegisterContent > &origins, const QQmlJSScope::ConstPtr &conversion, QQmlJSRegisterContent conversionScope, ContentVariant variant, QQmlJSRegisterContent scope)
QQmlJSRegisterContent createMethodCall(const QQmlJSMetaMethod &method, const QQmlJSScope::ConstPtr &returnType, QQmlJSRegisterContent scope)
Tracks the types for the QmlCompiler.
QTypeRevision revision() const
QString type() const
QTypeRevision version() const
bool isValid() const
QString package() const
Export()=default
Export(QString package, QString type, QTypeRevision version, QTypeRevision revision)
virtual QQmlSourceLocation sourceLocation() const
static BindingPrivate * get(Binding *binding)
Definition qqmlsa_p.h:89
static QQmlJSMetaPropertyBinding binding(QQmlSA::Binding &binding)
Definition qqmlsa.cpp:320
Element bindingScope() const
Definition qqmlsa_p.h:98
void setPropertyName(QString name)
Definition qqmlsa_p.h:96
static QQmlSA::Binding createBinding(const QQmlJSMetaPropertyBinding &)
Definition qqmlsa.cpp:313
static const QQmlJSMetaPropertyBinding binding(const QQmlSA::Binding &binding)
Definition qqmlsa.cpp:325
bool isAttached() const
Definition qqmlsa_p.h:101
void setIsAttached(bool isAttached)
Definition qqmlsa_p.h:102
BindingPrivate(Binding *, const BindingPrivate &)
Definition qqmlsa.cpp:307
void setBindingScope(Element bindingScope)
Definition qqmlsa_p.h:99
static const BindingPrivate * get(const Binding *binding)
Definition qqmlsa_p.h:90
\inmodule QtQmlCompiler
Definition qqmlsa.h:52
Element attachedType() const
Returns the attached type if the content type of this binding is AttachedProperty,...
Definition qqmlsa.cpp:384
BindingType bindingType() const
Returns the type of this binding.
Definition qqmlsa.cpp:350
Element bindingScope() const
Returns the Element scope in which the binding is defined.
Definition qqmlsa.cpp:342
friend bool operator!=(const Binding &lhs, const Binding &rhs)
Returns true if lhs and rhs are not equal, and false otherwise.
Definition qqmlsa.h:106
bool hasUndefinedScriptValue() const
Returns whether this binding has script value type undefined like when it is assigned undefined.
Definition qqmlsa.cpp:451
Binding(const Binding &)
Creates a copy of other.
Definition qqmlsa.cpp:254
Binding & operator=(const Binding &)
Assigns other to this Binding instance.
Definition qqmlsa.cpp:266
bool isAttached() const
Returns true if this type is attached to another one, false otherwise.
Definition qqmlsa.cpp:375
bool hasObject() const
Returns true if this binding has an objects, otherwise returns false.
Definition qqmlsa.cpp:432
friend bool operator==(const Binding &lhs, const Binding &rhs)
Returns true if lhs and rhs are equal, and false otherwise.
Definition qqmlsa.h:102
static bool isLiteralBinding(BindingType)
Returns true if bindingType is a literal type, and false otherwise.
Definition qqmlsa.cpp:475
QString propertyName() const
Returns the name of the property bound with this binding.
Definition qqmlsa.cpp:367
Binding()
Constructs a new Binding object.
Definition qqmlsa.cpp:247
QString stringValue() const
Returns the associated string literal if the content type of this binding is StringLiteral,...
Definition qqmlsa.cpp:359
Element objectType() const
Returns the type of the associated object if the content type of this binding is Object,...
Definition qqmlsa.cpp:441
Binding & operator=(Binding &&) noexcept
Move-assigns other to this Binding instance.
Definition qqmlsa.cpp:282
QQmlSA::SourceLocation sourceLocation() const
Returns the location in the QML code where this binding is defined.
Definition qqmlsa.cpp:405
ScriptBindingKind scriptKind() const
Returns the kind of the associated script if the content type of this binding is Script,...
Definition qqmlsa.cpp:424
double numberValue() const
Returns the associated number if the content type of this binding is NumberLiteral,...
Definition qqmlsa.cpp:415
Element groupType() const
Returns the type of the property of this binding if it is a group property, otherwise returns an inva...
Definition qqmlsa.cpp:334
bool hasFunctionScriptValue() const
Returns whether this binding has script value type function like when it is assigned a (lambda) metho...
Definition qqmlsa.cpp:464
QMultiHash< QString, Binding >::const_iterator constBegin() const
Definition qqmlsa.cpp:213
BindingsPrivate(QQmlSA::Binding::Bindings *, const BindingsPrivate &)
Definition qqmlsa.cpp:189
friend class QT_PREPEND_NAMESPACE(QQmlJSMetaPropertyBinding)
QMultiHash< QString, Binding >::const_iterator constEnd() const
Definition qqmlsa.cpp:232
\inmodule QtQmlCompiler
Definition qqmlsa.h:368
\inmodule QtQmlCompiler
Definition qqmlsa.h:202
QQmlSA::SourceLocation location() const
Definition qqmlsa.cpp:2037
FixSuggestionPrivate(FixSuggestion *, const QString &fixDescription, const QQmlSA::SourceLocation &location, const QString &replacement)
Definition qqmlsa.cpp:2012
void setHint(const QString &)
Definition qqmlsa.cpp:2057
void setFileName(const QString &)
Definition qqmlsa.cpp:2047
QString fixDescription() const
Definition qqmlsa.cpp:2032
FixSuggestionPrivate(FixSuggestion *)
Definition qqmlsa.cpp:2010
void setAutoApplicable(bool autoApplicable=true)
Definition qqmlsa.cpp:2067
static const QQmlJSFixSuggestion & fixSuggestion(const QQmlSA::FixSuggestion &)
Definition qqmlsa.cpp:2082
FixSuggestionPrivate(FixSuggestion *, FixSuggestionPrivate &&)
Definition qqmlsa.cpp:2027
QString replacement() const
Definition qqmlsa.cpp:2042
static QQmlJSFixSuggestion & fixSuggestion(QQmlSA::FixSuggestion &)
Definition qqmlsa.cpp:2077
FixSuggestionPrivate(FixSuggestion *, const FixSuggestionPrivate &)
Definition qqmlsa.cpp:2021
\inmodule QtQmlCompiler
Definition qqmlsa.h:397
void setHint(const QString &)
Sets hint as the hint for this fix suggestion.
Definition qqmlsa.cpp:2193
FixSuggestion(const FixSuggestion &)
Creates a copy of other.
Definition qqmlsa.cpp:2107
QString hint() const
Returns the hint for this fix suggestion.
Definition qqmlsa.cpp:2201
QString replacement() const
Returns the fix that will replace the problematic source code.
Definition qqmlsa.cpp:2169
QString fixDescription() const
Returns the description of the fix.
Definition qqmlsa.cpp:2152
bool isAutoApplicable() const
Returns whether this suggested fix can be applied automatically.
Definition qqmlsa.cpp:2218
void setAutoApplicable(bool autoApplicable=true)
Sets autoApplicable to determine whether this suggested fix can be applied automatically.
Definition qqmlsa.cpp:2210
\inmodule QtQmlCompiler
Definition qqmlsa.h:283
void emitWarning(QAnyStringView diagnostic, LoggerWarningId id)
Emits a warning message diagnostic about an issue of type id.
Definition qqmlsa.cpp:1264
Element resolveLiteralType(const Binding &binding)
Returns the element representing the type of literal in binding.
Definition qqmlsa.cpp:1376
void emitWarning(QAnyStringView diagnostic, LoggerWarningId id, QQmlSA::SourceLocation srcLocation, const QQmlSA::FixSuggestion &fix)
Emits a warning message diagnostic about an issue of type id located at srcLocation and with suggeste...
Definition qqmlsa.cpp:1287
void emitWarning(QAnyStringView diagnostic, LoggerWarningId id, QQmlSA::SourceLocation srcLocation)
Emits warning message diagnostic about an issue of type id located at srcLocation.
Definition qqmlsa.cpp:1273
Element resolveBuiltinType(QAnyStringView typeName) const
Returns the type of the built-in type identified by typeName.
Definition qqmlsa.cpp:1348
Element resolveAttached(QAnyStringView moduleName, QAnyStringView typeName)
Returns the attached type of typeName defined in module moduleName.
Definition qqmlsa.cpp:1366
QString resolveElementToId(const Element &element, const Element &context)
Returns the id of element in a given context.
Definition qqmlsa.cpp:1399
Element resolveTypeInFileScope(QAnyStringView typeName)
Returns the type corresponding to typeName inside the currently analysed file.
Definition qqmlsa.cpp:1302
QString sourceCode(QQmlSA::SourceLocation location)
Returns the source code located within location.
Definition qqmlsa.cpp:1411
Element resolveAttachedInFileScope(QAnyStringView typeName)
Returns the attached type corresponding to typeName used inside the currently analysed file.
Definition qqmlsa.cpp:1314
Element resolveIdToElement(QAnyStringView id, const Element &context)
Returns the element in context that has id id.
Definition qqmlsa.cpp:1387
Element resolveType(QAnyStringView moduleName, QAnyStringView typeName)
Returns the type of typeName defined in module moduleName.
Definition qqmlsa.cpp:1332
\inmodule QtQmlCompiler
Definition qqmlsa.h:340
MethodPrivate(Method *, const MethodPrivate &)
Definition qqmlsa.cpp:563
QQmlSA::SourceLocation sourceLocation() const
Definition qqmlsa.cpp:573
static QQmlSA::Method createMethod(const QQmlJSMetaMethod &)
Definition qqmlsa.cpp:680
MethodType methodType() const
Definition qqmlsa.cpp:578
static QQmlJSMetaMethod method(const QQmlSA::Method &)
Definition qqmlsa.cpp:701
QString methodName() const
Definition qqmlsa.cpp:568
\inmodule QtQmlCompiler
Definition qqmlsa.h:120
Method & operator=(Method &&) noexcept
Move-assigns other to this Method instance.
Definition qqmlsa.cpp:624
MethodType methodType() const
Returns the type of this method.
Definition qqmlsa.cpp:651
Method(const Method &)
Creates a copy of other.
Definition qqmlsa.cpp:598
Method()
Constructs a new Method object.
Definition qqmlsa.cpp:593
Method & operator=(const Method &)
Assigns other to this Method instance.
Definition qqmlsa.cpp:611
QString methodName() const
Returns the name of the this method.
Definition qqmlsa.cpp:642
MethodsPrivate(QQmlSA::Method::Methods *, MethodsPrivate &&)
Definition qqmlsa.cpp:556
static QQmlSA::Method::Methods createMethods(const QMultiHash< QString, QQmlJSMetaMethod > &)
Definition qqmlsa.cpp:689
QMultiHash< QString, Method >::const_iterator constEnd() const
Definition qqmlsa.cpp:544
MethodsPrivate(QQmlSA::Method::Methods *, const MethodsPrivate &)
Definition qqmlsa.cpp:551
QMultiHash< QString, Method >::const_iterator constBegin() const
Definition qqmlsa.cpp:525
\inmodule QtQmlCompiler
Definition qqmlsa.h:314
void analyze(const Element &root)
Runs the element passes over root and all its children.
Definition qqmlsa.cpp:1600
bool isCategoryEnabled(LoggerWarningId category) const
Returns true if warnings of category are enabled, false otherwise.
Definition qqmlsa.cpp:1711
bool registerPropertyPass(std::shared_ptr< PropertyPass > pass, QAnyStringView moduleName, QAnyStringView typeName, QAnyStringView propertyName=QAnyStringView(), bool allowInheritance=true)
Registers a static analysis pass for properties.
Definition qqmlsa.cpp:1503
std::unordered_map< quint32, Binding > bindingsByLocation() const
Returns bindings by their source location.
Definition qqmlsa.cpp:2004
bool hasImportedModule(QAnyStringView name) const
Returns true if the module named module has been imported by the QML to be analyzed,...
Definition qqmlsa.cpp:1703
PropertyPassBuilder(PassManager *passManager)
Definition qqmlsa_p.h:339
\inmodule QtQmlCompiler
Definition qqmlsa.h:351
static QQmlSA::Property createProperty(const QQmlJSMetaProperty &)
Definition qqmlsa.cpp:751
PropertyPrivate(Property *, const PropertyPrivate &)
Definition qqmlsa.cpp:708
PropertyPrivate(Property *, PropertyPrivate &&)
Definition qqmlsa.cpp:713
static QQmlJSMetaProperty property(const QQmlSA::Property &property)
Definition qqmlsa.cpp:746
QQmlSA::Element type() const
Returns the type that this property was defined with.
Definition qqmlsa.cpp:741
bool isValid() const
Definition qqmlsa.cpp:723
QString typeName() const
Definition qqmlsa.cpp:718
bool isReadonly() const
Returns whether this property is readonly.
Definition qqmlsa.cpp:733
\inmodule QtQmlCompiler
Definition qqmlsa.h:169
Property(const Property &)
Creates a copy of other.
Definition qqmlsa.cpp:774
QString typeName() const
Returns the name of the type of this property.
Definition qqmlsa.cpp:819
bool isReadonly() const
Returns true if this property is read-only, false otherwise.
Definition qqmlsa.cpp:837
\inmodule QtQmlCompiler
MethodType
Definition qqmlsa.h:48
Q_QMLCOMPILER_EXPORT void emitWarningWithOptionalFix(GenericPass &pass, QAnyStringView diagnostic, const LoggerWarningId &id, const QQmlSA::SourceLocation &srcLocation, const std::optional< QQmlJSFixSuggestion > &fix)
Definition qqmlsa.cpp:2237
bool isRegularBindingType(BindingType type)
Definition qqmlsa.cpp:2253
constexpr bool isFunctionScope(ScopeType type)
AccessSemantics
Definition qqmlsa.h:49
@ HasBaseTypeError
Definition qqmlsa_p.h:43
@ InlineComponent
Definition qqmlsa_p.h:41
@ HasExtensionNamespace
Definition qqmlsa_p.h:44
@ WrappedInImplicitComponent
Definition qqmlsa_p.h:42
static auto getQQmlJSScopeFromSmartPtr(const From &p) -> From
Q_DECLARE_INTERFACE(QNetworkAccessBackendFactory, QNetworkAccessBackendFactory_iid)
Q_DECLARE_TYPEINFO(QObjectPrivate::ConnectionList, Q_RELOCATABLE_TYPE)
static QString toNumericString(double value)
static QString messageTypeForMethod(const QString &method)
static QString derefContentPointer(const QString &contentPointer)
#define BYTECODE_UNIMPLEMENTED()
#define INJECT_TRACE_INFO(function)
#define REJECT
static QString registerName(int registerIndex, int offset)
static QString minExpression(int argc)
static QString maxExpression(int argc)
static bool isTypeStorable(const QQmlJSTypeResolver *resolver, const QQmlJSScope::ConstPtr &type)
QQmlSA::MethodType QQmlJSMetaMethodType
QQmlJSMetaParameter QQmlJSMetaReturnType
ScriptBindingValueType
@ ScriptValue_Function
@ ScriptValue_Unknown
@ ScriptValue_Undefined
#define QmlLintPluginInterface_iid
Definition qqmlsa.h:440
QList< Export > exports
QTypeRevision revision
static void onWriteDefault(PropertyPass *, const Element &, const QString &, const Element &, const Element &, SourceLocation)
Definition qqmlsa_p.h:299
static void onBindingDefault(PropertyPass *, const Element &, const QString &, const Binding &, const Element &, const Element &)
Definition qqmlsa_p.h:287
void onRead(const Element &element, const QString &propertyName, const Element &readScope, SourceLocation location) override
Executes whenever a property is read.
Definition qqmlsa_p.h:314
static void onCallDefault(PropertyPass *, const Element &, const QString &, const Element &, SourceLocation)
Definition qqmlsa_p.h:295
void onBinding(const Element &element, const QString &propertyName, const Binding &binding, const Element &bindingScope, const Element &value) override
Executes whenever a property gets bound to a value.
Definition qqmlsa_p.h:309
void onCall(const Element &element, const QString &propertyName, const Element &readScope, SourceLocation location) override
Executes whenever a property or method is called.
Definition qqmlsa_p.h:319
static void onReadDefault(PropertyPass *, const Element &, const QString &, const Element &, SourceLocation)
Definition qqmlsa_p.h:291
void onWrite(const Element &element, const QString &propertyName, const Element &value, const Element &writeScope, SourceLocation location) override
Executes whenever a property is written to.
Definition qqmlsa_p.h:324
std::shared_ptr< QQmlSA::PropertyPass > pass
Definition qqmlsa_p.h:51