76 bool firstLine =
true;
78 auto readImport = [&](
const QString *sections,
int sectionCount, Import::Flags
flags) {
80 if (sectionCount == 2) {
81 import = Import(sections[1], QTypeRevision(), flags);
82 }
else if (sectionCount == 3) {
84 import = Import(sections[1], QTypeRevision(), flags | Import::Auto);
87 if (version.isValid()) {
88 import = Import(sections[1], version, flags);
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));
403 if (fileName1 == fileName2)
410 const qsizetype file2PotentialFileSelectorPos = fileName2.indexOf(u
'+');
411 const bool file2MightHaveFileSelector = file2PotentialFileSelectorPos != -1;
413 if (
const qsizetype fileSelectorPos1 = fileName1.indexOf(u
'+'); fileSelectorPos1 != -1) {
416 const QString baseName = file2MightHaveFileSelector
423 *correctedFileName = baseName;
428 if (file2MightHaveFileSelector
430 *correctedFileName = fileName1;