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
qqmljscontextproperties_p.h
Go to the documentation of this file.
1// Copyright (C) 2025 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 QQMLJSCONTEXTPROPERTIES_P_H
6#define QQMLJSCONTEXTPROPERTIES_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 <QtCore/qstring.h>
19#include <QtCore/qhash.h>
20#include <QtCore/qlist.h>
21#include <QtCore/private/qflatmap_p.h>
22
23#include <QtQml/private/qqmljssourcelocation_p.h>
24
25#include <QtQmlToolingSettings/private/qqmltoolingsettings_p.h>
26
27QT_BEGIN_NAMESPACE
28
29class QSettings;
30
31namespace QQmlJS {
32class LoggerCategory;
33
35{
38
40 const HeuristicContextProperty &b) noexcept
41 {
42 return a.filename == b.filename && a.location == b.location;
43 }
45};
46
48{
49public:
50 bool contains(const QString &name) const { return m_properties.contains(name); }
51 qsizetype size() const { return m_properties.size(); }
52 bool isValid() const { return !m_properties.isEmpty(); }
53 QList<HeuristicContextProperty> definitionsForName(const QString &name) const;
54 void writeCache(const QString &folder) const;
55
56 void add(const QString &name, const HeuristicContextProperty &property);
57
58 static HeuristicContextProperties collectFromCppSourceDirs(const QList<QString> &cppSourceDirs);
59 static HeuristicContextProperties collectFrom(QSettings *settings);
60
62 const HeuristicContextProperties &b) noexcept
63 {
64 return std::equal(a.m_properties.begin(), a.m_properties.end(), b.m_properties.begin(),
65 b.m_properties.end());
66 }
68
69private:
70 struct Entry
71 {
72 QString name;
73 QList<HeuristicContextProperty> definitions;
74
75 friend bool comparesEqual(const Entry &a, const Entry &b) noexcept
76 {
77 return a.name == b.name && a.definitions == b.definitions;
78 }
79 Q_DECLARE_EQUALITY_COMPARABLE(Entry);
80 };
81
82 void collectFromDirs(const QList<QString> &dirs);
83 void collectFromFile(const QString &file);
84 void grepFallback(const QList<QString> &rootUrls);
85#if QT_CONFIG(process) && !defined(Q_OS_WINDOWS)
86 void parseGrepOutput(const QString &output);
87#endif
88
90};
91
92} // namespace QQmlJS
93
94QT_END_NAMESPACE
95
96#endif // QQMLJSCONTEXTPROPERTIES_P_H
void add(const QString &name, const HeuristicContextProperty &property)
bool contains(const QString &name) const
static HeuristicContextProperties collectFromCppSourceDirs(const QList< QString > &cppSourceDirs)
friend bool comparesEqual(const HeuristicContextProperties &a, const HeuristicContextProperties &b) noexcept
static HeuristicContextProperties collectFrom(QSettings *settings)
void writeCache(const QString &folder) const
QList< HeuristicContextProperty > definitionsForName(const QString &name) const
static const QRegularExpression s_matchSetContextProperty
static constexpr auto cachedHeuristicListKey
static constexpr QLatin1StringView s_pattern
static constexpr int s_contextPropertyNameIdxInPattern
static constexpr std::array s_fileFilters
Combined button and popup list for selecting options.
friend bool comparesEqual(const HeuristicContextProperty &a, const HeuristicContextProperty &b) noexcept