6#include <QtCore/QtDebug>
43 _typeNamespace.
clear();
45 _dependencies.clear();
49 _designerSupported =
false;
66 while (!
ch->isSpace() && !
ch->isNull())
76 bool firstLine =
true;
78 auto readImport = [&](
const QString *sections,
int sectionCount, Import::Flags
flags) {
80 if (sectionCount == 2) {
82 }
else if (sectionCount == 3) {
87 if (version.isValid()) {
90 reportError(lineNumber, 0,
97 reportError(lineNumber, 0,
98 QStringLiteral(
"%1 requires 1 or 2 arguments, but %2 were provided")
99 .
arg(sections[0]).
arg(sectionCount - 1));
103 _imports.append(
import);
105 _dependencies.append(
import);
109 auto readPlugin = [&](
const QString *sections,
int sectionCount,
bool isOptional) {
110 if (sectionCount < 2 || sectionCount > 3) {
111 reportError(lineNumber, 0,
QStringLiteral(
"plugin directive requires one or two "
112 "arguments, but %1 were provided")
113 .
arg(sectionCount - 1));
117 const Plugin entry(sections[1], sections[2], isOptional);
118 _plugins.append(
entry);
123 while (!
ch->isNull()) {
126 bool invalidLine =
false;
138 int sectionCount = 0;
147 if (sectionCount < 4) {
162 reportError(lineNumber, 0,
163 QStringLiteral(
"invalid qmldir directive contains too many tokens"));
165 }
else if (sectionCount == 0) {
169 if (sectionCount != 2) {
170 reportError(lineNumber, 0,
171 QStringLiteral(
"module identifier directive requires one argument, but %1 were provided").
arg(sectionCount - 1));
174 if (!_typeNamespace.
isEmpty()) {
175 reportError(lineNumber, 0,
176 QStringLiteral(
"only one module identifier directive may be defined in a qmldir file"));
180 reportError(lineNumber, 0,
181 QStringLiteral(
"module identifier directive must be the first directive in a qmldir file"));
185 _typeNamespace = sections[1];
188 if (!readPlugin(sections, sectionCount,
false))
191 if (sectionCount < 2) {
192 reportError(lineNumber, 0,
QStringLiteral(
"optional directive requires further "
193 "arguments, but none were provided."));
198 if (!readPlugin(sections + 1, sectionCount - 1,
true))
204 reportError(lineNumber, 0,
QStringLiteral(
"only import and plugin can be optional, "
205 "not %1.").
arg(sections[1]));
209 if (sectionCount < 2) {
210 reportError(lineNumber, 0,
212 "arguments, but none were provided."));
216 if (!readImport(sections + 1, sectionCount - 1,
220 reportError(lineNumber, 0,
226 if (sectionCount < 2) {
227 reportError(lineNumber, 0,
228 QStringLiteral(
"classname directive requires an argument, but %1 were provided").
arg(sectionCount - 1));
233 _classNames.append(sections[1]);
236 if (sectionCount == 3) {
238 entry.internal =
true;
240 }
else if (sectionCount == 4) {
244 entry.internal =
true;
247 reportError(lineNumber, 0,
253 reportError(lineNumber, 0,
255 "but %1 were provided").
arg(sectionCount - 1));
259 if (sectionCount < 3 || sectionCount > 4) {
260 reportError(lineNumber, 0,
261 QStringLiteral(
"singleton types require 2 or 3 arguments, but %1 were provided").
arg(sectionCount - 1));
263 }
else if (sectionCount == 3) {
267 entry.singleton =
true;
276 entry.singleton =
true;
279 reportError(lineNumber, 0,
QStringLiteral(
"invalid version %1, expected <major>.<minor>").
arg(sections[2]));
283 if (sectionCount != 2) {
284 reportError(lineNumber, 0,
285 QStringLiteral(
"typeinfo requires 1 argument, but %1 were provided").
arg(sectionCount - 1));
288 _typeInfos.append(sections[1]);
289 }
else if (sections[0] ==
QLatin1String(
"designersupported")) {
290 if (sectionCount != 1)
291 reportError(lineNumber, 0,
QStringLiteral(
"designersupported does not expect any argument"));
293 _designerSupported =
true;
295 if (sectionCount != 1)
296 reportError(lineNumber, 0,
QStringLiteral(
"static does not expect any argument"));
298 _isStaticModule =
true;
300 if (sectionCount != 1)
301 reportError(lineNumber, 0,
QStringLiteral(
"system does not expect any argument"));
303 _isSystemModule =
true;
309 if (sectionCount < 2) {
310 reportError(lineNumber, 0,
312 "but %1 were provided").
arg(sectionCount - 1));
316 if (!_preferredPath.
isEmpty()) {
318 "only one prefer directive may be defined in a qmldir file"));
322 if (!sections[1].endsWith(u
'/')) {
325 "the preferred directory has to end with a '/'"));
329 _preferredPath = sections[1];
331 if (sectionCount < 2) {
332 reportError(lineNumber, 0,
334 "but %1 were provided")
335 .
arg(sectionCount - 1));
343 "only one linktarget directive may be defined in a qmldir file"));
347 _linkTarget = sections[1];
348 }
else if (sectionCount == 2) {
352 }
else if (sectionCount == 3) {
360 _scripts.append(
entry);
366 reportError(lineNumber, 0,
QStringLiteral(
"invalid version %1, expected <major>.<minor>").
arg(sections[1]));
369 reportError(lineNumber, 0,
370 QStringLiteral(
"a component declaration requires two or three arguments, but %1 were provided").
arg(sectionCount));
384 error.message = description;
391 reportError(
e.loc.startLine,
e.loc.startColumn,
e.message);
397 const int numErrors = _errors.
size();
399 for (
int i = 0;
i < numErrors; ++
i) {
constexpr bool isDigit() const noexcept
Returns true if the character is a decimal digit (Number_DecimalDigit); otherwise returns false.
constexpr char16_t unicode() const noexcept
Returns the numeric Unicode value of the QChar.
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
void append(parameter_type t)
void setError(const QQmlJS::DiagnosticMessage &)
QList< QQmlJS::DiagnosticMessage > errors(const QString &uri) const
bool parse(const QString &source)
url is used for generating errors.
\macro QT_RESTRICTED_CAST_FROM_ASCII
void clear()
Clears the contents of the string and makes it null.
qsizetype size() const
Returns the number of characters in this string.
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QString static QString qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static constexpr QTypeRevision fromVersion(Major majorVersion, Minor minorVersion)
Produces a QTypeRevision from the given majorVersion and minorVersion, both of which need to be a val...
constexpr quint8 minorVersion() const
Returns the minor version encoded in the revision.
constexpr bool isValid() const
Returns true if the major version or the minor version is known, otherwise false.
constexpr quint8 majorVersion() const
Returns the major version encoded in the revision.
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
GLsizei GLsizei GLchar * source
GLenum GLenum GLsizei void GLsizei void * column
static qreal component(const QPointF &point, unsigned int i)
static void scanSpace(const QChar *&ch)
static void scanToEnd(const QChar *&ch)
QDebug & operator<<(QDebug &debug, const QQmlDirParser::Component &component)
static void scanWord(const QChar *&ch)
static QTypeRevision parseVersion(const QString &str)
static QT_BEGIN_NAMESPACE int parseInt(QStringView str, bool *ok)
#define qPrintable(string)
QLatin1StringView QLatin1String
#define QStringLiteral(str)
QT_BEGIN_NAMESPACE typedef uchar * output
\inmodule QtCore \reentrant