Merge remote-tracking branch 'origin/10.0' into qds/dev

bigger conflicts resolved at:
  src/plugins/qmldesigner/CMakeLists.txt
  src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp

Change-Id: I08e2a109d8e37cbd77225129854e9e633725bfc7
This commit is contained in:
Tim Jenßen
2023-03-26 15:58:49 +02:00
8349 changed files with 128327 additions and 169799 deletions

View File

@@ -1,6 +1,6 @@
add_qtc_library(QmlJS
DEPENDS ExtensionSystem Utils Qt5::Xml
PUBLIC_DEPENDS CPlusPlus Qt5::Widgets LanguageUtils
DEPENDS ExtensionSystem Utils Qt::Xml
PUBLIC_DEPENDS CPlusPlus Qt::Widgets LanguageUtils
SOURCES
jsoncheck.cpp jsoncheck.h
parser/qmldirparser.cpp parser/qmldirparser_p.h

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "jsoncheck.h"
@@ -107,7 +107,7 @@ bool JsonCheck::visit(ObjectPattern *ast)
}
QStringList missing;
foreach (const QString &property, properties) {
for (const QString &property : properties) {
if (!propertiesFound.contains(property)) {
m_schema->enterNestedPropertySchema(property);
if (m_schema->required())

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
import sys
import os
@@ -6,19 +6,47 @@ if not len(sys.argv) >= 3:
print("Usage: %s license files..." % os.path.basename(sys.argv[0]))
sys.exit()
def detectLicense(fileContent: list[str]) -> tuple[int, int]:
for i, line in enumerate(fileContent):
if fileContent[i].startswith('//'):
"""
new license style (commented with //): return first noncomment-line
after commented license
"""
for j, line in enumerate(fileContent[i:]):
if not line.startswith('//'):
return (i, i + j)
return (i, len(fileContent))
if fileContent[i].startswith('/*'):
"""
old license style (commented as /*block*/): return line after the
block-comment
"""
for j, line in enumerate(fileContent[i:]):
if line.endswith('*/\n'):
return (i, i + j + 1)
raise ValueError("Encountered EOF while in the license comment")
# else case: probably the generated codes "#line ..."
raise ValueError("Encountered EOF without finding any license")
licenseFileName = sys.argv[1]
licenseText = ""
with open(licenseFileName, 'r') as f:
licenseText = f.read()
licenseText = licenseText[0:licenseText.find('*/')]
licenseText = f.read().splitlines(keepends=True)
start, stop = detectLicense(licenseText)
licenseText = licenseText[start:stop]
files = sys.argv[2:]
for fileName in files:
with open(fileName, 'r') as f:
text = f.read()
oldEnd = text.find('*/')
if oldEnd == -1:
oldEnd = 0
text = licenseText + text[oldEnd:]
text = f.read().splitlines(keepends=True)
start, stop = detectLicense(text)
if stop == -1:
stop = 0
with open(fileName, 'w') as f:
f.write(text)
f.writelines(text[0:start])
f.writelines(licenseText)
f.writelines(text[stop:])

View File

@@ -1,8 +1,10 @@
diff --git a/src/libs/qmljs/parser/qmldirparser.cpp b/src/libs/qmljs/parser/qmldirparser.cpp
index 747d2010f3..e9d22624ef 100644
index 49b7ee9d0c..690d1ef557 100644
--- a/src/libs/qmljs/parser/qmldirparser.cpp
+++ b/src/libs/qmljs/parser/qmldirparser.cpp
@@ -25,14 +25,10 @@
@@ -1,72 +1,42 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmldirparser_p.h"
@@ -17,7 +19,19 @@ index 747d2010f3..e9d22624ef 100644
static int parseInt(QStringView str, bool *ok)
{
int pos = 0;
@@ -50,45 +46,19 @@ static int parseInt(QStringView str, bool *ok)
int number = 0;
- while (pos < str.length() && str.at(pos).isDigit()) {
+ while (pos < str.size() && str.at(pos).isDigit()) {
if (pos != 0)
number *= 10;
number += str.at(pos).unicode() - '0';
++pos;
}
- if (pos != str.length())
+ if (pos != str.size())
*ok = false;
else
*ok = true;
return number;
}
@@ -32,7 +46,13 @@ index 747d2010f3..e9d22624ef 100644
- *minor = parseInt(QStringView(str.constData() + dotIndex + 1, str.length() - dotIndex - 1),
- &ok);
- return ok;
- }
+ const int major = parseInt(QStringView(str).left(dotIndex), &ok);
+ if (!ok)
+ return QTypeRevision();
+ const int minor = parseInt(QStringView(str).mid(dotIndex + 1, str.size() - dotIndex - 1),
+ &ok);
+ return ok ? QTypeRevision::fromVersion(major, minor) : QTypeRevision();
}
- return false;
-}
-
@@ -59,19 +79,13 @@ index 747d2010f3..e9d22624ef 100644
- major = parseInt(QStringView(str.constData(), str.length()),
- &ok);
- minor = ComponentVersion::MaxVersion;
+ const int major = parseInt(QStringView(str).left(dotIndex), &ok);
+ if (!ok)
+ return QTypeRevision();
+ const int minor = parseInt(QStringView(str).mid(dotIndex + 1, str.length() - dotIndex - 1),
+ &ok);
+ return ok ? QTypeRevision::fromVersion(major, minor) : QTypeRevision();
}
- }
- return ComponentVersion(major, minor);
+ return QTypeRevision();
}
void QmlDirParser::clear()
@@ -132,12 +102,12 @@ bool QmlDirParser::parse(const QString &source)
@@ -110,12 +80,12 @@ bool QmlDirParser::parse(const QString &source)
auto readImport = [&](const QString *sections, int sectionCount, Import::Flags flags) {
Import import;
if (sectionCount == 2) {
@@ -87,7 +101,7 @@ index 747d2010f3..e9d22624ef 100644
if (version.isValid()) {
import = Import(sections[1], version, flags);
} else {
@@ -275,7 +245,7 @@ bool QmlDirParser::parse(const QString &source)
@@ -253,7 +243,7 @@ bool QmlDirParser::parse(const QString &source)
QStringLiteral("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1));
continue;
}
@@ -96,7 +110,7 @@ index 747d2010f3..e9d22624ef 100644
entry.internal = true;
_components.insert(entry.typeName, entry);
} else if (sections[0] == QLatin1String("singleton")) {
@@ -286,16 +256,16 @@ bool QmlDirParser::parse(const QString &source)
@@ -264,16 +254,16 @@ bool QmlDirParser::parse(const QString &source)
} else if (sectionCount == 3) {
// handle qmldir directory listing case where singleton is defined in the following pattern:
// singleton TestSingletonType TestSingletonType.qml
@@ -117,7 +131,7 @@ index 747d2010f3..e9d22624ef 100644
entry.singleton = true;
_components.insert(entry.typeName, entry);
} else {
@@ -361,19 +331,19 @@ bool QmlDirParser::parse(const QString &source)
@@ -339,19 +339,19 @@ bool QmlDirParser::parse(const QString &source)
_linkTarget = sections[1];
} else if (sectionCount == 2) {
// No version specified (should only be used for relative qmldir files)
@@ -142,7 +156,7 @@ index 747d2010f3..e9d22624ef 100644
_components.insert(entry.typeName, entry);
}
} else {
@@ -420,15 +390,19 @@ QList<QmlJS::DiagnosticMessage> QmlDirParser::errors(const QString &uri) const
@@ -398,15 +398,19 @@ QList<QmlJS::DiagnosticMessage> QmlDirParser::errors(const QString &uri) const
QDebug &operator<< (QDebug &debug, const QmlDirParser::Component &component)
{
@@ -167,10 +181,16 @@ index 747d2010f3..e9d22624ef 100644
}
diff --git a/src/libs/qmljs/parser/qmldirparser_p.h b/src/libs/qmljs/parser/qmldirparser_p.h
index d5a0aabfd0..c1869b7cc8 100644
index 3d4ba5fdc0..9712ab2a6e 100644
--- a/src/libs/qmljs/parser/qmldirparser_p.h
+++ b/src/libs/qmljs/parser/qmldirparser_p.h
@@ -36,15 +36,12 @@
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -14,20 +14,17 @@
// We mean it.
//
@@ -191,7 +211,13 @@ index d5a0aabfd0..c1869b7cc8 100644
QT_QML_BEGIN_NAMESPACE
@@ -90,17 +87,19 @@ public:
class QmlEngine;
-class QML_PARSER_EXPORT QmlDirParser
+class Q_QML_COMPILER_PRIVATE_EXPORT QmlDirParser
{
public:
void clear();
@@ -68,17 +65,19 @@ public:
{
Component() = default;
@@ -216,7 +242,7 @@ index d5a0aabfd0..c1869b7cc8 100644
bool internal = false;
bool singleton = false;
};
@@ -109,16 +108,17 @@ public:
@@ -87,43 +86,46 @@ public:
{
Script() = default;
@@ -238,7 +264,14 @@ index d5a0aabfd0..c1869b7cc8 100644
};
struct Import
@@ -131,13 +131,15 @@ public:
{
enum Flag {
Default = 0x0,
Auto = 0x1, // forward the version of the importing module
Optional = 0x2, // is not automatically imported but only a tooling hint
OptionalDefault
= 0x4, // tooling hint only, denotes this entry should be imported by tooling
};
Q_DECLARE_FLAGS(Flags, Flag)
Import() = default;
@@ -255,13 +288,37 @@ index d5a0aabfd0..c1869b7cc8 100644
- LanguageUtils::ComponentVersion version; // invalid version is latest version, unless Flag::Auto
+ QTypeRevision version; // invalid version is latest version, unless Flag::Auto
Flags flags;
friend bool operator==(const Import &a, const Import &b)
{
return a.module == b.module && a.version == b.version && a.flags == b.flags;
}
};
QMultiHash<QString,Component> components() const { return _components; }
diff --git a/src/libs/qmljs/parser/qmlimportresolver.cpp b/src/libs/qmljs/parser/qmlimportresolver.cpp
index e74c5840c1..e7416ef7f0 100644
index 1d9582f76a..0c1c79860e 100644
--- a/src/libs/qmljs/parser/qmlimportresolver.cpp
+++ b/src/libs/qmljs/parser/qmlimportresolver.cpp
@@ -40,20 +40,20 @@ enum ImportVersion { FullyVersioned, PartiallyVersioned, Unversioned };
@@ -1,16 +1,13 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmlimportresolver_p.h"
-#include <QtCore/QList>
-#include <QtCore/QStringList>
-#include <QtCore/QStringView>
QT_QML_BEGIN_NAMESPACE
enum ImportVersion { FullyVersioned, PartiallyVersioned, Unversioned };
-/*!
+/*
Forms complete paths to a module, from a list of base paths,
a module URI and version specification.
@@ -21,20 +18,20 @@ enum ImportVersion { FullyVersioned, PartiallyVersioned, Unversioned };
- base/QtQml.2/Models
- base/QtQml/Models
*/
@@ -279,7 +336,8 @@ index e74c5840c1..e7416ef7f0 100644
QStringList importPaths;
// fully & partially versioned parts + 1 unversioned for each base path
importPaths.reserve(2 * parts.count() + 1);
- importPaths.reserve(2 * parts.count() + 1);
+ importPaths.reserve(2 * parts.size() + 1);
- auto versionString = [](LanguageUtils::ComponentVersion version, ImportVersion mode)
- {
@@ -287,7 +345,7 @@ index e74c5840c1..e7416ef7f0 100644
if (mode == FullyVersioned) {
// extension with fully encoded version number (eg. MyModule.3.2)
return QString::fromLatin1(".%1.%2").arg(version.majorVersion())
@@ -67,7 +67,7 @@ QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths
@@ -48,7 +45,7 @@ QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths
return QString();
};
@@ -296,7 +354,7 @@ index e74c5840c1..e7416ef7f0 100644
QString str;
for (auto it = refs.cbegin(); it != refs.cend(); ++it) {
if (it != refs.cbegin())
@@ -77,9 +77,10 @@ QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths
@@ -58,9 +55,10 @@ QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths
return str;
};
@@ -310,11 +368,26 @@ index e74c5840c1..e7416ef7f0 100644
for (int mode = initial; mode <= Unversioned; ++mode) {
const QString ver = versionString(version, ImportVersion(mode));
@@ -74,7 +72,7 @@ QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths
if (mode != Unversioned) {
// insert in the middle
- for (int index = parts.count() - 2; index >= 0; --index) {
+ for (int index = parts.size() - 2; index >= 0; --index) {
importPaths += dir + joinStringRefs(parts.mid(0, index + 1), Slash)
+ ver + Slash
+ joinStringRefs(parts.mid(index + 1), Slash);
diff --git a/src/libs/qmljs/parser/qmlimportresolver_p.h b/src/libs/qmljs/parser/qmlimportresolver_p.h
index 68c052d408..8f18de3d0b 100644
index 4c9ed68d11..0a36cd3c9b 100644
--- a/src/libs/qmljs/parser/qmlimportresolver_p.h
+++ b/src/libs/qmljs/parser/qmlimportresolver_p.h
@@ -40,11 +40,12 @@
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -18,11 +18,12 @@
#include "qmljsglobal_p.h"
#include <QtCore/qstring.h>
@@ -325,72 +398,35 @@ index 68c052d408..8f18de3d0b 100644
-QML_PARSER_EXPORT QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths,
- LanguageUtils::ComponentVersion version);
+QML_PARSER_EXPORT QStringList qQmlResolveImportPaths(QStringView uri,
+ const QStringList &basePaths,
+ QTypeRevision version);
+Q_QML_COMPILER_PRIVATE_EXPORT QStringList qQmlResolveImportPaths(QStringView uri,
+ const QStringList &basePaths,
+ QTypeRevision version);
QT_QML_END_NAMESPACE
diff --git a/src/libs/qmljs/parser/qmljs.g b/src/libs/qmljs/parser/qmljs.g
index 5f62edf4d1..19f4e200e5 100644
--- a/src/libs/qmljs/parser/qmljs.g
+++ b/src/libs/qmljs/parser/qmljs.g
@@ -381,7 +381,7 @@ public:
inline DiagnosticMessage diagnosticMessage() const
{
for (const DiagnosticMessage &d : diagnostic_messages) {
- if (d.kind != Severity::Warning)
+ if (d.type != QtWarningMsg)
return d;
}
@@ -425,7 +425,7 @@ protected:
DiagnosticMessage error;
error.loc = location;
error.message = message;
- error.kind = DiagnosticMessage::qtMsgTypeToKind(kind);
+ error.type = kind;
return error;
}
@@ -446,8 +446,8 @@ protected:
Value *sym_stack = nullptr;
int *state_stack = nullptr;
SourceLocation *location_stack = nullptr;
- QVector<QStringView> string_stack;
- QVector<QStringView> rawString_stack;
+ QList<QStringView> string_stack;
+ QList<QStringView> rawString_stack;
AST::Node *program = nullptr;
@@ -849,7 +849,7 @@ UiVersionSpecifier: T_VERSION_NUMBER T_DOT T_VERSION_NUMBER;
case $rule_number: {
const int major = sym(1).dval;
const int minor = sym(3).dval;
- if (major < 0 || major >= 255 || minor < 0 || minor >= 255) {
+ if (!QTypeRevision::isValidSegment(major) || !QTypeRevision::isValidSegment(minor)) {
diagnostic_messages.append(
compileError(loc(1),
QLatin1String("Invalid version. Version numbers must be >= 0 and < 255.")));
@@ -862,11 +862,12 @@ UiVersionSpecifier: T_VERSION_NUMBER T_DOT T_VERSION_NUMBER;
} break;
./
+
UiVersionSpecifier: T_VERSION_NUMBER;
/.
case $rule_number: {
const int major = sym(1).dval;
- if (major < 0 || major >= 255) {
+ if (!QTypeRevision::isValidSegment(major)) {
diagnostic_messages.append(
compileError(loc(1),
QLatin1String("Invalid major version. Version numbers must be >= 0 and < 255.")));
diff --git a/src/libs/qmljs/parser/qmljsast_p.h b/src/libs/qmljs/parser/qmljsast_p.h
index 78b9f4b080..dcbcb5fd0d 100644
index ba5cc3a719..b7280b1f56 100644
--- a/src/libs/qmljs/parser/qmljsast_p.h
+++ b/src/libs/qmljs/parser/qmljsast_p.h
@@ -654,12 +654,14 @@ class QML_PARSER_EXPORT UiVersionSpecifier : public Node
@@ -19,16 +19,15 @@
#include "qmljs/parser/qmljsmemorypool_p.h"
#include <QtCore/qtaggedpointer.h>
#include <QtCore/qversionnumber.h>
-QT_BEGIN_NAMESPACE
-class QString;
-QT_END_NAMESPACE
#include <type_traits>
QT_QML_BEGIN_NAMESPACE
+class QString;
+
namespace QmlJS {
class Parser;
}
@@ -634,12 +614,14 @@ class QML_PARSER_EXPORT UiVersionSpecifier : public Node
public:
QMLJS_DECLARE_AST_NODE(UiVersionSpecifier)
@@ -407,7 +443,7 @@ index 78b9f4b080..dcbcb5fd0d 100644
{
kind = K;
}
@@ -674,8 +676,7 @@ public:
@@ -654,8 +636,7 @@ public:
}
// attributes:
@@ -417,38 +453,34 @@ index 78b9f4b080..dcbcb5fd0d 100644
SourceLocation majorToken;
SourceLocation minorToken;
};
@@ -881,14 +882,14 @@ struct QML_PARSER_EXPORT BoundName
};
@@ -3418,19 +3403,19 @@ public:
QString id;
- TypeAnnotation *typeAnnotation;
- Type typeAnnotationType;
+ QTaggedPointer<TypeAnnotation, Type> typeAnnotation;
BoundName(const QString &id, TypeAnnotation *typeAnnotation, Type type = Declared)
- : id(id), typeAnnotation(typeAnnotation), typeAnnotationType(type)
+ : id(id)
+ , typeAnnotation(typeAnnotation, type)
{}
BoundName() = default;
QString typeName() const { return typeAnnotation ? typeAnnotation->type->toString() : QString(); }
- bool isInjected() const { return typeAnnotation && typeAnnotationType == Injected; }
+ bool isInjected() const { return typeAnnotation.tag() == Injected; }
};
SourceLocation defaultToken() const
{
- return hasAttributes ? m_attributes->defaultToken() : SourceLocation{};
+ return hasAttributes ? m_attributes->defaultToken() : SourceLocation{};
}
bool isDefaultMember() const { return defaultToken().isValid(); }
SourceLocation requiredToken() const
{
- return hasAttributes ? m_attributes->requiredToken() : SourceLocation{};
+ return hasAttributes ? m_attributes->requiredToken() : SourceLocation{};
}
bool isRequired() const { return requiredToken().isValid(); }
SourceLocation readonlyToken() const
{
- return hasAttributes ? m_attributes->readonlyToken() : SourceLocation{};
+ return hasAttributes ? m_attributes->readonlyToken() : SourceLocation{};
}
bool isReadonly() const { return readonlyToken().isValid(); }
struct BoundNames : public QVector<BoundName>
@@ -3486,7 +3487,6 @@ public:
SourceLocation identifierToken;
SourceLocation colonToken;
SourceLocation semicolonToken;
-
private:
union {
SourceLocation m_propertyToken = SourceLocation{};
diff --git a/src/libs/qmljs/parser/qmljslexer.cpp b/src/libs/qmljs/parser/qmljslexer.cpp
index 6c4eb70744..90f567d19c 100644
index 248f1f92f3..4f8eefa4c6 100644
--- a/src/libs/qmljs/parser/qmljslexer.cpp
+++ b/src/libs/qmljs/parser/qmljslexer.cpp
@@ -27,6 +27,7 @@
@@ -5,6 +5,7 @@
#include "qmljsengine_p.h"
#include "qmljskeywords_p.h"
@@ -456,26 +488,29 @@ index 6c4eb70744..90f567d19c 100644
#include "qmljs/parser/qmljsdiagnosticmessage_p.h"
#include "qmljs/parser/qmljsmemorypool_p.h"
@@ -35,14 +36,6 @@
@@ -13,11 +14,9 @@
#include <QtCore/qdebug.h>
#include <QtCore/QScopedValueRollback>
-QT_BEGIN_NAMESPACE
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
-Q_CORE_EXPORT double qstrntod(const char *s00, int len, char const **se, bool *ok);
-#else
-Q_CORE_EXPORT double qstrntod(const char *s00, qsizetype len, char const **se, bool *ok);
-#endif
-QT_END_NAMESPACE
-
#include <optional>
+QT_QML_BEGIN_NAMESPACE
using namespace QmlJS;
static inline int regExpFlagFromChar(const QChar &ch)
diff --git a/src/libs/qmljs/parser/qmljslexer_p.h b/src/libs/qmljs/parser/qmljslexer_p.h
index a442748d74..dc7f7f7308 100644
index c34636f2ba..73a853a6d1 100644
--- a/src/libs/qmljs/parser/qmljslexer_p.h
+++ b/src/libs/qmljs/parser/qmljslexer_p.h
@@ -47,7 +47,7 @@ QT_QML_BEGIN_NAMESPACE
@@ -22,12 +22,12 @@
QT_QML_BEGIN_NAMESPACE
class QDebug;
namespace QmlJS {
class Engine;
@@ -484,11 +519,33 @@ index a442748d74..dc7f7f7308 100644
class Directives;
class QML_PARSER_EXPORT Lexer: public QmlJSGrammar
diff --git a/src/libs/qmljs/parser/qmljsmemorypool_p.h b/src/libs/qmljs/parser/qmljsmemorypool_p.h
index b13e795be5..8d0321af27 100644
--- a/src/libs/qmljs/parser/qmljsmemorypool_p.h
+++ b/src/libs/qmljs/parser/qmljsmemorypool_p.h
@@ -14,7 +14,7 @@
// We mean it.
//
-#include "qmljsglobal_p.h"
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qstring.h>
#include <QtCore/qvector.h>
diff --git a/src/libs/qmljs/parser/qmljssourcelocation_p.h b/src/libs/qmljs/parser/qmljssourcelocation_p.h
index 29be90fd9b..865c008f19 100644
index 8713cad548..8f9148d079 100644
--- a/src/libs/qmljs/parser/qmljssourcelocation_p.h
+++ b/src/libs/qmljs/parser/qmljssourcelocation_p.h
@@ -95,8 +95,11 @@ public:
@@ -3,7 +3,7 @@
#pragma once
-#include "qmljsglobal_p.h"
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qhashfunctions.h>
//
@@ -73,8 +73,11 @@ public:
friend size_t qHash(const SourceLocation &location, size_t seed = 0)
{
@@ -502,3 +559,25 @@ index 29be90fd9b..865c008f19 100644
}
friend bool operator==(const SourceLocation &a, const SourceLocation &b)
diff --git a/src/libs/qmljs/parser/qmljs.g b/src/libs/qmljs/parser/qmljs.g
index 6789f6e673..fdd31500a3 100644
--- a/src/libs/qmljs/parser/qmljs.g
+++ b/src/libs/qmljs/parser/qmljs.g
@@ -286,7 +286,7 @@ public:
inline DiagnosticMessage diagnosticMessage() const
{
for (const DiagnosticMessage &d : diagnostic_messages) {
+ if (d.type != QtWarningMsg)
- if (d.isWarning())
return d;
}
@@ -330,7 +330,7 @@ protected:
DiagnosticMessage error;
error.loc = location;
error.message = message;
+ error.type = kind;
- error.kind = DiagnosticMessage::qtMsgTypeToKind(kind);
return error;
}

View File

@@ -1,33 +1,17 @@
diff --git a/src/libs/qmljs/parser/qmljsgrammar.cpp b/src/libs/qmljs/parser/qmljsgrammar.cpp
index 0413edb006..373f42747d 100644
--- a/src/libs/qmljs/parser/qmljsgrammar.cpp
+++ b/src/libs/qmljs/parser/qmljsgrammar.cpp
@@ -22,6 +22,7 @@
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
***************************************************************************/
-// This file was generated by qlalr - DO NOT EDIT!
+ / This file was generated by qlalr
+ - DO NOT EDIT !
#include "qmljsgrammar_p.h"
diff --git a/src/libs/qmljs/parser/qmljsgrammar_p.h b/src/libs/qmljs/parser/qmljsgrammar_p.h
index 2e7172b41d..6a057768d4 100644
index d1c6545896..74a98634f9 100644
--- a/src/libs/qmljs/parser/qmljsgrammar_p.h
+++ b/src/libs/qmljs/parser/qmljsgrammar_p.h
@@ -22,12 +22,12 @@
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
***************************************************************************/
@@ -1,11 +1,9 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-// This file was generated by qlalr - DO NOT EDIT!
+ / This file was generated by qlalr
+ - DO NOT EDIT !
#ifndef QMLJSGRAMMAR_P_H
#define QMLJSGRAMMAR_P_H
-#include "qmljsglobal_p.h"
-class QML_PARSER_EXPORT QmlJSGrammar
+ class QmlJSGrammar
+class QmlJSGrammar
{
public:
enum VariousConstants {

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmldirparser_p.h"
@@ -237,6 +237,26 @@ bool QmlDirParser::parse(const QString &source)
"not %1.").arg(sections[1]));
continue;
}
} else if (sections[0] == QLatin1String("default")) {
if (sectionCount < 2) {
reportError(lineNumber,
0,
QStringLiteral("default directive requires further "
"arguments, but none were provided."));
continue;
}
if (sections[1] == QLatin1String("import")) {
if (!readImport(sections + 1,
sectionCount - 1,
Import::Flags({Import::Optional, Import::OptionalDefault})))
continue;
} else {
reportError(lineNumber,
0,
QStringLiteral("only optional imports can have a a defaultl, "
"not %1.")
.arg(sections[1]));
}
} else if (sections[0] == QLatin1String("classname")) {
if (sectionCount < 2) {
reportError(lineNumber, 0,
@@ -248,14 +268,28 @@ bool QmlDirParser::parse(const QString &source)
_classNames.append(sections[1]);
} else if (sections[0] == QLatin1String("internal")) {
if (sectionCount != 3) {
if (sectionCount == 3) {
Component entry(sections[1], sections[2], -1, -1);
entry.internal = true;
_components.insert(entry.typeName, entry);
} else if (sectionCount == 4) {
int major, minor;
if (parseVersion(sections[2], &major, &minor)) {
Component entry(sections[1], sections[3], major, minor);
entry.internal = true;
_components.insert(entry.typeName, entry);
} else {
reportError(lineNumber, 0,
QStringLiteral("invalid version %1, expected <major>.<minor>")
.arg(sections[2]));
continue;
}
} else {
reportError(lineNumber, 0,
QStringLiteral("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1));
QStringLiteral("internal types require 2 or 3 arguments, "
"but %1 were provided").arg(sectionCount - 1));
continue;
}
Component entry(sections[1], sections[2], -1, -1);
entry.internal = true;
_components.insert(entry.typeName, entry);
} else if (sections[0] == QLatin1String("singleton")) {
if (sectionCount < 3 || sectionCount > 4) {
reportError(lineNumber, 0,
@@ -292,6 +326,16 @@ bool QmlDirParser::parse(const QString &source)
reportError(lineNumber, 0, QStringLiteral("designersupported does not expect any argument"));
else
_designerSupported = true;
} else if (sections[0] == QLatin1String("static")) {
if (sectionCount != 1)
reportError(lineNumber, 0, QStringLiteral("static does not expect any argument"));
else
_isStaticModule = true;
} else if (sections[0] == QLatin1String("system")) {
if (sectionCount != 1)
reportError(lineNumber, 0, QStringLiteral("system does not expect any argument"));
else
_isSystemModule = true;
} else if (sections[0] == QLatin1String("import")
|| sections[0] == QLatin1String("depends")) {
if (!readImport(sections, sectionCount, Import::Default))

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -102,9 +102,11 @@ public:
struct Import
{
enum Flag {
Default = 0x0,
Auto = 0x1, // forward the version of the importing module
Optional = 0x2 // is not automatically imported but only a tooling hint
Default = 0x0,
Auto = 0x1, // forward the version of the importing module
Optional = 0x2, // is not automatically imported but only a tooling hint
OptionalDefault
= 0x4, // tooling hint only, denotes this entry should be imported by tooling
};
Q_DECLARE_FLAGS(Flags, Flag)
@@ -117,6 +119,11 @@ public:
QString module;
LanguageUtils::ComponentVersion version; // invalid version is latest version, unless Flag::Auto
Flags flags;
friend bool operator==(const Import &a, const Import &b)
{
return a.module == b.module && a.version == b.version && a.flags == b.flags;
}
};
QMultiHash<QString,Component> components() const { return _components; }
@@ -125,6 +132,8 @@ public:
QList<Script> scripts() const { return _scripts; }
QList<Plugin> plugins() const { return _plugins; }
bool designerSupported() const { return _designerSupported; }
bool isStaticModule() const { return _isStaticModule; }
bool isSystemModule() const { return _isSystemModule; }
QStringList typeInfos() const { return _typeInfos; }
QStringList classNames() const { return _classNames; }
@@ -145,6 +154,8 @@ private:
QList<Script> _scripts;
QList<Plugin> _plugins;
bool _designerSupported = false;
bool _isStaticModule = false;
bool _isSystemModule = false;
QStringList _typeInfos;
QStringList _classNames;
QString _linkTarget;

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmlimportresolver_p.h"
#include <QtCore/QList>

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
-- Copyright (C) 2016 The Qt Company Ltd.
-- SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR LGPL-3.0
-- SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
%parser QmlJSGrammar
%decl qmljsparser_p.h
@@ -73,8 +73,19 @@
%token T_GET "get"
%token T_SET "set"
-- token representing no token
%token T_NONE
%token T_ERROR
-- states for line by line parsing
%token T_EOL
%token T_PARTIAL_COMMENT "non closed multiline comment"
%token T_PARTIAL_SINGLE_QUOTE_STRING_LITERAL "multiline single quote string literal"
%token T_PARTIAL_DOUBLE_QUOTE_STRING_LITERAL "multiline double quote string literal"
%token T_PARTIAL_TEMPLATE_HEAD "(template head)"
%token T_PARTIAL_TEMPLATE_MIDDLE "(template middle)"
--- feed tokens
%token T_FEED_UI_PROGRAM
%token T_FEED_UI_OBJECT_MEMBER
@@ -96,44 +107,9 @@
%start TopLevel
/./****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
/.// Copyright (C) 2016 The Qt Company Ltd.
// Contact: https://www.qt.io/licensing/
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qmljs/parser/qmljsengine_p.h"
#include "qmljs/parser/qmljslexer_p.h"
@@ -147,44 +123,9 @@
./
/:/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
/:// Copyright (C) 2016 The Qt Company Ltd.
// Contact: https://www.qt.io/licensing/
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
//
@@ -271,7 +212,7 @@ public:
AST::ExportClause *ExportClause;
AST::ExportDeclaration *ExportDeclaration;
AST::TypeAnnotation *TypeAnnotation;
AST::TypeArgumentList *TypeArgumentList;
AST::TypeArgument *TypeArgument;
AST::Type *Type;
AST::UiProgram *UiProgram;
@@ -345,7 +286,7 @@ public:
inline DiagnosticMessage diagnosticMessage() const
{
for (const DiagnosticMessage &d : diagnostic_messages) {
if (d.kind != Severity::Warning)
if (d.isWarning())
return d;
}
@@ -438,6 +379,7 @@ protected:
SavedToken *last_token = nullptr;
int functionNestingLevel = 0;
int classNestingLevel = 0;
enum CoverExpressionType {
CE_Invalid,
@@ -813,7 +755,7 @@ UiVersionSpecifier: T_VERSION_NUMBER T_DOT T_VERSION_NUMBER;
case $rule_number: {
const int major = sym(1).dval;
const int minor = sym(3).dval;
if (major < 0 || major >= 255 || minor < 0 || minor >= 255) {
if (!QTypeRevision::isValidSegment(major) || !QTypeRevision::isValidSegment(minor)) {
diagnostic_messages.append(
compileError(loc(1),
QLatin1String("Invalid version. Version numbers must be >= 0 and < 255.")));
@@ -826,11 +768,12 @@ UiVersionSpecifier: T_VERSION_NUMBER T_DOT T_VERSION_NUMBER;
} break;
./
UiVersionSpecifier: T_VERSION_NUMBER;
/.
case $rule_number: {
const int major = sym(1).dval;
if (major < 0 || major >= 255) {
if (!QTypeRevision::isValidSegment(major)) {
diagnostic_messages.append(
compileError(loc(1),
QLatin1String("Invalid major version. Version numbers must be >= 0 and < 255.")));
@@ -1188,10 +1131,10 @@ UiParameterListOpt: UiParameterList;
} break;
./
UiParameterList: QmlIdentifier T_COLON UiPropertyType;
UiParameterList: QmlIdentifier T_COLON Type;
/.
case $rule_number: {
AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(3).UiQualifiedId->finish(), stringRef(1));
AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(3).Type, stringRef(1));
node->identifierToken = loc(1);
node->colonToken = loc(2);
node->propertyTypeToken = loc(3);
@@ -1199,20 +1142,20 @@ UiParameterList: QmlIdentifier T_COLON UiPropertyType;
} break;
./
UiParameterList: UiPropertyType QmlIdentifier;
UiParameterList: Type QmlIdentifier;
/.
case $rule_number: {
AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiQualifiedId->finish(), stringRef(2));
AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).Type, stringRef(2));
node->propertyTypeToken = loc(1);
node->identifierToken = loc(2);
sym(1).Node = node;
} break;
./
UiParameterList: UiParameterList T_COMMA QmlIdentifier T_COLON UiPropertyType;
UiParameterList: UiParameterList T_COMMA QmlIdentifier T_COLON Type;
/.
case $rule_number: {
AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, sym(5).UiQualifiedId->finish(), stringRef(3));
AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, sym(5).Type, stringRef(3));
node->propertyTypeToken = loc(5);
node->commaToken = loc(2);
node->identifierToken = loc(3);
@@ -1221,10 +1164,10 @@ UiParameterList: UiParameterList T_COMMA QmlIdentifier T_COLON UiPropertyType;
} break;
./
UiParameterList: UiParameterList T_COMMA UiPropertyType QmlIdentifier;
UiParameterList: UiParameterList T_COMMA Type QmlIdentifier;
/.
case $rule_number: {
AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, sym(3).UiQualifiedId->finish(), stringRef(4));
AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, sym(3).Type, stringRef(4));
node->propertyTypeToken = loc(3);
node->commaToken = loc(2);
node->identifierToken = loc(4);
@@ -1384,9 +1327,26 @@ UiObjectMemberWithScriptStatement: UiPropertyAttributes UiPropertyType QmlIdenti
} break;
./
UiObjectMemberWithScriptStatement: UiPropertyAttributes T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_COLON UiScriptStatement OptionalSemicolon;
/.
case $rule_number: {
AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6), sym(8).Statement);
node->typeModifier = stringRef(2);
auto attributes = sym(1).UiPropertyAttributes;
if (attributes->isRequired())
diagnostic_messages.append(compileError(attributes->requiredToken(), QLatin1String("Required properties with initializer do not make sense."), QtCriticalMsg));
node->setAttributes(attributes);
node->typeModifierToken = loc(2);
node->typeToken = loc(4);
node->identifierToken = loc(6);
node->colonToken = loc(7);
sym(1).Node = node;
} break;
./
UiObjectMember: UiObjectMemberWithScriptStatement;
UiObjectMemberWithArray: UiPropertyAttributes T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET Semicolon;
UiObjectMemberWithArray: UiPropertyAttributes T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_COLON ExpressionStatementLookahead T_LBRACKET UiArrayMemberList T_RBRACKET Semicolon;
/.
case $rule_number: {
AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6));
@@ -1404,10 +1364,10 @@ UiObjectMemberWithArray: UiPropertyAttributes T_IDENTIFIER T_LT UiPropertyType T
propertyName->identifierToken = loc(6);
propertyName->next = nullptr;
AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding(propertyName, sym(9).UiArrayMemberList->finish());
AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding(propertyName, sym(10).UiArrayMemberList->finish());
binding->colonToken = loc(7);
binding->lbracketToken = loc(8);
binding->rbracketToken = loc(10);
binding->lbracketToken = loc(9);
binding->rbracketToken = loc(11);
node->binding = binding;
@@ -1495,6 +1455,8 @@ UiObjectMember: T_ENUM T_IDENTIFIER T_LBRACE EnumMemberList T_RBRACE;
case $rule_number: {
AST::UiEnumDeclaration *enumDeclaration = new (pool) AST::UiEnumDeclaration(stringRef(2), sym(4).UiEnumMemberList->finish());
enumDeclaration->enumToken = loc(1);
enumDeclaration->identifierToken = loc(2);
enumDeclaration->lbraceToken = loc(3);
enumDeclaration->rbraceToken = loc(5);
sym(1).Node = enumDeclaration;
break;
@@ -1535,6 +1497,18 @@ EnumMemberList: T_IDENTIFIER T_EQ T_NUMERIC_LITERAL;
}
./
EnumMemberList: T_IDENTIFIER T_EQ T_MINUS T_NUMERIC_LITERAL;
/.
case $rule_number: {
AST::UiEnumMemberList *node = new (pool) AST::UiEnumMemberList(stringRef(1), -sym(4).dval);
node->memberToken = loc(1);
node->valueToken = combine(loc(3), loc(4));
sym(1).Node = node;
break;
}
./
EnumMemberList: EnumMemberList T_COMMA T_IDENTIFIER;
/.
case $rule_number: {
@@ -1556,6 +1530,18 @@ EnumMemberList: EnumMemberList T_COMMA T_IDENTIFIER T_EQ T_NUMERIC_LITERAL;
}
./
EnumMemberList: EnumMemberList T_COMMA T_IDENTIFIER T_EQ T_MINUS T_NUMERIC_LITERAL;
/.
case $rule_number: {
AST::UiEnumMemberList *node = new (pool) AST::UiEnumMemberList(sym(1).UiEnumMemberList, stringRef(3), -sym(6).dval);
node->memberToken = loc(3);
node->valueToken = combine(loc(5), loc(6));
sym(1).Node = node;
break;
}
./
QmlIdentifier: T_IDENTIFIER
| T_PROPERTY
| T_SIGNAL
@@ -1589,28 +1575,16 @@ BindingIdentifier: IdentifierReference;
-- Types
--------------------------------------------------------------------------------------------------------
TypeArguments: Type;
Type: UiQualifiedId T_LT SimpleType T_GT;
/.
case $rule_number: {
sym(1).TypeArgumentList = new (pool) AST::TypeArgumentList(sym(1).Type);
sym(1).Type = new (pool) AST::Type(sym(1).UiQualifiedId, sym(3).Type);
} break;
./
TypeArguments: TypeArguments T_COMMA Type;
/.
case $rule_number: {
sym(1).TypeArgumentList = new (pool) AST::TypeArgumentList(sym(1).TypeArgumentList, sym(3).Type);
} break;
./
Type: SimpleType;
Type: UiQualifiedId T_LT TypeArguments T_GT;
/.
case $rule_number: {
sym(1).Type = new (pool) AST::Type(sym(1).UiQualifiedId, sym(3).TypeArgumentList->finish());
} break;
./
Type: T_RESERVED_WORD;
SimpleType: T_RESERVED_WORD;
/.
case $rule_number: {
AST::UiQualifiedId *id = new (pool) AST::UiQualifiedId(stringRef(1));
@@ -1619,13 +1593,25 @@ Type: T_RESERVED_WORD;
} break;
./
Type: UiQualifiedId;
SimpleType: UiQualifiedId;
/.
case $rule_number: {
sym(1).Type = new (pool) AST::Type(sym(1).UiQualifiedId);
} break;
./
SimpleType: T_VAR;
/. case $rule_number: Q_FALLTHROUGH(); ./
SimpleType: T_VOID;
/.
case $rule_number: {
AST::UiQualifiedId *id = new (pool) AST::UiQualifiedId(stringRef(1));
id->identifierToken = loc(1);
sym(1).Type = new (pool) AST::Type(id->finish());
} break;
./
TypeAnnotation: T_COLON Type;
/.
case $rule_number: {
@@ -4318,16 +4304,16 @@ ClassDeclaration_Default: ClassDeclaration;
ClassLBrace: T_LBRACE;
/.
case $rule_number: {
lexer->setStaticIsKeyword(true);
if (++classNestingLevel == 1)
lexer->setStaticIsKeyword(true);
} break;
./
ClassRBrace: T_RBRACE;
/. case $rule_number: ./
ClassStaticQualifier: T_STATIC;
/.
case $rule_number: {
lexer->setStaticIsKeyword(false);
if (--classNestingLevel == 0)
lexer->setStaticIsKeyword(false);
} break;
./
@@ -4382,10 +4368,9 @@ ClassElement: MethodDefinition;
} break;
./
ClassElement: ClassStaticQualifier MethodDefinition;
ClassElement: T_STATIC MethodDefinition;
/.
case $rule_number: {
lexer->setStaticIsKeyword(true);
AST::ClassElementList *node = new (pool) AST::ClassElementList(sym(2).PatternProperty, true);
sym(1).Node = node;
} break;

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsast_p.h"
#include <QLocale>
@@ -1311,17 +1311,7 @@ void Type::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(typeId, visitor);
accept(typeArguments, visitor);
}
visitor->endVisit(this);
}
void TypeArgumentList::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
for (TypeArgumentList *it = this; it; it = it->next)
accept(it->typeId, visitor);
accept(typeArgument, visitor);
}
visitor->endVisit(this);
@@ -1563,17 +1553,11 @@ QString Type::toString() const
void Type::toString(QString *out) const
{
for (QmlJS::AST::UiQualifiedId *it = typeId; it; it = it->next) {
out->append(it->name);
typeId->toString(out);
if (it->next)
out->append(QLatin1Char('.'));
}
if (typeArguments) {
if (typeArgument) {
out->append(QLatin1Char('<'));
if (auto subType = static_cast<TypeArgumentList*>(typeArguments)->typeId)
subType->toString(out);
typeArgument->toString(out);
out->append(QLatin1Char('>'));
};
}

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -19,11 +19,13 @@
#include "qmljs/parser/qmljsmemorypool_p.h"
#include <QtCore/qtaggedpointer.h>
#include <QtCore/qversionnumber.h>
QT_BEGIN_NAMESPACE
class QString;
QT_END_NAMESPACE
#include <type_traits>
QT_QML_BEGIN_NAMESPACE
@@ -96,10 +98,10 @@ enum class VariableScope {
template <typename T1, typename T2>
T1 cast(T2 *ast)
{
if (ast && ast->kind == static_cast<T1>(0)->K)
if (ast && ast->kind == std::remove_pointer_t<T1>::K)
return static_cast<T1>(ast);
return 0;
return nullptr;
}
FunctionExpression *asAnonymousFunctionDefinition(AST::Node *n);
@@ -209,7 +211,7 @@ public:
Kind_PatternProperty,
Kind_PatternPropertyList,
Kind_Type,
Kind_TypeArgumentList,
Kind_TypeArgument,
Kind_TypeAnnotation,
Kind_UiArrayBinding,
@@ -327,6 +329,22 @@ public:
SourceLocation lastSourceLocation() const override
{ return lastListElement(this)->identifierToken; }
QString toString() const
{
QString result;
toString(&result);
return result;
}
void toString(QString *out) const
{
for (const UiQualifiedId *it = this; it; it = it->next) {
out->append(it->name);
if (it->next)
out->append(QLatin1Char('.'));
}
}
// attributes
UiQualifiedId *next;
QStringView name;
@@ -338,9 +356,9 @@ class QML_PARSER_EXPORT Type: public Node
public:
QMLJS_DECLARE_AST_NODE(Type)
Type(UiQualifiedId *typeId, Node *typeArguments = nullptr)
Type(UiQualifiedId *typeId, Type *typeArgument = nullptr)
: typeId(typeId)
, typeArguments(typeArguments)
, typeArgument(typeArgument ? typeArgument->typeId : nullptr)
{ kind = K; }
void accept0(BaseVisitor *visitor) override;
@@ -349,53 +367,16 @@ public:
{ return typeId->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
{ return typeArguments ? typeArguments->lastSourceLocation() : typeId->lastSourceLocation(); }
{
return typeArgument ? typeArgument->lastSourceLocation() : typeId->lastSourceLocation();
}
QString toString() const;
void toString(QString *out) const;
// attributes
UiQualifiedId *typeId;
Node *typeArguments; // TypeArgumentList
};
class QML_PARSER_EXPORT TypeArgumentList: public Node
{
public:
QMLJS_DECLARE_AST_NODE(TypeArgumentList)
TypeArgumentList(Type *typeId)
: typeId(typeId)
, next(nullptr)
{ kind = K; }
TypeArgumentList(TypeArgumentList *previous, Type *typeId)
: typeId(typeId)
{
kind = K;
next = previous->next;
previous->next = this;
}
void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return typeId->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
{ return lastListElement(this)->typeId->lastSourceLocation(); }
inline TypeArgumentList *finish()
{
TypeArgumentList *front = next;
next = nullptr;
return front;
}
// attributes
Type *typeId;
TypeArgumentList *next;
UiQualifiedId *typeArgument;
};
class QML_PARSER_EXPORT TypeAnnotation: public Node
@@ -861,14 +842,14 @@ struct QML_PARSER_EXPORT BoundName
};
QString id;
TypeAnnotation *typeAnnotation;
Type typeAnnotationType;
QTaggedPointer<TypeAnnotation, Type> typeAnnotation;
BoundName(const QString &id, TypeAnnotation *typeAnnotation, Type type = Declared)
: id(id), typeAnnotation(typeAnnotation), typeAnnotationType(type)
: id(id)
, typeAnnotation(typeAnnotation, type)
{}
BoundName() = default;
QString typeName() const { return typeAnnotation ? typeAnnotation->type->toString() : QString(); }
bool isInjected() const { return typeAnnotation && typeAnnotationType == Injected; }
bool isInjected() const { return typeAnnotation.tag() == Injected; }
};
struct BoundNames : public QVector<BoundName>
@@ -3293,12 +3274,17 @@ class QML_PARSER_EXPORT UiParameterList: public Node
public:
QMLJS_DECLARE_AST_NODE(UiParameterList)
UiParameterList(UiQualifiedId *t, QStringView n):
type (t), name (n), next (this)
{ kind = K; }
UiParameterList(Type *t, QStringView n)
: type(t)
, name(n)
, next(this)
{
kind = K;
}
UiParameterList(UiParameterList *previous, UiQualifiedId *t, QStringView n):
type (t), name (n)
UiParameterList(UiParameterList *previous, Type *t, QStringView n)
: type(t)
, name(n)
{
kind = K;
next = previous->next;
@@ -3324,7 +3310,7 @@ public:
}
// attributes
UiQualifiedId *type;
Type *type;
QStringView name;
UiParameterList *next;
SourceLocation commaToken;
@@ -3716,6 +3702,8 @@ public:
// attributes
SourceLocation enumToken;
SourceLocation identifierToken;
SourceLocation lbraceToken;
SourceLocation rbraceToken;
QStringView name;
UiEnumMemberList *members;

View File

@@ -1,9 +1,8 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include "qmljsglobal_p.h"
#include "qmljs/parser/qmljssourcelocation_p.h"
#include "qmljsglobal_p.h"
@@ -122,7 +121,7 @@ class NestedExpression;
class ClassExpression;
class ClassDeclaration;
class ClassElementList;
class TypeArgumentList;
class TypeArgument;
class Type;
class TypeAnnotation;

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsastvisitor_p.h"

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -377,8 +377,8 @@ public:
virtual bool visit(Type *) = 0;
virtual void endVisit(Type *) = 0;
virtual bool visit(TypeArgumentList *) = 0;
virtual void endVisit(TypeArgumentList *) = 0;
virtual bool visit(TypeArgument *) = 0;
virtual void endVisit(TypeArgument *) = 0;
virtual bool visit(TypeAnnotation *) = 0;
virtual void endVisit(TypeAnnotation *) = 0;
@@ -721,8 +721,8 @@ public:
bool visit(Type *) override { return true; }
void endVisit(Type *) override {}
bool visit(TypeArgumentList *) override { return true; }
void endVisit(TypeArgumentList *) override {}
bool visit(TypeArgument *) override { return true; }
void endVisit(TypeArgument *) override {}
bool visit(TypeAnnotation *) override { return true; }
void endVisit(TypeAnnotation *) override {}

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -75,7 +75,7 @@ public:
_comments.append(QmlJS::SourceLocation(pos, len, line, col));
}
QList<SourceLocation> comments() const { return _comments; }
const QList<SourceLocation> comments() const { return _comments; }
Lexer *lexer() const { return _lexer; }
void setLexer(Lexer *lexer) { _lexer = lexer; }

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
// This file was generated by qlalr - DO NOT EDIT!
#ifndef QMLJSGRAMMAR_P_H
#define QMLJSGRAMMAR_P_H
@@ -10,7 +10,7 @@ class QML_PARSER_EXPORT QmlJSGrammar
public:
enum VariousConstants {
EOF_SYMBOL = 0,
REDUCE_HERE = 132,
REDUCE_HERE = 139,
T_AND = 1,
T_AND_AND = 2,
T_AND_EQ = 3,
@@ -39,24 +39,25 @@ public:
T_ELLIPSIS = 100,
T_ELSE = 16,
T_ENUM = 99,
T_EOL = 123,
T_EQ = 17,
T_EQ_EQ = 18,
T_EQ_EQ_EQ = 19,
T_ERROR = 121,
T_ERROR = 122,
T_EXPORT = 106,
T_EXTENDS = 104,
T_FALSE = 87,
T_FEED_JS_EXPRESSION = 125,
T_FEED_JS_MODULE = 127,
T_FEED_JS_SCRIPT = 126,
T_FEED_JS_STATEMENT = 124,
T_FEED_UI_OBJECT_MEMBER = 123,
T_FEED_UI_PROGRAM = 122,
T_FEED_JS_EXPRESSION = 132,
T_FEED_JS_MODULE = 134,
T_FEED_JS_SCRIPT = 133,
T_FEED_JS_STATEMENT = 131,
T_FEED_UI_OBJECT_MEMBER = 130,
T_FEED_UI_PROGRAM = 129,
T_FINALLY = 20,
T_FOR = 21,
T_FORCE_BLOCK = 129,
T_FORCE_DECLARATION = 128,
T_FOR_LOOKAHEAD_OK = 130,
T_FORCE_BLOCK = 136,
T_FORCE_DECLARATION = 135,
T_FOR_LOOKAHEAD_OK = 137,
T_FROM = 107,
T_FUNCTION = 23,
T_FUNCTION_STAR = 22,
@@ -85,6 +86,7 @@ public:
T_MINUS_MINUS = 43,
T_MULTILINE_STRING_LITERAL = 93,
T_NEW = 44,
T_NONE = 121,
T_NOT = 45,
T_NOT_EQ = 46,
T_NOT_EQ_EQ = 47,
@@ -92,10 +94,15 @@ public:
T_NULL = 85,
T_NUMERIC_LITERAL = 48,
T_OF = 118,
T_ON = 131,
T_ON = 138,
T_OR = 49,
T_OR_EQ = 51,
T_OR_OR = 52,
T_PARTIAL_COMMENT = 124,
T_PARTIAL_DOUBLE_QUOTE_STRING_LITERAL = 126,
T_PARTIAL_SINGLE_QUOTE_STRING_LITERAL = 125,
T_PARTIAL_TEMPLATE_HEAD = 127,
T_PARTIAL_TEMPLATE_MIDDLE = 128,
T_PLUS = 53,
T_PLUS_EQ = 54,
T_PLUS_PLUS = 55,
@@ -128,7 +135,7 @@ public:
T_TEMPLATE_HEAD = 111,
T_TEMPLATE_MIDDLE = 112,
T_TEMPLATE_TAIL = 113,
T_THEN = 133,
T_THEN = 140,
T_THIS = 74,
T_THROW = 75,
T_TILDE = 76,
@@ -140,20 +147,20 @@ public:
T_VOID = 80,
T_WHILE = 81,
T_WITH = 82,
T_WITHOUTAS = 134,
T_WITHOUTAS = 141,
T_XOR = 83,
T_XOR_EQ = 84,
T_YIELD = 101,
ACCEPT_STATE = 1087,
RULE_COUNT = 617,
STATE_COUNT = 1088,
TERMINAL_COUNT = 135,
NON_TERMINAL_COUNT = 240,
ACCEPT_STATE = 1104,
RULE_COUNT = 620,
STATE_COUNT = 1105,
TERMINAL_COUNT = 142,
NON_TERMINAL_COUNT = 239,
GOTO_INDEX_OFFSET = 1088,
GOTO_INFO_OFFSET = 7358,
GOTO_CHECK_OFFSET = 7358
GOTO_INDEX_OFFSET = 1105,
GOTO_INFO_OFFSET = 7893,
GOTO_CHECK_OFFSET = 7893
};
static const char *const spell[];

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -22,6 +22,8 @@
QT_QML_BEGIN_NAMESPACE
class QDebug;
namespace QmlJS {
class Engine;
@@ -92,8 +94,12 @@ public:
NoQmlImport
};
enum class LexMode { WholeCode, LineByLine };
enum class CodeContinuation { Reset, Continue };
public:
Lexer(Engine *engine);
Lexer(Engine *engine, LexMode lexMode = LexMode::WholeCode);
int parseModeFlags() const {
int flags = 0;
@@ -107,22 +113,25 @@ public:
}
bool qmlMode() const;
bool yieldIsKeyWord() const { return _generatorLevel != 0; }
bool yieldIsKeyWord() const { return _state.generatorLevel != 0; }
void setStaticIsKeyword(bool b) { _staticIsKeyword = b; }
QString code() const;
void setCode(const QString &code, int lineno, bool qmlMode = true);
void setCode(const QString &code,
int lineno,
bool qmlMode = true,
CodeContinuation codeContinuation = CodeContinuation::Reset);
int lex();
bool scanRegExp(RegExpBodyPrefix prefix = NoPrefix);
bool scanDirectives(Directives *directives, DiagnosticMessage *error);
int regExpFlags() const { return _patternFlags; }
int regExpFlags() const { return _state.patternFlags; }
QString regExpPattern() const { return _tokenText; }
int tokenKind() const { return _tokenKind; }
int tokenOffset() const { return _tokenStartPtr - _code.unicode(); }
int tokenKind() const { return _state.tokenKind; }
int tokenOffset() const { return _currentOffset + _tokenStartPtr - _code.unicode(); }
int tokenLength() const { return _tokenLength; }
int tokenStartLine() const { return _tokenLine; }
@@ -130,7 +139,7 @@ public:
inline QStringView tokenSpell() const { return _tokenSpell; }
inline QStringView rawString() const { return _rawString; }
double tokenValue() const { return _tokenValue; }
double tokenValue() const { return _state.tokenValue; }
QString tokenText() const;
Error errorCode() const;
@@ -146,8 +155,92 @@ public:
BalancedParentheses
};
void enterGeneratorBody() { ++_generatorLevel; }
void leaveGeneratorBody() { --_generatorLevel; }
enum class CommentState { NoComment, HadComment, InMultilineComment };
void enterGeneratorBody() { ++_state.generatorLevel; }
void leaveGeneratorBody() { --_state.generatorLevel; }
struct State
{
Error errorCode = NoError;
QChar currentChar = u'\n';
double tokenValue = 0;
// parentheses state
ParenthesesState parenthesesState = IgnoreParentheses;
int parenthesesCount = 0;
// template string stack
QStack<int> outerTemplateBraceCount;
int bracesCount = -1;
int stackToken = -1;
int patternFlags = 0;
int tokenKind = 0;
ImportState importState = ImportState::NoQmlImport;
bool validTokenText = false;
bool prohibitAutomaticSemicolon = false;
bool restrictedKeyword = false;
bool terminator = false;
bool followsClosingBrace = false;
bool delimited = true;
bool handlingDirectives = false;
CommentState comments = CommentState::NoComment;
int generatorLevel = 0;
friend bool operator==(State const &s1, State const &s2)
{
if (s1.errorCode != s2.errorCode)
return false;
if (s1.currentChar != s2.currentChar)
return false;
if (s1.tokenValue != s2.tokenValue)
return false;
if (s1.parenthesesState != s2.parenthesesState)
return false;
if (s1.parenthesesCount != s2.parenthesesCount)
return false;
if (s1.outerTemplateBraceCount != s2.outerTemplateBraceCount)
return false;
if (s1.bracesCount != s2.bracesCount)
return false;
if (s1.stackToken != s2.stackToken)
return false;
if (s1.patternFlags != s2.patternFlags)
return false;
if (s1.tokenKind != s2.tokenKind)
return false;
if (s1.importState != s2.importState)
return false;
if (s1.validTokenText != s2.validTokenText)
return false;
if (s1.prohibitAutomaticSemicolon != s2.prohibitAutomaticSemicolon)
return false;
if (s1.restrictedKeyword != s2.restrictedKeyword)
return false;
if (s1.terminator != s2.terminator)
return false;
if (s1.followsClosingBrace != s2.followsClosingBrace)
return false;
if (s1.delimited != s2.delimited)
return false;
if (s1.handlingDirectives != s2.handlingDirectives)
return false;
if (s1.generatorLevel != s2.generatorLevel)
return false;
return true;
}
friend bool operator!=(State const &s1, State const &s2) { return !(s1 == s2); }
friend QML_PARSER_EXPORT QDebug operator<<(QDebug dbg, State const &s);
};
const State &state() const;
void setState(const State &state);
protected:
static int classify(const QChar *s, int n, int parseModeFlags);
@@ -177,54 +270,36 @@ private:
uint decodeUnicodeEscapeCharacter(bool *ok);
QChar decodeHexEscapeCharacter(bool *ok);
friend QML_PARSER_EXPORT QDebug operator<<(QDebug dbg, const Lexer &l);
private:
Engine *_engine;
LexMode _lexMode = LexMode::WholeCode;
QString _code;
const QChar *_endPtr;
bool _qmlMode;
bool _staticIsKeyword = false;
bool _skipLinefeed = false;
int _currentLineNumber = 0;
int _currentColumnNumber = 0;
int _currentOffset = 0;
int _tokenLength = 0;
int _tokenLine = 0;
int _tokenColumn = 0;
QString _tokenText;
QString _errorMessage;
QStringView _tokenSpell;
QStringView _rawString;
const QChar *_codePtr;
const QChar *_endPtr;
const QChar *_tokenStartPtr;
const QChar *_codePtr = nullptr;
const QChar *_tokenStartPtr = nullptr;
QChar _char;
Error _errorCode;
int _currentLineNumber;
int _currentColumnNumber;
double _tokenValue;
// parentheses state
ParenthesesState _parenthesesState;
int _parenthesesCount;
// template string stack
QStack<int> _outerTemplateBraceCount;
int _bracesCount = -1;
int _stackToken;
int _patternFlags;
int _tokenKind;
int _tokenLength;
int _tokenLine;
int _tokenColumn;
ImportState _importState = ImportState::NoQmlImport;
bool _validTokenText;
bool _prohibitAutomaticSemicolon;
bool _restrictedKeyword;
bool _terminator;
bool _followsClosingBrace;
bool _delimited;
bool _qmlMode;
bool _skipLinefeed = false;
int _generatorLevel = 0;
bool _staticIsKeyword = false;
bool _handlingDirectives = false;
State _state;
};
} // end of namespace QmlJS

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,7 @@
#line 126 "qmljs.g"
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
//
@@ -86,7 +88,7 @@ public:
AST::ExportClause *ExportClause;
AST::ExportDeclaration *ExportDeclaration;
AST::TypeAnnotation *TypeAnnotation;
AST::TypeArgumentList *TypeArgumentList;
AST::TypeArgument *TypeArgument;
AST::Type *Type;
AST::UiProgram *UiProgram;
@@ -160,7 +162,7 @@ public:
inline DiagnosticMessage diagnosticMessage() const
{
for (const DiagnosticMessage &d : diagnostic_messages) {
if (d.kind != Severity::Warning)
if (d.isWarning())
return d;
}
@@ -253,6 +255,7 @@ protected:
SavedToken *last_token = nullptr;
int functionNestingLevel = 0;
int classNestingLevel = 0;
enum CoverExpressionType {
CE_Invalid,
@@ -267,27 +270,27 @@ protected:
} // end of namespace QmlJS
#line 1819 "qmljs.g"
#line 1769 "qmljs.g"
#define J_SCRIPT_REGEXPLITERAL_RULE1 159
#define J_SCRIPT_REGEXPLITERAL_RULE1 163
#line 1831 "qmljs.g"
#line 1781 "qmljs.g"
#define J_SCRIPT_REGEXPLITERAL_RULE2 160
#define J_SCRIPT_REGEXPLITERAL_RULE2 164
#line 3451 "qmljs.g"
#line 3401 "qmljs.g"
#define J_SCRIPT_EXPRESSIONSTATEMENTLOOKAHEAD_RULE 461
#define J_SCRIPT_EXPRESSIONSTATEMENTLOOKAHEAD_RULE 465
#line 4103 "qmljs.g"
#line 4053 "qmljs.g"
#define J_SCRIPT_CONCISEBODYLOOKAHEAD_RULE 531
#define J_SCRIPT_CONCISEBODYLOOKAHEAD_RULE 535
#line 4645 "qmljs.g"
#line 4594 "qmljs.g"
#define J_SCRIPT_EXPORTDECLARATIONLOOKAHEAD_RULE 600
#define J_SCRIPT_EXPORTDECLARATIONLOOKAHEAD_RULE 603
#line 4929 "qmljs.g"
#line 4878 "qmljs.g"
QT_QML_END_NAMESPACE

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
/*!
\class QmlJS::PersistentTrie::Trie
@@ -96,7 +96,7 @@ void TrieNode::complete(QStringList &res, const TrieNode::Ptr &trie,
complete(res, trie->postfixes[0],QString(), base2, flags);
return;
}
foreach (TrieNode::Ptr t, trie->postfixes) {
for (TrieNode::Ptr t : std::as_const(trie->postfixes)) {
if ((flags & Partial) != 0)
res.append(base2 + t->prefix);
else
@@ -104,7 +104,7 @@ void TrieNode::complete(QStringList &res, const TrieNode::Ptr &trie,
}
return;
}
foreach (const TrieNode::Ptr v, trie->postfixes) {
for (const TrieNode::Ptr &v : std::as_const(trie->postfixes)) {
QString::const_iterator vi = v->prefix.constBegin(), vEnd = v->prefix.constEnd();
if (vi != vEnd && (*vi == *j || ((flags & CaseInsensitive) != 0
&& vi->toLower() == j->toLower()) || ((flags & SkipChars) != 0)))
@@ -199,7 +199,7 @@ bool TrieNode::contains(const TrieNode::Ptr &trie,
if ((flags & Partial) != 0)
return true;
if (i == iEnd) {
foreach (const TrieNode::Ptr t, trie->postfixes)
for (const TrieNode::Ptr &t : std::as_const(trie->postfixes))
if (t->prefix.isEmpty())
return true;
return trie->postfixes.isEmpty();
@@ -209,7 +209,7 @@ bool TrieNode::contains(const TrieNode::Ptr &trie,
if (i != iEnd)
return false;
bool res = false;
foreach (const TrieNode::Ptr v, trie->postfixes) {
for (const TrieNode::Ptr &v : std::as_const(trie->postfixes)) {
QString::const_iterator vi = v->prefix.constBegin(), vEnd = v->prefix.constEnd();
if (vi != vEnd && (*vi == *j || ((flags & CaseInsensitive) != 0
&& vi->toLower() == j->toLower())))
@@ -312,7 +312,7 @@ std::pair<TrieNode::Ptr,int> TrieNode::intersectF(
if (v1->postfixes.isEmpty() || v2->postfixes.isEmpty()) {
if (v1->postfixes.isEmpty() && v2->postfixes.isEmpty())
return std::make_pair(v1, 3);
foreach (P t1, v1->postfixes)
for (P t1 : std::as_const(v1->postfixes))
if (t1->prefix.isEmpty()) {
if (index1 == 0)
return std::make_pair(v2, 2);
@@ -320,7 +320,7 @@ std::pair<TrieNode::Ptr,int> TrieNode::intersectF(
return std::make_pair(TrieNode::create(
v1->prefix.left(index1).append(v2->prefix), v2->postfixes),0);
}
foreach (P t2, v2->postfixes)
for (P t2 : std::as_const(v2->postfixes))
if (t2->prefix.isEmpty())
return std::make_pair(v1,1);
return std::make_pair(P(nullptr), 0);
@@ -328,10 +328,10 @@ std::pair<TrieNode::Ptr,int> TrieNode::intersectF(
QMap<QString,int> p1, p2;
QList<P> p3;
int ii = 0;
foreach (P t1, v1->postfixes)
for (P t1 : std::as_const(v1->postfixes))
p1[t1->prefix] = ii++;
ii = 0;
foreach (P t2, v2->postfixes)
for (P t2 : std::as_const(v2->postfixes))
p2[t2->prefix] = ii++;
MapIterator p1Ptr = p1.constBegin(), p2Ptr = p2.constBegin(),
p1End = p1.constEnd(), p2End = p2.constEnd();
@@ -419,7 +419,7 @@ std::pair<TrieNode::Ptr,int> TrieNode::intersectF(
}
}
// i == iEnd && j != jEnd
foreach (const P &t1, v1->postfixes)
for (const P &t1 : std::as_const(v1->postfixes))
if ((!t1->prefix.isEmpty()) && t1->prefix.at(0) == *j) {
std::pair<P,int> res = intersectF(v2,t1,j-v2->prefix.constBegin());
if (index1 == 0)
@@ -432,7 +432,7 @@ std::pair<TrieNode::Ptr,int> TrieNode::intersectF(
return std::make_pair(P(nullptr), 0);
} else {
// i != iEnd && j == jEnd
foreach (P t2, v2->postfixes)
for (P t2 : std::as_const(v2->postfixes))
if (!t2->prefix.isEmpty() && t2->prefix.at(0) == *i) {
std::pair<P,int> res = intersectF(v1,t2,i-v1->prefix.constBegin());
return std::make_pair(res.first, (res.second & 1));
@@ -468,7 +468,8 @@ QDebug &TrieNode::printStrings(QDebug &dbg, const TrieNode::Ptr &trie)
return dbg << "Trie{*NULL*}";
dbg<<"Trie{ contents:[";
bool first = true;
foreach (const QString &s, stringList(trie)) {
const QStringList list = stringList(trie);
for (const QString &s : list) {
if (!first)
dbg << ",";
else
@@ -491,7 +492,7 @@ QDebug &TrieNode::describe(QDebug &dbg, const TrieNode::Ptr &trie,
dbg << trie->prefix;
int newIndent = indent + trie->prefix.size() + 3;
bool newLine = false;
foreach (TrieNode::Ptr sub, trie->postfixes) {
for (TrieNode::Ptr sub : std::as_const(trie->postfixes)) {
if (newLine) {
dbg << "\n";
for (int i=0; i < newIndent; ++i)

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -88,7 +88,7 @@ template <typename T> void enumerateTrieNode(const TrieNode::Ptr &trie, T &t,
if (trie.isNull())
return;
base.append(trie->prefix);
foreach (const TrieNode::Ptr subT, trie->postfixes) {
for (const TrieNode::Ptr &subT : std::as_const(trie->postfixes)) {
enumerateTrieNode(subT,t,base);
}
if (trie->postfixes.isEmpty())

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,11 +1,14 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsbind.h"
#include "parser/qmljsast_p.h"
#include "qmljsutils.h"
#include "qmljsdocument.h"
#include "qmljsmodelmanagerinterface.h"
#include "qmljstr.h"
#include "qmljsutils.h"
#include <QtCore/QVersionNumber>
#include <QtCore/QLibraryInfo>
@@ -54,7 +57,7 @@ bool Bind::isJsLibrary() const
return _isJsLibrary;
}
QList<ImportInfo> Bind::imports() const
const QList<ImportInfo> Bind::imports() const
{
return _imports;
}
@@ -86,7 +89,8 @@ bool Bind::usesQmlPrototype(ObjectValue *prototype,
if (componentName.isEmpty())
return false;
foreach (const ObjectValue *object, _qmlObjectsByPrototypeName.values(componentName)) {
QList<const ObjectValue *> values = _qmlObjectsByPrototypeName.values(componentName);
for (const ObjectValue *object : values) {
// resolve and check the prototype
const ObjectValue *resolvedPrototype = object->prototype(context);
if (resolvedPrototype == prototype)
@@ -163,7 +167,8 @@ ObjectValue *Bind::bindObject(UiQualifiedId *qualifiedTypeNameId, UiObjectInitia
void Bind::throwRecursionDepthError()
{
_diagnosticMessages->append(DiagnosticMessage(Severity::Error, SourceLocation(), tr("Hit maximal recursion depth in AST visit.")));
_diagnosticMessages->append(DiagnosticMessage(Severity::Error, SourceLocation(),
Tr::tr("Hit maximal recursion depth in AST visit.")));
}
void Bind::accept(Node *node)
@@ -211,7 +216,7 @@ bool Bind::visit(UiImport *ast)
}
if (!version.isValid() && (!qtVersion.isNull() && qtVersion.majorVersion() < 6)) {
_diagnosticMessages->append(
errorMessage(ast, tr("package import requires a version number")));
errorMessage(ast, Tr::tr("package import requires a version number")));
}
const QString importId = ast->importId.toString();
@@ -321,7 +326,7 @@ bool Bind::visit(UiInlineComponent *ast)
if (!_currentComponentName.isEmpty()) {
_currentComponentName += ".";
_diagnosticMessages->append(
errorMessage(ast, tr("Nested inline components are not supported")));
errorMessage(ast, Tr::tr("Nested inline components are not supported")));
}
_currentComponentName += ast->name.toString();
_rootObjectValue = nullptr;

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -17,7 +17,6 @@ class Document;
class QMLJS_EXPORT Bind: protected AST::Visitor
{
Q_DISABLE_COPY(Bind)
Q_DECLARE_TR_FUNCTIONS(QmlJS::Bind)
public:
Bind(Document *doc, QList<DiagnosticMessage> *messages,
@@ -25,7 +24,7 @@ public:
~Bind();
bool isJsLibrary() const;
QList<ImportInfo> imports() const;
const QList<ImportInfo> imports() const;
ObjectValue *idEnvironment() const;
ObjectValue *rootObjectValue() const;

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsbundle.h"
@@ -142,7 +142,8 @@ void QmlBundle::printEscaped(QTextStream &s, const QString &str)
void QmlBundle::writeTrie(QTextStream &stream, const Trie &t, const QString &indent) {
stream << QLatin1Char('[');
bool firstLine = true;
foreach (const QString &i, t.stringList()) {
const QStringList list = t.stringList();
for (const QString &i : list) {
if (firstLine)
firstLine = false;
else
@@ -197,7 +198,8 @@ QStringList QmlBundle::maybeReadTrie(Trie &trie, Utils::JsonObjectValue *config,
Utils::JsonValue *imp0 = config->member(propertyName);
Utils::JsonArrayValue *imp = ((imp0 != nullptr) ? imp0->toArray() : nullptr);
if (imp != nullptr) {
foreach (Utils::JsonValue *v, imp->elements()) {
const QList<Utils::JsonValue *> elements = imp->elements();
for (Utils::JsonValue *v : elements) {
Utils::JsonStringValue *impStr = ((v != nullptr) ? v->toString() : nullptr);
if (impStr != nullptr) {
trie.insert(impStr->value());
@@ -272,14 +274,14 @@ void QmlLanguageBundles::mergeBundleForLanguage(Dialect l, const QmlBundle &bund
m_bundles.insert(l,bundle);
}
QList<Dialect> QmlLanguageBundles::languages() const
const QList<Dialect> QmlLanguageBundles::languages() const
{
return m_bundles.keys();
}
void QmlLanguageBundles::mergeLanguageBundles(const QmlLanguageBundles &o)
{
foreach (Dialect l, o.languages())
for (Dialect l : o.languages())
mergeBundleForLanguage(l, o.bundleForLanguage(l));
}

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -74,7 +74,7 @@ class QMLJS_EXPORT QmlLanguageBundles
public:
QmlBundle bundleForLanguage(Dialect l) const;
void mergeBundleForLanguage(Dialect l, const QmlBundle &bundle);
QList<Dialect> languages() const;
const QList<Dialect> languages() const;
void mergeLanguageBundles(const QmlLanguageBundles &);
private:
QHash<Dialect,QmlBundle> m_bundles;

View File

@@ -1,10 +1,13 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljscheck.h"
#include "qmljsbind.h"
#include "qmljsevaluate.h"
#include "qmljstr.h"
#include "qmljsutils.h"
#include "parser/qmljsast_p.h"
#include <utils/algorithm.h>
@@ -433,7 +436,8 @@ protected:
}
if (_possiblyUndeclaredUses.contains(name)) {
foreach (const SourceLocation &loc, _possiblyUndeclaredUses.value(name)) {
const QList<SourceLocation> values = _possiblyUndeclaredUses.value(name);
for (const SourceLocation &loc : values) {
addMessage(WarnVarUsedBeforeDeclaration, loc, name);
}
_possiblyUndeclaredUses.remove(name);
@@ -469,7 +473,8 @@ protected:
if (FunctionDeclaration *decl = cast<FunctionDeclaration *>(ast)) {
if (_possiblyUndeclaredUses.contains(name)) {
foreach (const SourceLocation &loc, _possiblyUndeclaredUses.value(name)) {
const QList<SourceLocation> values = _possiblyUndeclaredUses.value(name);
for (const SourceLocation &loc : values) {
addMessage(WarnFunctionUsedBeforeDeclaration, loc, name);
}
_possiblyUndeclaredUses.remove(name);
@@ -1159,7 +1164,7 @@ bool Check::visit(UiPublicMember *ast)
const Value *init = evaluator(ast->statement);
QString preferredType;
if (init->asNumberValue())
preferredType = tr("'int' or 'real'");
preferredType = Tr::tr("'int' or 'real'");
else if (init->asStringValue())
preferredType = "'string'";
else if (init->asBooleanValue())
@@ -1214,7 +1219,7 @@ bool Check::visit(IdentifierExpression *)
// if (const Reference *ref = value_cast<Reference>(_lastValue)) {
// _lastValue = _context->lookupReference(ref);
// if (!_lastValue)
// error(ast->identifierToken, tr("could not resolve"));
// error(ast->identifierToken, Tr::tr("could not resolve"));
// }
// }
// return false;
@@ -1231,7 +1236,7 @@ bool Check::visit(FieldMemberExpression *)
// const ObjectValue *obj = _lastValue->asObjectValue();
// if (!obj) {
// error(locationFromRange(ast->base->firstSourceLocation(), ast->base->lastSourceLocation()),
// tr("does not have members"));
// Tr::tr("does not have members"));
// }
// if (!obj || ast->name.isEmpty()) {
// _lastValue = 0;
@@ -1239,7 +1244,7 @@ bool Check::visit(FieldMemberExpression *)
// }
// _lastValue = obj->lookupMember(ast->name.toString(), _context);
// if (!_lastValue)
// error(ast->identifierToken, tr("unknown member"));
// error(ast->identifierToken, Tr::tr("unknown member"));
// return false;
}
@@ -1642,7 +1647,7 @@ void Check::checkExtraParentheses(ExpressionNode *expression)
void Check::addMessages(const QList<Message> &messages)
{
foreach (const Message &msg, messages)
for (const Message &msg : messages)
addMessage(msg);
}
@@ -1682,7 +1687,8 @@ void Check::scanCommentsForAnnotations()
m_disabledMessageTypesByLine.clear();
const QRegularExpression disableCommentPattern = Message::suppressionPattern();
foreach (const SourceLocation &commentLoc, _doc->engine()->comments()) {
const QList<SourceLocation> comments = _doc->engine()->comments();
for (const SourceLocation &commentLoc : comments) {
const QString &comment = _doc->source().mid(int(commentLoc.begin()), int(commentLoc.length));
// enable all checks annotation
@@ -1728,7 +1734,7 @@ void Check::warnAboutUnnecessarySuppressions()
{
for (auto it = m_disabledMessageTypesByLine.cbegin(), end = m_disabledMessageTypesByLine.cend();
it != end; ++it) {
foreach (const MessageTypeAndSuppression &entry, it.value()) {
for (const MessageTypeAndSuppression &entry : it.value()) {
if (!entry.wasSuppressed)
addMessage(WarnUnnecessaryMessageSuppression, entry.suppressionSource);
}
@@ -1738,7 +1744,7 @@ void Check::warnAboutUnnecessarySuppressions()
bool Check::isQtQuick2() const
{
if (_doc->language() == Dialect::Qml) {
foreach (const Import &import, _imports->all()) {
for (const Import &import : _imports->all()) {
if (import.info.name() == "QtQuick"
&& import.info.version().majorVersion() == 2)
return true;
@@ -2069,7 +2075,7 @@ void Check::checkCaseFallthrough(StatementList *statements, SourceLocation error
afterLastStatement = it->statement->lastSourceLocation().end();
}
foreach (const SourceLocation &comment, _doc->engine()->comments()) {
for (const SourceLocation &comment : _doc->engine()->comments()) {
if (comment.begin() < afterLastStatement
|| comment.end() > nextLoc.begin())
continue;

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -18,8 +18,6 @@ class Imports;
class QMLJS_EXPORT Check: protected AST::Visitor
{
Q_DECLARE_TR_FUNCTIONS(QmlJS::Check)
typedef QSet<QString> StringSet;
public:

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljscodeformatter.h"
@@ -1023,7 +1023,7 @@ void CodeFormatter::dump() const
{
qCDebug(formatterLog) << "Current token index" << m_tokenIndex;
qCDebug(formatterLog) << "Current state:";
foreach (const State &s, m_currentState) {
for (const State &s : m_currentState) {
qCDebug(formatterLog) << stateToString(s.type) << s.savedIndentDepth;
}
qCDebug(formatterLog) << "Current indent depth:" << m_indentDepth;

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljscompletioncontextfinder.h"
#include "qmljsscanner.h"

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljscontext.h"

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsdialect.h"
#include "qmljsconstants.h"

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsdocument.h"
#include "qmljsbind.h"
@@ -372,7 +372,7 @@ QByteArray LibraryInfo::calculateFingerprint() const
hash.addData(reinterpret_cast<const char *>(&_status), sizeof(_status));
int len = _components.size();
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
foreach (const QmlDirParser::Component &component, _components) {
for (const QmlDirParser::Component &component : _components) {
len = component.fileName.size();
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
hash.addData(reinterpret_cast<const char *>(component.fileName.constData()),
@@ -388,7 +388,7 @@ QByteArray LibraryInfo::calculateFingerprint() const
}
len = _plugins.size();
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
foreach (const QmlDirParser::Plugin &plugin, _plugins) {
for (const QmlDirParser::Plugin &plugin : _plugins) {
len = plugin.path.size();
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
hash.addData(reinterpret_cast<const char *>(plugin.path.constData()), len * sizeofQChar);
@@ -398,7 +398,7 @@ QByteArray LibraryInfo::calculateFingerprint() const
}
len = _typeinfos.size();
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
foreach (const QString &typeinfo, _typeinfos) {
for (const QString &typeinfo : _typeinfos) {
len = typeinfo.size();
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
hash.addData(reinterpret_cast<const char *>(typeinfo.constData()),
@@ -407,10 +407,10 @@ QByteArray LibraryInfo::calculateFingerprint() const
len = _metaObjects.size();
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
QList<QByteArray> metaFingerprints;
foreach (const LanguageUtils::FakeMetaObject::ConstPtr &metaObject, _metaObjects)
for (const LanguageUtils::FakeMetaObject::ConstPtr &metaObject : _metaObjects)
metaFingerprints.append(metaObject->fingerprint());
std::sort(metaFingerprints.begin(), metaFingerprints.end());
foreach (const QByteArray &fp, metaFingerprints)
for (const QByteArray &fp : std::as_const(metaFingerprints))
hash.addData(fp);
hash.addData(reinterpret_cast<const char *>(&_dumpStatus), sizeof(_dumpStatus));
len = _dumpError.size(); // localization dependent (avoid?)
@@ -419,12 +419,12 @@ QByteArray LibraryInfo::calculateFingerprint() const
len = _moduleApis.size();
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
foreach (const ModuleApiInfo &moduleInfo, _moduleApis)
for (const ModuleApiInfo &moduleInfo : _moduleApis)
moduleInfo.addToHash(hash); // make it order independent?
len = _imports.size();
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
foreach (const QmlDirParser::Import &import, _imports)
for (const QmlDirParser::Import &import : _imports)
hash.addData(import.module.toUtf8()); // import order matters, keep order-dependent
QByteArray res(hash.result());
@@ -473,13 +473,14 @@ void Snapshot::insertLibraryInfo(const Utils::FilePath &path, const LibraryInfo
cImport.importId = path.toString();
cImport.language = Dialect::AnyLanguage;
QSet<ImportKey> packages;
foreach (const ModuleApiInfo &moduleInfo, info.moduleApis()) {
for (const ModuleApiInfo &moduleInfo : info.moduleApis()) {
ImportKey iKey(ImportType::Library, moduleInfo.uri, moduleInfo.version.majorVersion(),
moduleInfo.version.minorVersion());
packages.insert(iKey);
}
foreach (const LanguageUtils::FakeMetaObject::ConstPtr &metaO, info.metaObjects()) {
foreach (const LanguageUtils::FakeMetaObject::Export &e, metaO->exports()) {
const QList<LanguageUtils::FakeMetaObject::ConstPtr> metaObjects = info.metaObjects();
for (const LanguageUtils::FakeMetaObject::ConstPtr &metaO : metaObjects) {
for (const LanguageUtils::FakeMetaObject::Export &e : metaO->exports()) {
ImportKey iKey(ImportType::Library, e.package, e.version.majorVersion(),
e.version.minorVersion());
packages.insert(iKey);
@@ -489,7 +490,7 @@ void Snapshot::insertLibraryInfo(const Utils::FilePath &path, const LibraryInfo
QStringList splitPath = path.path().split(QLatin1Char('/'));
const QRegularExpression vNr(QLatin1String("^(.+)\\.([0-9]+)(?:\\.([0-9]+))?$"));
const QRegularExpression safeName(QLatin1String("^[a-zA-Z_][[a-zA-Z0-9_]*$"));
foreach (const ImportKey &importKey, packages) {
for (const ImportKey &importKey : std::as_const(packages)) {
if (importKey.splitPath.size() == 1 && importKey.splitPath.at(0).isEmpty() && splitPath.length() > 0) {
// relocatable
QStringList myPath = splitPath;
@@ -522,7 +523,7 @@ void Snapshot::insertLibraryInfo(const Utils::FilePath &path, const LibraryInfo
int majorVersion = LanguageUtils::ComponentVersion::NoVersion;
int minorVersion = LanguageUtils::ComponentVersion::NoVersion;
foreach (const QmlDirParser::Component &component, info.components()) {
for (const QmlDirParser::Component &component : info.components()) {
if (component.majorVersion > majorVersion)
majorVersion = component.majorVersion;
if (component.minorVersion > minorVersion)
@@ -555,8 +556,8 @@ void Snapshot::insertLibraryInfo(const Utils::FilePath &path, const LibraryInfo
cImport.addPossibleExport(Export(iKey, newP, true));
}
}
foreach (const QmlDirParser::Component &component, info.components()) {
foreach (const Export &e, cImport.possibleExports)
for (const QmlDirParser::Component &component : info.components()) {
for (const Export &e : std::as_const(cImport.possibleExports))
_dependencies.addExport(component.fileName, e.exportName, e.pathRequired, e.typeName);
}

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -154,13 +154,13 @@ public:
QByteArray fingerprint() const
{ return _fingerprint; }
QList<QmlDirParser::Component> components() const
const QList<QmlDirParser::Component> components() const
{ return _components; }
QList<QmlDirParser::Plugin> plugins() const
{ return _plugins; }
QStringList typeInfos() const
const QStringList typeInfos() const
{ return _typeinfos; }
FakeMetaObjectList metaObjects() const
@@ -169,7 +169,7 @@ public:
void setMetaObjects(const FakeMetaObjectList &objects)
{ _metaObjects = objects; }
QList<ModuleApiInfo> moduleApis() const
const QList<ModuleApiInfo> moduleApis() const
{ return _moduleApis; }
void setModuleApis(const QList<ModuleApiInfo> &apis)

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsevaluate.h"
#include "qmljscontext.h"

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,10 +1,12 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsfindexportedcpptypes.h"
#include <qmljs/qmljsinterpreter.h>
#include <qmljs/qmljsdocument.h>
#include "qmljsdocument.h"
#include "qmljsinterpreter.h"
#include "qmljstr.h"
#include <cplusplus/Overview.h>
#include <cplusplus/TypeOfExpression.h>
#include <cplusplus/cppmodelmanagerbase.h>
@@ -248,9 +250,9 @@ protected:
translationUnit()->getTokenStartPosition(nameExp->firstToken(), &line, &column);
_messages += Document::DiagnosticMessage(
Document::DiagnosticMessage::Warning,
_doc->fileName(),
_doc->filePath(),
line, column,
QmlJS::FindExportedCppTypes::tr(
QmlJS::Tr::tr(
"The type will only be available in the QML editors when the type name is a string literal."));
return false;
}
@@ -309,9 +311,9 @@ protected:
translationUnit()->getTokenStartPosition(ast->firstToken(), &line, &column);
_messages += Document::DiagnosticMessage(
Document::DiagnosticMessage::Warning,
_doc->fileName(),
_doc->filePath(),
line, column,
QmlJS::FindExportedCppTypes::tr(
QmlJS::Tr::tr(
"The module URI cannot be determined by static analysis. The type will not be available\n"
"globally in the QML editor. You can add a \"// @uri My.Module.Uri\" annotation to let\n"
"the QML editor know about a likely URI."));
@@ -491,9 +493,9 @@ protected:
translationUnit()->getTokenStartPosition(ast->expression_list->value->firstToken(), &line, &column);
_messages += Document::DiagnosticMessage(
Document::DiagnosticMessage::Warning,
_doc->fileName(),
_doc->filePath(),
line, column,
QmlJS::FindExportedCppTypes::tr(
QmlJS::Tr::tr(
"must be a string literal to be available in the QML editor"));
return false;
}
@@ -637,9 +639,9 @@ static QString toQmlType(const FullySpecifiedType &type)
static Class *lookupClass(const QString &expression, Scope *scope, TypeOfExpression &typeOf)
{
QList<LookupItem> results = typeOf(expression.toUtf8(), scope);
const QList<LookupItem> results = typeOf(expression.toUtf8(), scope);
Class *klass = nullptr;
foreach (const LookupItem &item, results) {
for (const LookupItem &item : results) {
if (item.declaration()) {
klass = item.declaration()->asClass();
if (klass)
@@ -707,8 +709,8 @@ static LanguageUtils::FakeMetaObject::Ptr buildFakeMetaObject(
if (QtEnum *qtEnum = member->asQtEnum()) {
// find the matching enum
Enum *e = nullptr;
QList<LookupItem> result = typeOf(namePrinter.prettyName(qtEnum->name()).toUtf8(), klass);
foreach (const LookupItem &item, result) {
const QList<LookupItem> result = typeOf(namePrinter.prettyName(qtEnum->name()).toUtf8(), klass);
for (const LookupItem &item : result) {
if (item.declaration()) {
e = item.declaration()->asEnum();
if (e)
@@ -757,7 +759,7 @@ static void buildExportedQmlObjects(
if (cppExports.isEmpty())
return;
foreach (const ExportedQmlType &exportedType, cppExports) {
for (const ExportedQmlType &exportedType : cppExports) {
Class *klass = nullptr;
if (!exportedType.typeExpression.isEmpty())
klass = lookupClass(exportedType.typeExpression, exportedType.scope, typeOf);
@@ -785,7 +787,7 @@ static void buildContextProperties(
{
using namespace LanguageUtils;
foreach (const ContextProperty &property, contextPropertyDescriptions) {
for (const ContextProperty &property : contextPropertyDescriptions) {
Scope *scope = doc->scopeAt(property.line, property.column);
QList<LookupItem> results = typeOf(property.expression.toUtf8(), scope);
QString typeName;
@@ -840,7 +842,7 @@ QStringList FindExportedCppTypes::operator()(const CPlusPlus::Document::Ptr &doc
FindExportsVisitor finder(document);
finder();
static const QString kindKey = QLatin1String("QmlJSTools.ExportedQmlTypesDiagnostic");
CppModelManagerBase::trySetExtraDiagnostics(document->fileName(), kindKey,
CppModelManagerBase::trySetExtraDiagnostics(document->filePath().toString(), kindKey,
finder.messages());
// if nothing was found, done
@@ -851,8 +853,9 @@ QStringList FindExportedCppTypes::operator()(const CPlusPlus::Document::Ptr &doc
// context properties need lookup inside function scope, and thus require a full check
CPlusPlus::Document::Ptr localDoc = document;
if (document->checkMode() != CPlusPlus::Document::FullCheck && !contextPropertyDescriptions.isEmpty()) {
localDoc = m_snapshot.documentFromSource(document->utf8Source(), document->fileName());
if (document->checkMode() != CPlusPlus::Document::FullCheck
&& !contextPropertyDescriptions.isEmpty()) {
localDoc = m_snapshot.documentFromSource(document->utf8Source(), document->filePath());
localDoc->check();
}
@@ -879,7 +882,7 @@ QStringList FindExportedCppTypes::operator()(const CPlusPlus::Document::Ptr &doc
m_exportedTypes += it.value();
fileNames += QLatin1String(it.key()->fileName());
}
foreach (const LanguageUtils::FakeMetaObject::Ptr &fmo, extraFakeMetaObjects) {
for (const LanguageUtils::FakeMetaObject::Ptr &fmo : std::as_const(extraFakeMetaObjects)) {
fmo->updateFingerprint();
m_exportedTypes += fmo;
}

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -14,7 +14,6 @@ namespace QmlJS {
class QMLJS_EXPORT FindExportedCppTypes
{
Q_DECLARE_TR_FUNCTIONS(QmlJSTools::FindExportedCppTypes)
public:
FindExportedCppTypes(const CPlusPlus::Snapshot &snapshot);

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsicons.h"
@@ -61,12 +61,14 @@ void Icons::setIconFilesPath(const QString &iconPath)
if (debug)
qCDebug(iconsLog) << "parsing" << iconPath;
QDir topDir(iconPath);
foreach (const QFileInfo &subDirInfo, topDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
QList<QFileInfo> dirs = topDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
for (const QFileInfo &subDirInfo : dirs) {
if (debug)
qCDebug(iconsLog) << "parsing" << subDirInfo.absoluteFilePath();
const QString packageName = subDirInfo.fileName();
QDir subDir(subDirInfo.absoluteFilePath() + QLatin1String("/16x16"));
foreach (const QFileInfo &iconFile, subDir.entryInfoList(QDir::Files)) {
QList<QFileInfo> files = subDir.entryInfoList(QDir::Files);
for (const QFileInfo &iconFile : files) {
QIcon icon(iconFile.absoluteFilePath());
if (icon.isNull()) {
if (debug)

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsimportdependencies.h"
#include "qmljsinterpreter.h"
@@ -188,7 +188,7 @@ void ImportKey::addToHash(QCryptographicHash &hash) const
hash.addData(reinterpret_cast<const char *>(&type), sizeof(type));
hash.addData(reinterpret_cast<const char *>(&majorVersion), sizeof(majorVersion));
hash.addData(reinterpret_cast<const char *>(&minorVersion), sizeof(minorVersion));
foreach (const QString &s, splitPath) {
for (const QString &s : splitPath) {
hash.addData("/", 1);
hash.addData(reinterpret_cast<const char *>(s.constData()), sizeof(QChar) * s.size());
}
@@ -484,7 +484,7 @@ size_t qHash(const ImportKey &info)
{
size_t res = ::qHash(info.type) ^
::qHash(info.majorVersion) ^ ::qHash(info.minorVersion);
foreach (const QString &s, info.splitPath)
for (const QString &s : std::as_const(info.splitPath))
res = res ^ ::qHash(s);
return res;
}
@@ -546,7 +546,7 @@ QByteArray DependencyInfo::calculateFingerprint(const ImportDependencies &deps)
rootImport.addToHash(hash);
QStringList coreImports = Utils::toList(allCoreImports);
coreImports.sort();
foreach (const QString importId, coreImports) {
for (const QString &importId : std::as_const(coreImports)) {
hash.addData(reinterpret_cast<const char*>(importId.constData()), importId.size() * sizeof(QChar));
QByteArray coreImportFingerprint = deps.coreImport(importId).fingerprint;
hash.addData(coreImportFingerprint);
@@ -612,7 +612,7 @@ void ImportDependencies::filter(const ViewerContext &vContext)
const CoreImport &cImport = j.value();
if (languageIsCompatible(vContext.language, cImport.language)) {
QList<Export> newExports;
foreach (const Export &e, cImport.possibleExports) {
for (const Export &e : std::as_const(cImport.possibleExports)) {
++benchMark.nPossibleExports;
if (e.visibleInVContext(vContext)) {
newExports.append(e);
@@ -660,10 +660,10 @@ void ImportDependencies::iterateOnCandidateImports(
default:
{
const QStringList imp = m_importCache.value(key.flatKey());
foreach (const QString &cImportName, imp) {
for (const QString &cImportName : imp) {
CoreImport cImport = coreImport(cImportName);
if (languageIsCompatible(vContext.language, cImport.language)) {
foreach (const Export e, cImport.possibleExports) {
for (const Export &e : std::as_const(cImport.possibleExports)) {
++benchMark.nPossibleExports;
if (e.visibleInVContext(vContext)) {
ImportMatchStrength m = e.exportName.matchImport(key, vContext);
@@ -683,10 +683,10 @@ void ImportDependencies::iterateOnCandidateImports(
while (lb != end) {
ImportKey::DirCompareInfo c = key.compareDir(lb.key());
if (c == ImportKey::SameDir) {
foreach (const QString &cImportName, lb.value()) {
for (const QString &cImportName : std::as_const(lb.value())) {
CoreImport cImport = coreImport(cImportName);
if (languageIsCompatible(vContext.language, cImport.language)) {
foreach (const Export e, cImport.possibleExports) {
for (const Export &e : std::as_const(cImport.possibleExports)) {
++benchMark.nPossibleExports;
if (e.visibleInVContext(vContext)) {
ImportMatchStrength m = e.exportName.matchImport(key, vContext);
@@ -754,19 +754,19 @@ void ImportDependencies::addCoreImport(const CoreImport &import)
CoreImport newImport = import;
if (m_coreImports.contains(import.importId)) {
CoreImport oldVal = m_coreImports.value(import.importId);
foreach (const Export &e, oldVal.possibleExports) {
for (const Export &e : std::as_const(oldVal.possibleExports)) {
if (e.intrinsic)
removeImportCacheEntry(e.exportName, import.importId);
else
newImport.possibleExports.append(e);
}
}
foreach (const Export &e, import.possibleExports)
for (const Export &e : std::as_const(import.possibleExports))
m_importCache[e.exportName].append(import.importId);
m_coreImports.insert(newImport.importId, newImport);
if (importsLog().isDebugEnabled()) {
QString msg = QString::fromLatin1("added import %1 for").arg(newImport.importId);
foreach (const Export &e, newImport.possibleExports)
for (const Export &e : std::as_const(newImport.possibleExports))
msg += QString::fromLatin1("\n %1(%2)")
.arg(e.exportName.toString(), e.pathRequired.toUserOutput());
qCDebug(importsLog) << msg;
@@ -781,7 +781,7 @@ void ImportDependencies::removeCoreImport(const QString &importId)
}
CoreImport &cImport = m_coreImports[importId];
QList<Export> newExports;
foreach (const Export &e, cImport.possibleExports)
for (const Export &e : std::as_const(cImport.possibleExports))
if (e.intrinsic)
removeImportCacheEntry(e.exportName, importId);
else
@@ -867,10 +867,10 @@ void ImportDependencies::iterateOnLibraryImports(
iter_t end = m_importCache.constEnd();
while (i != end && i.key().type == ImportType::Library) {
qCDebug(importsLog) << "libloop:" << i.key().toString() << i.value();
foreach (const QString &cImportName, i.value()) {
for (const QString &cImportName : i.value()) {
CoreImport cImport = coreImport(cImportName);
if (languageIsCompatible(vContext.language, cImport.language)) {
foreach (const Export &e, cImport.possibleExports) {
for (const Export &e : std::as_const(cImport.possibleExports)) {
++benchMark.nPossibleExports;
if (e.visibleInVContext(vContext) && e.exportName.type == ImportType::Library) {
ImportMatchStrength m = e.exportName.matchImport(i.key(), vContext);
@@ -903,10 +903,10 @@ void ImportDependencies::iterateOnSubImports(
ImportKey::DirCompareInfo c = baseKey.compareDir(i.key());
if (c != ImportKey::SameDir && c != ImportKey::SecondInFirst)
break;
foreach (const QString &cImportName, i.value()) {
for (const QString &cImportName : i.value()) {
CoreImport cImport = coreImport(cImportName);
if (languageIsCompatible(vContext.language, cImport.language)) {
foreach (const Export &e, cImport.possibleExports) {
for (const Export &e : std::as_const(cImport.possibleExports)) {
++benchMark.nPossibleExports;
if (e.visibleInVContext(vContext)) {
ImportMatchStrength m = e.exportName.matchImport(i.key(), vContext);
@@ -961,14 +961,15 @@ void ImportDependencies::checkConsistency() const
for (auto j = m_importCache.cbegin(), end = m_importCache.cend(); j != end; ++j) {
for (const QString &s : j.value()) {
bool found = false;
foreach (const Export &e, m_coreImports.value(s).possibleExports)
const QList<Export> exports = m_coreImports.value(s).possibleExports;
for (const Export &e : exports)
if (e.exportName == j.key())
found = true;
Q_ASSERT(found); Q_UNUSED(found)
}
}
for (auto i = m_coreImports.cbegin(), end = m_coreImports.cend(); i != end; ++i) {
foreach (const Export &e, i.value().possibleExports) {
for (const Export &e : std::as_const(i.value().possibleExports)) {
if (!m_importCache.value(e.exportName).contains(i.key())) {
qCWarning(importsLog) << e.exportName.toString();
qCWarning(importsLog) << i.key();

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
/*
This file is a self-contained interactive indenter for Qt Script.

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,15 +1,18 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "parser/qmljsast_p.h"
#include "qmljsinterpreter.h"
#include "qmljsconstants.h"
#include "qmljscontext.h"
#include "qmljsevaluate.h"
#include "qmljsinterpreter.h"
#include "qmljsmodelmanagerinterface.h"
#include "qmljsscopeastpath.h"
#include "qmljsscopebuilder.h"
#include "qmljsscopechain.h"
#include "qmljstr.h"
#include "qmljstypedescriptionreader.h"
#include "qmljsvalueowner.h"
@@ -427,7 +430,7 @@ const CppComponentValue *CppComponentValue::prototype() const
Use this function rather than calling prototype() in a loop, as it avoids
cycles.
*/
QList<const CppComponentValue *> CppComponentValue::prototypes() const
const QList<const CppComponentValue *> CppComponentValue::prototypes() const
{
QList<const CppComponentValue *> protos;
for (const CppComponentValue *it = this; it; it = it->prototype()) {
@@ -457,7 +460,7 @@ QString CppComponentValue::defaultPropertyName() const
QString CppComponentValue::propertyType(const QString &propertyName) const
{
foreach (const CppComponentValue *it, prototypes()) {
for (const CppComponentValue *it : prototypes()) {
FakeMetaObject::ConstPtr iter = it->m_metaObject;
int propIdx = iter->propertyIndex(propertyName);
if (propIdx != -1)
@@ -468,7 +471,7 @@ QString CppComponentValue::propertyType(const QString &propertyName) const
bool CppComponentValue::isListProperty(const QString &propertyName) const
{
foreach (const CppComponentValue *it, prototypes()) {
for (const CppComponentValue *it : prototypes()) {
FakeMetaObject::ConstPtr iter = it->m_metaObject;
int propIdx = iter->propertyIndex(propertyName);
if (propIdx != -1)
@@ -479,7 +482,7 @@ bool CppComponentValue::isListProperty(const QString &propertyName) const
FakeMetaEnum CppComponentValue::getEnum(const QString &typeName, const CppComponentValue **foundInScope) const
{
foreach (const CppComponentValue *it, prototypes()) {
for (const CppComponentValue *it : prototypes()) {
FakeMetaObject::ConstPtr iter = it->m_metaObject;
const int index = iter->enumeratorIndex(typeName);
if (index != -1) {
@@ -495,7 +498,7 @@ FakeMetaEnum CppComponentValue::getEnum(const QString &typeName, const CppCompon
const QmlEnumValue *CppComponentValue::getEnumValue(const QString &typeName, const CppComponentValue **foundInScope) const
{
foreach (const CppComponentValue *it, prototypes()) {
for (const CppComponentValue *it : prototypes()) {
if (const QmlEnumValue *e = it->m_enums.value(typeName)) {
if (foundInScope)
*foundInScope = it;
@@ -544,7 +547,7 @@ const ObjectValue *CppComponentValue::signalScope(const QString &signalName) con
bool CppComponentValue::isWritable(const QString &propertyName) const
{
foreach (const CppComponentValue *it, prototypes()) {
for (const CppComponentValue *it : prototypes()) {
FakeMetaObject::ConstPtr iter = it->m_metaObject;
int propIdx = iter->propertyIndex(propertyName);
if (propIdx != -1)
@@ -555,7 +558,7 @@ bool CppComponentValue::isWritable(const QString &propertyName) const
bool CppComponentValue::isPointer(const QString &propertyName) const
{
foreach (const CppComponentValue *it, prototypes()) {
for (const CppComponentValue *it : prototypes()) {
FakeMetaObject::ConstPtr iter = it->m_metaObject;
int propIdx = iter->propertyIndex(propertyName);
if (propIdx != -1)
@@ -574,7 +577,7 @@ bool CppComponentValue::hasLocalProperty(const QString &typeName) const
bool CppComponentValue::hasProperty(const QString &propertyName) const
{
foreach (const CppComponentValue *it, prototypes()) {
for (const CppComponentValue *it : prototypes()) {
FakeMetaObject::ConstPtr iter = it->m_metaObject;
int propIdx = iter->propertyIndex(propertyName);
if (propIdx != -1)
@@ -585,7 +588,7 @@ bool CppComponentValue::hasProperty(const QString &propertyName) const
bool CppComponentValue::isDerivedFrom(FakeMetaObject::ConstPtr base) const
{
foreach (const CppComponentValue *it, prototypes()) {
for (const CppComponentValue *it : prototypes()) {
FakeMetaObject::ConstPtr iter = it->m_metaObject;
if (iter == base)
return true;
@@ -1326,7 +1329,7 @@ CppQmlTypesLoader::BuiltinObjects CppQmlTypesLoader::loadQmlTypes(const QFileInf
QHash<QString, FakeMetaObject::ConstPtr> newObjects;
QStringList newDependencies;
foreach (const QFileInfo &qmlTypeFile, qmlTypeFiles) {
for (const QFileInfo &qmlTypeFile : qmlTypeFiles) {
QString error, warning;
QFile file(qmlTypeFile.absoluteFilePath());
if (file.open(QIODevice::ReadOnly)) {
@@ -1340,13 +1343,11 @@ CppQmlTypesLoader::BuiltinObjects CppQmlTypesLoader::loadQmlTypes(const QFileInf
error = file.errorString();
}
if (!error.isEmpty()) {
errors->append(TypeDescriptionReader::tr(
"Errors while loading qmltypes from %1:\n%2").arg(
errors->append(Tr::tr("Errors while loading qmltypes from %1:\n%2").arg(
qmlTypeFile.absoluteFilePath(), error));
}
if (!warning.isEmpty()) {
warnings->append(TypeDescriptionReader::tr(
"Warnings while loading qmltypes from %1:\n%2").arg(
warnings->append(Tr::tr("Warnings while loading qmltypes from %1:\n%2").arg(
qmlTypeFile.absoluteFilePath(), warning));
}
}
@@ -1400,8 +1401,8 @@ template <typename T>
void CppQmlTypes::load(const QString &originId, const T &fakeMetaObjects, const QString &overridePackage)
{
QList<CppComponentValue *> newCppTypes;
foreach (const FakeMetaObject::ConstPtr &fmo, fakeMetaObjects) {
foreach (const FakeMetaObject::Export &exp, fmo->exports()) {
for (const FakeMetaObject::ConstPtr &fmo : fakeMetaObjects) {
for (const FakeMetaObject::Export &exp : fmo->exports()) {
QString package = exp.package;
if (package.isEmpty())
package = overridePackage;
@@ -1422,7 +1423,7 @@ void CppQmlTypes::load(const QString &originId, const T &fakeMetaObjects, const
}
// set prototypes of cpp types
foreach (CppComponentValue *object, newCppTypes) {
for (CppComponentValue *object : std::as_const(newCppTypes)) {
const QString &protoCppName = object->metaObject()->superclassName();
const CppComponentValue *proto = objectByCppName(protoCppName);
if (proto)
@@ -1441,11 +1442,12 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri
QList<const CppComponentValue *> newObjects;
// make new exported objects
foreach (const FakeMetaObjectWithOrigin &fmoo, m_fakeMetaObjectsByPackage.value(package)) {
const QSet<FakeMetaObjectWithOrigin> fmoos = m_fakeMetaObjectsByPackage.value(package);
for (const FakeMetaObjectWithOrigin &fmoo : fmoos) {
const FakeMetaObject::ConstPtr &fmo = fmoo.fakeMetaObject;
// find the highest-version export for each alias
QHash<QString, FakeMetaObject::Export> bestExports;
foreach (const FakeMetaObject::Export &exp, fmo->exports()) {
for (const FakeMetaObject::Export &exp : fmo->exports()) {
if (exp.package != package || (version.isValid() && exp.version > version))
continue;
@@ -1465,7 +1467,7 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri
continue;
ComponentVersion cppVersion;
foreach (const FakeMetaObject::Export &bestExport, bestExports) {
for (const FakeMetaObject::Export &bestExport : std::as_const(bestExports)) {
QString name = bestExport.type;
bool exported = true;
if (name.isEmpty()) {
@@ -1495,7 +1497,7 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri
// set their prototypes, creating them if necessary
// this ensures that the prototypes of C++ objects are resolved correctly and with the correct
// revision, and cannot be hidden by other objects.
foreach (const CppComponentValue *cobject, newObjects) {
for (const CppComponentValue *cobject : std::as_const(newObjects)) {
CppComponentValue *object = const_cast<CppComponentValue *>(cobject);
while (!object->prototype()) {
const QString &protoCppName = object->metaObject()->superclassName();
@@ -1860,7 +1862,7 @@ bool ASTObjectValue::getSourceLocation(Utils::FilePath *fileName, int *line, int
void ASTObjectValue::processMembers(MemberProcessor *processor) const
{
foreach (ASTPropertyReference *ref, m_properties) {
for (ASTPropertyReference *ref : m_properties) {
uint pFlags = PropertyInfo::Readable;
if (!ref->ast()->isReadonly())
pFlags |= PropertyInfo::Writeable;
@@ -1868,7 +1870,7 @@ void ASTObjectValue::processMembers(MemberProcessor *processor) const
// ### Should get a different value?
processor->processGeneratedSlot(ref->onChangedSlotName(), ref);
}
foreach (ASTSignal *ref, m_signals) {
for (ASTSignal *ref : m_signals) {
processor->processSignal(ref->ast()->name.toString(), ref);
// ### Should get a different value?
processor->processGeneratedSlot(ref->slotName(), ref);
@@ -2099,9 +2101,9 @@ bool ASTPropertyReference::getSourceLocation(Utils::FilePath *fileName, int *lin
const Value *ASTPropertyReference::value(ReferenceContext *referenceContext) const
{
if (m_ast->statement
&& (m_ast->memberType->name == QLatin1String("variant")
|| m_ast->memberType->name == QLatin1String("var")
|| m_ast->memberType->name == QLatin1String("alias"))) {
&& (m_ast->memberType->toString() == QLatin1String("variant")
|| m_ast->memberType->toString() == QLatin1String("var")
|| m_ast->memberType->toString() == QLatin1String("alias"))) {
// Adjust the context for the current location - expensive!
// ### Improve efficiency by caching the 'use chain' constructed in ScopeBuilder.
@@ -2117,7 +2119,7 @@ const Value *ASTPropertyReference::value(ReferenceContext *referenceContext) con
return evaluator(m_ast->statement);
}
const QString memberType = m_ast->memberType->name.toString();
const QString memberType = m_ast->memberType->toString();
const Value *builtin = valueOwner()->defaultValueForBuiltinType(memberType);
if (!builtin->asUndefinedValue())
@@ -2141,7 +2143,7 @@ ASTSignal::ASTSignal(UiPublicMember *ast, const Document *doc, ValueOwner *value
ObjectValue *v = valueOwner->newObject(/*prototype=*/nullptr);
for (UiParameterList *it = ast->parameters; it; it = it->next) {
if (!it->name.isEmpty())
v->setMember(it->name.toString(), valueOwner->defaultValueForBuiltinType(it->type->name.toString()));
v->setMember(it->name.toString(), valueOwner->defaultValueForBuiltinType(it->type->toString()));
}
m_bodyScope = v;
}
@@ -2168,9 +2170,9 @@ const Value *ASTSignal::argument(int index) const
UiParameterList *param = m_ast->parameters;
for (int i = 0; param && i < index; ++i)
param = param->next;
if (!param || param->type->name.isEmpty())
if (!param || param->type->toString().isEmpty())
return valueOwner()->unknownValue();
return valueOwner()->defaultValueForBuiltinType(param->type->name.toString());
return valueOwner()->defaultValueForBuiltinType(param->type->toString());
}
QString ASTSignal::argumentName(int index) const

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -577,7 +577,7 @@ public:
using ObjectValue::prototype;
const CppComponentValue *prototype() const;
QList<const CppComponentValue *> prototypes() const;
const QList<const CppComponentValue *> prototypes() const;
LanguageUtils::FakeMetaObject::ConstPtr metaObject() const;

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
/*
This file is a self-contained interactive indenter for Qt Script.
@@ -105,7 +105,7 @@ QString LineInfo::trimmedCodeLine(const QString &t)
yyLinizerState.tokens = scanner(t, startState);
QString trimmed;
int previousTokenEnd = 0;
foreach (const Token &token, yyLinizerState.tokens) {
for (const Token &token : std::as_const(yyLinizerState.tokens)) {
trimmed.append(t.mid(previousTokenEnd, token.begin() - previousTokenEnd));
if (token.is(Token::String)) {
@@ -131,7 +131,7 @@ QString LineInfo::trimmedCodeLine(const QString &t)
}
bool isBinding = false;
foreach (const Token &token, yyLinizerState.tokens) {
for (const Token &token : std::as_const(yyLinizerState.tokens)) {
if (token.is(Token::Colon)) {
isBinding = true;
break;

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,14 +1,16 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljslink.h"
#include "parser/qmljsast_p.h"
#include "qmljsdocument.h"
#include "qmljsbind.h"
#include "qmljsutils.h"
#include "qmljsmodelmanagerinterface.h"
#include "qmljsconstants.h"
#include "qmljsdocument.h"
#include "qmljsmodelmanagerinterface.h"
#include "qmljstr.h"
#include "qmljsutils.h"
#include <utils/algorithm.h>
#include <utils/filepath.h>
@@ -293,7 +295,7 @@ void LinkPrivate::populateImportedTypes(Imports *imports, const Document::Ptr &d
imports->setImportFailed();
if (info.ast()) {
error(doc, info.ast()->fileNameToken,
Link::tr("File or directory not found."));
Tr::tr("File or directory not found."));
}
break;
default:
@@ -455,7 +457,7 @@ Import LinkPrivate::importNonFile(const Document::Ptr &doc, const ImportInfo &im
error(doc,
locationFromRange(importInfo.ast()->firstSourceLocation(),
importInfo.ast()->lastSourceLocation()),
Link::tr(
Tr::tr(
"QML module not found (%1).\n\n"
"Import paths:\n"
"%2\n\n"
@@ -525,19 +527,19 @@ bool LinkPrivate::importLibrary(const Document::Ptr &doc,
import->valid = false;
error(doc,
errorLoc,
Link::tr("Implicit import '%1' of QML module '%2' not found.\n\n"
"Import paths:\n"
"%3\n\n"
"For qmake projects, use the QML_IMPORT_PATH variable to add import "
"paths.\n"
"For Qbs projects, declare and set a qmlImportPaths property in "
"your product "
"to add import paths.\n"
"For qmlproject projects, use the importPaths property to add "
"import paths.\n"
"For CMake projects, make sure QML_IMPORT_PATH variable is in "
"CMakeCache.txt.\n")
.arg(importName,
Tr::tr("Implicit import '%1' of QML module '%2' not found.\n\n"
"Import paths:\n"
"%3\n\n"
"For qmake projects, use the QML_IMPORT_PATH variable to add import "
"paths.\n"
"For Qbs projects, declare and set a qmlImportPaths property in "
"your product "
"to add import paths.\n"
"For qmlproject projects, use the importPaths property to add "
"import paths.\n"
"For CMake projects, make sure QML_IMPORT_PATH variable is in "
"CMakeCache.txt.\n")
.arg(importName,
importInfo.name(),
Utils::transform(m_importPaths, [](const Utils::FilePath &p) {
return p.toString();
@@ -569,8 +571,9 @@ bool LinkPrivate::importLibrary(const Document::Ptr &doc,
if (!optional && errorLoc.isValid()) {
appendDiagnostic(doc, DiagnosticMessage(
Severity::ReadingTypeInfoWarning, errorLoc,
Link::tr("QML module contains C++ plugins, "
"currently reading type information... %1").arg(import->info.name())));
Tr::tr("QML module contains C++ plugins, "
"currently reading type information... %1")
.arg(import->info.name())));
import->valid = false;
}
} else if (libraryInfo.pluginTypeInfoStatus() == LibraryInfo::DumpError

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -18,7 +18,6 @@ class LinkPrivate;
class QMLJS_EXPORT Link
{
Q_DISABLE_COPY(Link)
Q_DECLARE_TR_FUNCTIONS(QmlJS::Link)
public:
Link(Link &&) = delete;

View File

@@ -1,15 +1,17 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsmodelmanagerinterface.h"
#include "qmljsbind.h"
#include "qmljsconstants.h"
#include "qmljsdialect.h"
#include "qmljsfindexportedcpptypes.h"
#include "qmljsinterpreter.h"
#include "qmljsmodelmanagerinterface.h"
#include "qmljsplugindumper.h"
#include "qmljsdialect.h"
#include "qmljsviewercontext.h"
#include "qmljstr.h"
#include "qmljsutils.h"
#include "qmljsviewercontext.h"
#include <cplusplus/cppmodelmanagerbase.h>
#include <utils/algorithm.h>
@@ -343,7 +345,7 @@ QFuture<void> ModelManagerInterface::refreshSourceFiles(const QList<Utils::FileP
addFuture(result);
if (sourceFiles.count() > 1)
addTaskInternal(result, tr("Parsing QML Files"), Constants::TASK_INDEX);
addTaskInternal(result, Tr::tr("Parsing QML Files"), Constants::TASK_INDEX);
if (sourceFiles.count() > 1 && !m_shouldScanImports) {
bool scan = false;
@@ -449,13 +451,18 @@ bool pInfoLessThanImports(const ModelManagerInterface::ProjectInfo &p1,
}
inline void combine(QSet<FilePath> &set, const QList<FilePath> &list)
{
for (const FilePath &path : list)
set.insert(path);
}
static QSet<Utils::FilePath> generatedQrc(
const QList<ModelManagerInterface::ProjectInfo> &projectInfos)
{
QSet<Utils::FilePath> res;
for (const auto &pInfo : projectInfos) {
for (const auto &generatedQrcFile: pInfo.generatedQrcFiles)
res.insert(generatedQrcFile);
combine(res, pInfo.generatedQrcFiles);
}
return res;
}
@@ -475,24 +482,20 @@ void ModelManagerInterface::iterateQrcFiles(
Utils::sort(pInfos, &pInfoLessThanAll);
}
QSet<Utils::FilePath> pathsChecked;
QSet<Utils::FilePath> allQrcs = generatedQrc(pInfos);
for (const ModelManagerInterface::ProjectInfo &pInfo : std::as_const(pInfos)) {
QList<Utils::FilePath> qrcFilePaths;
if (resources == ActiveQrcResources)
qrcFilePaths = pInfo.activeResourceFiles;
combine(allQrcs, pInfo.activeResourceFiles);
else
qrcFilePaths = pInfo.allResourceFiles;
for (const Utils::FilePath &p : generatedQrc({pInfo}))
qrcFilePaths.append(p);
for (const Utils::FilePath &qrcFilePath : std::as_const(qrcFilePaths)) {
if (pathsChecked.contains(qrcFilePath))
continue;
pathsChecked.insert(qrcFilePath);
QrcParser::ConstPtr qrcFile = m_qrcCache.parsedPath(qrcFilePath.toString());
if (qrcFile.isNull())
continue;
callback(qrcFile);
}
combine(allQrcs, pInfo.allResourceFiles);
}
for (const Utils::FilePath &qrcFilePath : std::as_const(allQrcs)) {
QrcParser::ConstPtr qrcFile = m_qrcCache.parsedPath(qrcFilePath.toFSPathString());
if (qrcFile.isNull())
continue;
callback(qrcFile);
}
}
@@ -875,7 +878,7 @@ static bool findNewQmlLibraryInPath(const Utils::FilePath &path,
}
// found a new library!
const std::optional<QByteArray> contents = qmldirFile.fileContents();
const expected_str<QByteArray> contents = qmldirFile.fileContents();
if (!contents)
return false;
QString qmldirData = QString::fromUtf8(*contents);
@@ -985,7 +988,7 @@ void ModelManagerInterface::parseLoop(QSet<Utils::FilePath> &scannedPaths,
contents = entry.first;
documentRevision = entry.second;
} else {
const std::optional<QByteArray> fileContents = fileName.fileContents();
const expected_str<QByteArray> fileContents = fileName.fileContents();
if (fileContents) {
QTextStream ins(*fileContents);
contents = ins.readAll();
@@ -1208,7 +1211,7 @@ void ModelManagerInterface::maybeScan(const PathsAndLanguages &importPaths)
workingCopyInternal(), pathToScan,
this, true, true, false);
addFuture(result);
addTaskInternal(result, tr("Scanning QML Imports"), Constants::TASK_IMPORT_SCAN);
addTaskInternal(result, Tr::tr("Scanning QML Imports"), Constants::TASK_IMPORT_SCAN);
}
}
@@ -1350,10 +1353,10 @@ void ModelManagerInterface::maybeQueueCppQmlTypeUpdate(const CPlusPlus::Document
void ModelManagerInterface::queueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc, bool scan)
{
QPair<CPlusPlus::Document::Ptr, bool> prev = m_queuedCppDocuments.value(doc->fileName());
QPair<CPlusPlus::Document::Ptr, bool> prev = m_queuedCppDocuments.value(doc->filePath().path());
if (prev.first && prev.second)
prev.first->releaseSourceAndAST();
m_queuedCppDocuments.insert(doc->fileName(), {doc, scan});
m_queuedCppDocuments.insert(doc->filePath().path(), {doc, scan});
m_updateCppQmlTypesTimer->start();
}
@@ -1439,13 +1442,13 @@ void ModelManagerInterface::updateCppQmlTypes(
CPlusPlus::Document::Ptr doc = pair.first;
const bool scan = pair.second;
const QString fileName = doc->fileName();
const FilePath filePath = doc->filePath();
if (!scan) {
hasNewInfo = newData.remove(fileName) || hasNewInfo;
const auto savedDocs = newDeclarations.value(fileName);
hasNewInfo = newData.remove(filePath.path()) || hasNewInfo;
const auto savedDocs = newDeclarations.value(filePath.path());
for (const CPlusPlus::Document::Ptr &savedDoc : savedDocs) {
finder(savedDoc);
hasNewInfo = rescanExports(savedDoc->fileName(), finder, newData) || hasNewInfo;
hasNewInfo = rescanExports(savedDoc->filePath().path(), finder, newData) || hasNewInfo;
}
continue;
}
@@ -1453,7 +1456,7 @@ void ModelManagerInterface::updateCppQmlTypes(
for (auto it = newDeclarations.begin(), end = newDeclarations.end(); it != end;) {
for (auto docIt = it->begin(), endDocIt = it->end(); docIt != endDocIt;) {
const CPlusPlus::Document::Ptr &savedDoc = *docIt;
if (savedDoc->fileName() == fileName) {
if (savedDoc->filePath() == filePath) {
savedDoc->releaseSourceAndAST();
it->erase(docIt);
break;
@@ -1472,7 +1475,7 @@ void ModelManagerInterface::updateCppQmlTypes(
doc->keepSourceAndAST(); // keep for later reparsing when dependent doc changes
}
hasNewInfo = rescanExports(fileName, finder, newData) || hasNewInfo;
hasNewInfo = rescanExports(filePath.path(), finder, newData) || hasNewInfo;
doc->releaseSourceAndAST();
}

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,12 +1,13 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsplugindumper.h"
#include "qmljsmodelmanagerinterface.h"
#include "qmljsutils.h"
#include <qmljs/qmljsinterpreter.h>
#include <qmljs/qmljsviewercontext.h>
#include "qmljsinterpreter.h"
#include "qmljsmodelmanagerinterface.h"
#include "qmljstr.h"
#include "qmljsutils.h"
#include "qmljsviewercontext.h"
#include <utils/algorithm.h>
#include <utils/filesystemwatcher.h>
@@ -123,25 +124,23 @@ void PluginDumper::onLoadPluginTypes(const Utils::FilePath &libraryPath,
plugin.importVersion = importVersion;
// add default qmltypes file if it exists
QDirIterator it(canonicalLibraryPath.toString(), QStringList { "*.qmltypes" }, QDir::Files);
while (it.hasNext()) {
const FilePath defaultQmltypesPath = canonicalLibraryPath.resolvePath(it.next());
if (!plugin.typeInfoPaths.contains(defaultQmltypesPath))
plugin.typeInfoPaths += defaultQmltypesPath;
const FilePaths libEntries = canonicalLibraryPath.dirEntries({{"*.qmltypes"}, QDir::Files});
for (const FilePath &libEntry : libEntries) {
if (!plugin.typeInfoPaths.contains(libEntry))
plugin.typeInfoPaths += libEntry;
}
// add typeinfo files listed in qmldir
foreach (const QString &typeInfo, libraryInfo.typeInfos()) {
for (const QString &typeInfo : libraryInfo.typeInfos()) {
const FilePath pathNow = canonicalLibraryPath.resolvePath(typeInfo);
if (!plugin.typeInfoPaths.contains(pathNow) && pathNow.exists())
plugin.typeInfoPaths += pathNow;
}
// watch plugin libraries
foreach (const QmlDirParser::Plugin &plugin, snapshot.libraryInfo(canonicalLibraryPath).plugins()) {
const QString pluginLibrary = resolvePlugin(canonicalLibraryPath.toString(), plugin.path, plugin.name);
const QList<QmlDirParser::Plugin> plugins = snapshot.libraryInfo(canonicalLibraryPath).plugins();
for (const QmlDirParser::Plugin &plugin : plugins) {
const FilePath pluginLibrary = resolvePlugin(canonicalLibraryPath, plugin.path, plugin.name);
if (!pluginLibrary.isEmpty()) {
if (!pluginWatcher()->watchesFile(pluginLibrary))
pluginWatcher()->addFile(pluginLibrary, FileSystemWatcher::WatchModifiedDate);
@@ -154,9 +153,9 @@ void PluginDumper::onLoadPluginTypes(const Utils::FilePath &libraryPath,
for (const FilePath &path : std::as_const(plugin.typeInfoPaths)) {
if (!path.exists())
continue;
if (!pluginWatcher()->watchesFile(path.toString()))
pluginWatcher()->addFile(path.toString(), FileSystemWatcher::WatchModifiedDate);
m_libraryToPluginIndex.insert(path.toString(), index);
if (!pluginWatcher()->watchesFile(path))
pluginWatcher()->addFile(path, FileSystemWatcher::WatchModifiedDate);
m_libraryToPluginIndex.insert(path, index);
}
}
@@ -165,23 +164,23 @@ void PluginDumper::onLoadPluginTypes(const Utils::FilePath &libraryPath,
void PluginDumper::dumpAllPlugins()
{
foreach (const Plugin &plugin, m_plugins) {
for (const Plugin &plugin : std::as_const(m_plugins)) {
dump(plugin);
}
}
static QString noTypeinfoError(const FilePath &libraryPath)
{
return PluginDumper::tr("QML module does not contain information about components contained in plugins.\n\n"
"Module path: %1\n"
"See \"Using QML Modules with Plugins\" in the documentation.").arg(
return Tr::tr("QML module does not contain information about components contained in plugins.\n\n"
"Module path: %1\n"
"See \"Using QML Modules with Plugins\" in the documentation.").arg(
libraryPath.toUserOutput());
}
static QString qmldumpErrorMessage(const FilePath &libraryPath, const QString &error)
{
return noTypeinfoError(libraryPath) + "\n\n" +
PluginDumper::tr("Automatic type dump of QML module failed.\nErrors:\n%1").
Tr::tr("Automatic type dump of QML module failed.\nErrors:\n%1").
arg(error) + QLatin1Char('\n');
}
@@ -189,19 +188,19 @@ static QString qmldumpFailedMessage(const FilePath &libraryPath, const QString &
{
QString firstLines = QStringList(error.split('\n').mid(0, 10)).join('\n');
return noTypeinfoError(libraryPath) + "\n\n" +
PluginDumper::tr("Automatic type dump of QML module failed.\n"
"First 10 lines or errors:\n"
"\n"
"%1"
"\n"
"Check General Messages for details."
).arg(firstLines);
Tr::tr("Automatic type dump of QML module failed.\n"
"First 10 lines or errors:\n"
"\n"
"%1"
"\n"
"Check General Messages for details."
).arg(firstLines);
}
static void printParseWarnings(const FilePath &libraryPath, const QString &warning)
{
ModelManagerInterface::writeWarning(
PluginDumper::tr("Warnings while parsing QML type information of %1:\n"
Tr::tr("Warnings while parsing QML type information of %1:\n"
"%2").arg(libraryPath.toUserOutput(), warning));
}
@@ -211,26 +210,26 @@ static QString qmlPluginDumpErrorMessage(QtcProcess *process)
const QString binary = process->commandLine().executable().toUserOutput();
switch (process->error()) {
case QProcess::FailedToStart:
errorMessage = PluginDumper::tr("\"%1\" failed to start: %2").arg(binary, process->errorString());
errorMessage = Tr::tr("\"%1\" failed to start: %2").arg(binary, process->errorString());
break;
case QProcess::Crashed:
errorMessage = PluginDumper::tr("\"%1\" crashed.").arg(binary);
errorMessage = Tr::tr("\"%1\" crashed.").arg(binary);
break;
case QProcess::Timedout:
errorMessage = PluginDumper::tr("\"%1\" timed out.").arg(binary);
errorMessage = Tr::tr("\"%1\" timed out.").arg(binary);
break;
case QProcess::ReadError:
case QProcess::WriteError:
errorMessage = PluginDumper::tr("I/O error running \"%1\".").arg(binary);
errorMessage = Tr::tr("I/O error running \"%1\".").arg(binary);
break;
case QProcess::UnknownError:
if (process->exitCode())
errorMessage = PluginDumper::tr("\"%1\" returned exit code %2.").arg(binary).arg(process->exitCode());
errorMessage = Tr::tr("\"%1\" returned exit code %2.").arg(binary).arg(process->exitCode());
break;
}
errorMessage += '\n' + PluginDumper::tr("Arguments: %1").arg(process->commandLine().arguments());
errorMessage += '\n' + Tr::tr("Arguments: %1").arg(process->commandLine().arguments());
if (process->error() != QProcess::FailedToStart) {
const QString stdErr = QString::fromLocal8Bit(process->readAllStandardError());
const QString stdErr = QString::fromLocal8Bit(process->readAllRawStandardError());
if (!stdErr.isEmpty()) {
errorMessage += QLatin1Char('\n');
errorMessage += stdErr;
@@ -263,7 +262,7 @@ void PluginDumper::qmlPluginTypeDumpDone(QtcProcess *process)
return;
}
const QByteArray output = process->readAllStandardOutput();
const QByteArray output = process->readAllRawStandardOutput();
class CppQmlTypesInfo {
public:
@@ -318,7 +317,7 @@ void PluginDumper::qmlPluginTypeDumpDone(QtcProcess *process)
void PluginDumper::pluginChanged(const QString &pluginLibrary)
{
const int pluginIndex = m_libraryToPluginIndex.value(pluginLibrary, -1);
const int pluginIndex = m_libraryToPluginIndex.value(FilePath::fromString(pluginLibrary), -1);
if (pluginIndex == -1)
return;
@@ -346,7 +345,7 @@ QFuture<PluginDumper::QmlTypeDescription> PluginDumper::loadQmlTypeDescription(c
CppQmlTypesLoader::parseQmlTypeDescriptions(reader.data(), &objs, &apis, &deps,
&error, &warning, p.toString());
if (!error.isEmpty()) {
result.errors += tr("Failed to parse \"%1\".\nError: %2").arg(p.toUserOutput(), error);
result.errors += Tr::tr("Failed to parse \"%1\".\nError: %2").arg(p.toUserOutput(), error);
} else {
result.objects += objs.values();
result.moduleApis += apis;
@@ -548,7 +547,7 @@ void PluginDumper::prepareLibraryInfo(LibraryInfo &libInfo,
libInfo.setPluginTypeInfoStatus(LibraryInfo::TypeInfoFileDone);
} else {
printParseWarnings(libraryPath, errors.join(QLatin1Char('\n')));
errs.prepend(tr("Errors while reading typeinfo files:"));
errs.prepend(Tr::tr("Errors while reading typeinfo files:"));
libInfo.setPluginTypeInfoStatus(LibraryInfo::TypeInfoFileError, errs.join(QLatin1Char('\n')));
}
@@ -637,7 +636,7 @@ void PluginDumper::dump(const Plugin &plugin)
errorMessage = noTypeinfoError(plugin.qmldirPath);
} else {
errorMessage = qmldumpErrorMessage(plugin.qmldirPath,
tr("Could not locate the helper application for dumping type information from C++ plugins.\n"
Tr::tr("Could not locate the helper application for dumping type information from C++ plugins.\n"
"Please build the qmldump application on the Qt version options page."));
}
@@ -665,45 +664,37 @@ void PluginDumper::dump(const Plugin &plugin)
Adapted from QDeclarativeImportDatabase::resolvePlugin.
*/
QString PluginDumper::resolvePlugin(const QDir &qmldirPath, const QString &qmldirPluginPath,
const QString &baseName, const QStringList &suffixes,
const QString &prefix)
FilePath PluginDumper::resolvePlugin(const FilePath &qmldirPath, const QString &qmldirPluginPath,
const QString &baseName, const QStringList &suffixes,
const QString &prefix)
{
QStringList searchPaths;
searchPaths.append(QLatin1String("."));
QStringList searchPaths = {"."};
bool qmldirPluginPathIsRelative = QDir::isRelativePath(qmldirPluginPath);
if (!qmldirPluginPathIsRelative)
searchPaths.prepend(qmldirPluginPath);
foreach (const QString &pluginPath, searchPaths) {
for (const QString &pluginPath : std::as_const(searchPaths)) {
QString resolvedPath;
FilePath resolvedPath;
if (pluginPath == QLatin1String(".")) {
if (qmldirPluginPathIsRelative)
resolvedPath = qmldirPath.absoluteFilePath(qmldirPluginPath);
resolvedPath = qmldirPath.resolvePath(qmldirPluginPath);
else
resolvedPath = qmldirPath.absolutePath();
resolvedPath = qmldirPath.absoluteFilePath();
} else {
resolvedPath = pluginPath;
resolvedPath = FilePath::fromString(pluginPath);
}
QDir dir(resolvedPath);
foreach (const QString &suffix, suffixes) {
QString pluginFileName = prefix;
pluginFileName += baseName;
pluginFileName += suffix;
QFileInfo fileInfo(dir, pluginFileName);
if (fileInfo.exists())
return fileInfo.absoluteFilePath();
for (const QString &suffix : suffixes) {
FilePath candidate = resolvedPath.pathAppended(prefix + baseName + suffix);
if (candidate.exists())
return candidate.absoluteFilePath();
}
}
return QString();
return {};
}
/*!
@@ -722,8 +713,8 @@ QString PluginDumper::resolvePlugin(const QDir &qmldirPath, const QString &qmldi
Version number on unix are ignored.
*/
QString PluginDumper::resolvePlugin(const QDir &qmldirPath, const QString &qmldirPluginPath,
const QString &baseName)
FilePath PluginDumper::resolvePlugin(const FilePath &qmldirPath, const QString &qmldirPluginPath,
const QString &baseName)
{
QStringList validSuffixList;
QString prefix;

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -82,11 +82,13 @@ private:
void loadQmltypesFile(const Utils::FilePaths &qmltypesFilePaths,
const Utils::FilePath &libraryPath,
QmlJS::LibraryInfo libraryInfo);
QString resolvePlugin(const QDir &qmldirPath, const QString &qmldirPluginPath,
const QString &baseName);
QString resolvePlugin(const QDir &qmldirPath, const QString &qmldirPluginPath,
const QString &baseName, const QStringList &suffixes,
const QString &prefix = QString());
Utils::FilePath resolvePlugin(const Utils::FilePath &qmldirPath,
const QString &qmldirPluginPath,
const QString &baseName);
Utils::FilePath resolvePlugin(const Utils::FilePath &qmldirPath,
const QString &qmldirPluginPath,
const QString &baseName, const QStringList &suffixes,
const QString &prefix = QString());
private:
Utils::FileSystemWatcher *pluginWatcher();
@@ -102,7 +104,7 @@ private:
Utils::FileSystemWatcher *m_pluginWatcher;
QHash<Utils::QtcProcess *, Utils::FilePath> m_runningQmldumps;
QList<Plugin> m_plugins;
QHash<QString, int> m_libraryToPluginIndex;
QHash<Utils::FilePath, int> m_libraryToPluginIndex;
QHash<QString, QmlJS::ModelManagerInterface::ProjectInfo> m_qtToInfo;
};

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljspropertyreader.h"
#include "qmljsdocument.h"

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsreformatter.h"
#include "qmljscodeformatter.h"
@@ -273,7 +273,7 @@ protected:
const int minContentLength = 10;
qreal result = badnessFromSplits;
foreach (const QString &line, lines) {
for (const QString &line : std::as_const(lines)) {
// really long lines should be avoided at all cost
if (line.size() > strongMaxLineLength) {
result += 50 + (line.size() - strongMaxLineLength);

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsrewriter.h"

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <qmljs/qmljsscanner.h>

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsscopeastpath.h"

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsscopebuilder.h"
@@ -48,7 +48,7 @@ void ScopeBuilder::push(AST::Node *node)
const ObjectValue *owner = nullptr;
const Value *value = nullptr;
// try to find the name on the scope objects
foreach (const ObjectValue *scope, _scopeChain->qmlScopeObjects()) {
for (const ObjectValue *scope : _scopeChain->qmlScopeObjects()) {
value = scope->lookupMember(name, _scopeChain->context(), &owner);
if (value)
break;
@@ -84,7 +84,7 @@ void ScopeBuilder::push(AST::Node *node)
void ScopeBuilder::push(const QList<AST::Node *> &nodes)
{
foreach (Node *node, nodes)
for (Node *node : nodes)
push(node);
}
@@ -197,7 +197,7 @@ const Value *ScopeBuilder::scopeObjectLookup(AST::UiQualifiedId *id)
{
// do a name lookup on the scope objects
const Value *result = nullptr;
foreach (const ObjectValue *scopeObject, _scopeChain->qmlScopeObjects()) {
for (const ObjectValue *scopeObject : _scopeChain->qmlScopeObjects()) {
const ObjectValue *object = scopeObject;
for (UiQualifiedId *it = id; it; it = it->next) {
if (it->name.isEmpty())

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsscopechain.h"
#include "qmljsbind.h"
@@ -49,7 +49,7 @@ Document::Ptr QmlComponentChain::document() const
return m_document;
}
QList<const QmlComponentChain *> QmlComponentChain::instantiatingComponents() const
const QList<const QmlComponentChain *> QmlComponentChain::instantiatingComponents() const
{
return m_instantiatingComponents;
}
@@ -155,7 +155,7 @@ void ScopeChain::setQmlComponentChain(const QSharedPointer<const QmlComponentCha
m_qmlComponentScope = qmlComponentChain;
}
QList<const ObjectValue *> ScopeChain::qmlScopeObjects() const
const QList<const ObjectValue *> ScopeChain::qmlScopeObjects() const
{
return m_qmlScopeObjects;
}
@@ -219,7 +219,7 @@ void ScopeChain::setSkipmakeComponentChain(bool b)
static void collectScopes(const QmlComponentChain *chain, QList<const ObjectValue *> *target)
{
foreach (const QmlComponentChain *parent, chain->instantiatingComponents())
for (const QmlComponentChain *parent : chain->instantiatingComponents())
collectScopes(parent, target);
if (!chain->document())
@@ -244,7 +244,7 @@ void ScopeChain::update() const
// the root scope in js files doesn't see instantiating components
if (m_document->language() != Dialect::JavaScript || m_jsScopes.count() != 1) {
if (m_qmlComponentScope) {
foreach (const QmlComponentChain *parent, m_qmlComponentScope->instantiatingComponents())
for (const QmlComponentChain *parent : m_qmlComponentScope->instantiatingComponents())
collectScopes(parent, &m_all);
}
}
@@ -272,7 +272,7 @@ void ScopeChain::update() const
static void addInstantiatingComponents(ContextPtr context, QmlComponentChain *chain)
{
const QRegularExpression importCommentPattern(QLatin1String("@scope\\s+(.*)"));
foreach (const SourceLocation &commentLoc, chain->document()->engine()->comments()) {
for (const SourceLocation &commentLoc : chain->document()->engine()->comments()) {
const QString &comment = chain->document()->source().mid(commentLoc.begin(), commentLoc.length);
// find all @scope annotations
@@ -290,10 +290,10 @@ static void addInstantiatingComponents(ContextPtr context, QmlComponentChain *ch
.absoluteFilePath();
}
foreach (const QmlComponentChain *c, chain->instantiatingComponents())
for (const QmlComponentChain *c : chain->instantiatingComponents())
additionalScopes.removeAll(c->document()->fileName());
foreach (const Utils::FilePath &scope, additionalScopes) {
for (const Utils::FilePath &scope : std::as_const(additionalScopes)) {
Document::Ptr doc = context->snapshot().document(scope);
if (doc) {
QmlComponentChain *ch = new QmlComponentChain(doc);
@@ -329,8 +329,8 @@ void ScopeChain::initializeRootScope()
// add scope chains for all components that import this file
// unless there's .pragma library
if (!m_document->bind()->isJsLibrary()) {
foreach (Document::Ptr otherDoc, snapshot) {
foreach (const ImportInfo &import, otherDoc->bind()->imports()) {
for (Document::Ptr otherDoc : snapshot) {
for (const ImportInfo &import : otherDoc->bind()->imports()) {
if ((import.type() == ImportType::File
&& m_document->fileName().toString() == import.path())
|| (import.type() == ImportType::QrcFile
@@ -368,7 +368,7 @@ void ScopeChain::makeComponentChain(
const Bind *bind = doc->bind();
// add scopes for all components instantiating this one
foreach (Document::Ptr otherDoc, snapshot) {
for (Document::Ptr otherDoc : snapshot) {
if (otherDoc == doc)
continue;
if (otherDoc->bind()->usesQmlPrototype(bind->rootObjectValue(), m_context)) {

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -26,7 +26,7 @@ public:
~QmlComponentChain();
Document::Ptr document() const;
QList<const QmlComponentChain *> instantiatingComponents() const;
const QList<const QmlComponentChain *> instantiatingComponents() const;
const ObjectValue *idScope() const;
const ObjectValue *rootObjectScope() const;
@@ -62,7 +62,7 @@ public:
QSharedPointer<const QmlComponentChain> qmlComponentChain() const;
void setQmlComponentChain(const QSharedPointer<const QmlComponentChain> &qmlComponentChain);
QList<const ObjectValue *> qmlScopeObjects() const;
const QList<const ObjectValue *> qmlScopeObjects() const;
void setQmlScopeObjects(const QList<const ObjectValue *> &qmlScopeObjects);
const TypeScope *qmlTypes() const;

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljssimplereader.h"
@@ -13,6 +13,7 @@
#include "qqmljsparser_p.h"
#endif
#include "qmljstr.h"
#include "qmljsutils.h"
#include <QFile>
@@ -110,7 +111,7 @@ static Q_LOGGING_CATEGORY(simpleReaderLog, "qtc.qmljs.simpleReader", QtWarningMs
file.close();
return readFromSource(QString::fromLocal8Bit(source));
}
addError(tr("Cannot find file %1.").arg(fileName));
addError(Tr::tr("Cannot find file %1.").arg(fileName));
return false;
}
@@ -157,14 +158,14 @@ static Q_LOGGING_CATEGORY(simpleReaderLog, "qtc.qmljs.simpleReader", QtWarningMs
bool SimpleAbstractStreamReader::readDocument(AST::UiProgram * ast)
{
if (!ast) {
addError(tr("Could not parse document."));
addError(Tr::tr("Could not parse document."));
return false;
}
AST::UiObjectDefinition *uiObjectDefinition = AST::cast<AST::UiObjectDefinition *>(
ast->members->member);
if (!uiObjectDefinition) {
addError(tr("Expected document to contain a single object definition."));
addError(Tr::tr("Expected document to contain a single object definition."));
return false;
}
readChild(uiObjectDefinition);
@@ -237,7 +238,7 @@ static Q_LOGGING_CATEGORY(simpleReaderLog, "qtc.qmljs.simpleReader", QtWarningMs
AST::ExpressionStatement *expStmt = AST::cast<AST::ExpressionStatement *>(
uiScriptBinding->statement);
if (!expStmt) {
addError(tr("Expected expression statement after colon."),
addError(Tr::tr("Expected expression statement after colon."),
uiScriptBinding->statement->firstSourceLocation());
return std::make_pair(QVariant(), SourceLocation());
}
@@ -339,7 +340,7 @@ static Q_LOGGING_CATEGORY(simpleReaderLog, "qtc.qmljs.simpleReader", QtWarningMs
if (m_currentNode.toStrongRef().data()->propertyNames().contains(name)) {
auto previousSourceLoc = m_currentNode.toStrongRef().data()->property(name).nameLocation;
addError(tr("Property is defined twice, previous definition at %1:%2")
addError(Tr::tr("Property is defined twice, previous definition at %1:%2")
.arg(QString::number(previousSourceLoc.startLine),
QString::number(previousSourceLoc.startColumn)),
currentSourceLocation());

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -18,9 +18,6 @@
#include <QVariant>
#include <QWeakPointer>
// for Q_DECLARE_TR_FUNCTIONS
#include <QCoreApplication>
namespace QmlJS {
#ifndef QT_CREATOR
@@ -84,8 +81,6 @@ using namespace QQmlJS;
class QMLJS_EXPORT SimpleAbstractStreamReader
{
Q_DECLARE_TR_FUNCTIONS(QmlJS::SimpleAbstractStreamReader)
public:
SimpleAbstractStreamReader();
virtual ~SimpleAbstractStreamReader();
@@ -124,8 +119,6 @@ private:
class QMLJS_EXPORT SimpleReader: public SimpleAbstractStreamReader
{
Q_DECLARE_TR_FUNCTIONS(QmlJS::SimpleReader)
public:
SimpleReader();
SimpleReaderNode::Ptr readFile(const QString &fileName);

View File

@@ -1,8 +1,11 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsstaticanalysismessage.h"
#include "qmljsconstants.h"
#include "qmljstr.h"
#include "parser/qmljsengine_p.h"
#include "parser/qmljsdiagnosticmessage_p.h"
@@ -19,8 +22,6 @@ namespace {
class StaticAnalysisMessages
{
Q_DECLARE_TR_FUNCTIONS(QmlJS::StaticAnalysisMessages)
public:
void newMsg(Type type, Enum severity, const QString &message, int placeholders = 0)
{
@@ -40,9 +41,9 @@ public:
static inline QString msgInvalidConstructor(const char *what)
{
return StaticAnalysisMessages::tr("Do not use \"%1\" as a constructor."
"\n\nFor more information, see the"
" \"Checking Code Syntax\" documentation.")
return Tr::tr("Do not use \"%1\" as a constructor."
"\n\nFor more information, see the"
" \"Checking Code Syntax\" documentation.")
.arg(QLatin1String(what));
}
@@ -51,63 +52,63 @@ StaticAnalysisMessages::StaticAnalysisMessages()
// When changing a message or severity, update the documentation, currently
// in creator-code-syntax.qdoc, accordingly.
newMsg(ErrInvalidEnumValue, Error,
tr("Invalid value for enum."));
Tr::tr("Invalid value for enum."));
newMsg(ErrEnumValueMustBeStringOrNumber, Error,
tr("Enum value must be a string or a number."));
Tr::tr("Enum value must be a string or a number."));
newMsg(ErrNumberValueExpected, Error,
tr("Number value expected."));
Tr::tr("Number value expected."));
newMsg(ErrBooleanValueExpected, Error,
tr("Boolean value expected."));
Tr::tr("Boolean value expected."));
newMsg(ErrStringValueExpected, Error,
tr("String value expected."));
Tr::tr("String value expected."));
newMsg(ErrInvalidUrl, Error,
tr("Invalid URL."));
Tr::tr("Invalid URL."));
newMsg(WarnFileOrDirectoryDoesNotExist, Warning,
tr("File or directory does not exist."));
Tr::tr("File or directory does not exist."));
newMsg(ErrInvalidColor, Error,
tr("Invalid color."));
Tr::tr("Invalid color."));
newMsg(ErrAnchorLineExpected, Error,
tr("Anchor line expected."));
Tr::tr("Anchor line expected."));
newMsg(ErrPropertiesCanOnlyHaveOneBinding, Error,
tr("Duplicate property binding."));
Tr::tr("Duplicate property binding."));
newMsg(ErrIdExpected, Error,
tr("Id expected."));
Tr::tr("Id expected."));
newMsg(ErrInvalidId, Error,
tr("Invalid id."));
Tr::tr("Invalid id."));
newMsg(ErrDuplicateId, Error,
tr("Duplicate id."));
Tr::tr("Duplicate id."));
newMsg(ErrInvalidPropertyName, Error,
tr("Invalid property name \"%1\"."), 1);
Tr::tr("Invalid property name \"%1\"."), 1);
newMsg(ErrDoesNotHaveMembers, Error,
tr("\"%1\" does not have members."), 1);
Tr::tr("\"%1\" does not have members."), 1);
newMsg(ErrInvalidMember, Error,
tr("\"%1\" is not a member of \"%2\"."), 2);
Tr::tr("\"%1\" is not a member of \"%2\"."), 2);
newMsg(WarnAssignmentInCondition, Warning,
tr("Assignment in condition."));
Tr::tr("Assignment in condition."));
newMsg(WarnCaseWithoutFlowControl, Warning,
tr("Unterminated non-empty case block."));
Tr::tr("Unterminated non-empty case block."));
newMsg(WarnEval, Warning,
tr("Do not use 'eval'."));
Tr::tr("Do not use 'eval'."));
newMsg(WarnUnreachable, Warning,
tr("Unreachable."));
Tr::tr("Unreachable."));
newMsg(WarnWith, Warning,
tr("Do not use 'with'."));
Tr::tr("Do not use 'with'."));
newMsg(WarnComma, Warning,
tr("Do not use comma expressions."));
Tr::tr("Do not use comma expressions."));
newMsg(WarnAlreadyFormalParameter, Warning,
tr("\"%1\" already is a formal parameter."), 1);
Tr::tr("\"%1\" already is a formal parameter."), 1);
newMsg(WarnUnnecessaryMessageSuppression, Warning,
tr("Unnecessary message suppression."));
Tr::tr("Unnecessary message suppression."));
newMsg(WarnAlreadyFunction, Warning,
tr("\"%1\" already is a function."), 1);
Tr::tr("\"%1\" already is a function."), 1);
newMsg(WarnVarUsedBeforeDeclaration, Warning,
tr("var \"%1\" is used before its declaration."), 1);
Tr::tr("var \"%1\" is used before its declaration."), 1);
newMsg(WarnAlreadyVar, Warning,
tr("\"%1\" already is a var."), 1);
Tr::tr("\"%1\" already is a var."), 1);
newMsg(WarnDuplicateDeclaration, Warning,
tr("\"%1\" is declared more than once."), 1);
Tr::tr("\"%1\" is declared more than once."), 1);
newMsg(WarnFunctionUsedBeforeDeclaration, Warning,
tr("Function \"%1\" is used before its declaration."), 1);
Tr::tr("Function \"%1\" is used before its declaration."), 1);
newMsg(WarnBooleanConstructor, Warning,
msgInvalidConstructor("Boolean"));
newMsg(WarnStringConstructor, Warning,
@@ -119,124 +120,124 @@ StaticAnalysisMessages::StaticAnalysisMessages()
newMsg(WarnFunctionConstructor, Warning,
msgInvalidConstructor("Function"));
newMsg(HintAnonymousFunctionSpacing, Hint,
tr("The 'function' keyword and the opening parenthesis should be separated by a single space."));
Tr::tr("The 'function' keyword and the opening parenthesis should be separated by a single space."));
newMsg(WarnBlock, Warning,
tr("Do not use stand-alone blocks."));
Tr::tr("Do not use stand-alone blocks."));
newMsg(WarnVoid, Warning,
tr("Do not use void expressions."));
Tr::tr("Do not use void expressions."));
newMsg(WarnConfusingPluses, Warning,
tr("Confusing pluses."));
Tr::tr("Confusing pluses."));
newMsg(WarnConfusingMinuses, Warning,
tr("Confusing minuses."));
Tr::tr("Confusing minuses."));
newMsg(HintDeclareVarsInOneLine, Hint,
tr("Declare all function vars on a single line."));
Tr::tr("Declare all function vars on a single line."));
newMsg(HintExtraParentheses, Hint,
tr("Unnecessary parentheses."));
Tr::tr("Unnecessary parentheses."));
newMsg(MaybeWarnEqualityTypeCoercion, MaybeWarning,
tr("== and != may perform type coercion, use === or !== to avoid it."));
Tr::tr("== and != may perform type coercion, use === or !== to avoid it."));
newMsg(WarnConfusingExpressionStatement, Warning,
tr("Expression statements should be assignments, calls or delete expressions only."));
Tr::tr("Expression statements should be assignments, calls or delete expressions only."));
newMsg(HintDeclarationsShouldBeAtStartOfFunction, Hint,
tr("Place var declarations at the start of a function."));
Tr::tr("Place var declarations at the start of a function."));
newMsg(HintOneStatementPerLine, Hint,
tr("Use only one statement per line."));
Tr::tr("Use only one statement per line."));
newMsg(ErrUnknownComponent, Error,
tr("Unknown component."));
Tr::tr("Unknown component."));
newMsg(ErrCouldNotResolvePrototypeOf, Error,
tr("Could not resolve the prototype \"%1\" of \"%2\"."), 2);
Tr::tr("Could not resolve the prototype \"%1\" of \"%2\"."), 2);
newMsg(ErrCouldNotResolvePrototype, Error,
tr("Could not resolve the prototype \"%1\"."), 1);
Tr::tr("Could not resolve the prototype \"%1\"."), 1);
newMsg(ErrPrototypeCycle, Error,
tr("Prototype cycle, the last non-repeated component is \"%1\"."), 1);
Tr::tr("Prototype cycle, the last non-repeated component is \"%1\"."), 1);
newMsg(ErrInvalidPropertyType, Error,
tr("Invalid property type \"%1\"."), 1);
Tr::tr("Invalid property type \"%1\"."), 1);
newMsg(WarnEqualityTypeCoercion, Error,
tr("== and != perform type coercion, use === or !== to avoid it."));
Tr::tr("== and != perform type coercion, use === or !== to avoid it."));
newMsg(WarnExpectedNewWithUppercaseFunction, Error,
tr("Calls of functions that start with an uppercase letter should use 'new'."));
Tr::tr("Calls of functions that start with an uppercase letter should use 'new'."));
newMsg(WarnNewWithLowercaseFunction, Error,
tr("Use 'new' only with functions that start with an uppercase letter."));
Tr::tr("Use 'new' only with functions that start with an uppercase letter."));
newMsg(WarnNumberConstructor, Error,
msgInvalidConstructor("Function"));
newMsg(HintBinaryOperatorSpacing, Hint,
tr("Use spaces around binary operators."));
Tr::tr("Use spaces around binary operators."));
newMsg(WarnUnintentinalEmptyBlock, Error,
tr("Unintentional empty block, use ({}) for empty object literal."));
Tr::tr("Unintentional empty block, use ({}) for empty object literal."));
newMsg(HintPreferNonVarPropertyType, Hint,
tr("Use %1 instead of 'var' or 'variant' to improve performance."), 1);
Tr::tr("Use %1 instead of 'var' or 'variant' to improve performance."), 1);
newMsg(ErrMissingRequiredProperty, Error,
tr("Missing property \"%1\"."), 1);
Tr::tr("Missing property \"%1\"."), 1);
newMsg(ErrObjectValueExpected, Error,
tr("Object value expected."));
Tr::tr("Object value expected."));
newMsg(ErrArrayValueExpected, Error,
tr("Array value expected."));
Tr::tr("Array value expected."));
newMsg(ErrDifferentValueExpected, Error,
tr("%1 value expected."), 1);
Tr::tr("%1 value expected."), 1);
newMsg(ErrSmallerNumberValueExpected, Error,
tr("Maximum number value is %1."), 1);
Tr::tr("Maximum number value is %1."), 1);
newMsg(ErrLargerNumberValueExpected, Error,
tr("Minimum number value is %1."), 1);
Tr::tr("Minimum number value is %1."), 1);
newMsg(ErrMaximumNumberValueIsExclusive, Error,
tr("Maximum number value is exclusive."));
Tr::tr("Maximum number value is exclusive."));
newMsg(ErrMinimumNumberValueIsExclusive, Error,
tr("Minimum number value is exclusive."));
Tr::tr("Minimum number value is exclusive."));
newMsg(ErrInvalidStringValuePattern, Error,
tr("String value does not match required pattern."));
Tr::tr("String value does not match required pattern."));
newMsg(ErrLongerStringValueExpected, Error,
tr("Minimum string value length is %1."), 1);
Tr::tr("Minimum string value length is %1."), 1);
newMsg(ErrShorterStringValueExpected, Error,
tr("Maximum string value length is %1."), 1);
Tr::tr("Maximum string value length is %1."), 1);
newMsg(ErrInvalidArrayValueLength, Error,
tr("%1 elements expected in array value."), 1);
Tr::tr("%1 elements expected in array value."), 1);
newMsg(WarnImperativeCodeNotEditableInVisualDesigner, Warning,
tr("Imperative code is not supported in Qt Design Studio."));
Tr::tr("Imperative code is not supported in Qt Design Studio."));
newMsg(WarnUnsupportedTypeInVisualDesigner, Warning,
tr("This type (%1) is not supported in Qt Design Studio."), 1);
Tr::tr("This type (%1) is not supported in Qt Design Studio."), 1);
newMsg(WarnReferenceToParentItemNotSupportedByVisualDesigner, Warning,
tr("Reference to parent item cannot be resolved correctly by Qt Design Studio."));
Tr::tr("Reference to parent item cannot be resolved correctly by Qt Design Studio."));
newMsg(WarnUndefinedValueForVisualDesigner, Warning,
tr("This visual property binding cannot be evaluated in the local context "
"and might not show up in Qt Design Studio as expected."));
Tr::tr("This visual property binding cannot be evaluated in the local context "
"and might not show up in Qt Design Studio as expected."));
newMsg(WarnStatesOnlyInRootItemForVisualDesigner, Warning,
tr("Qt Design Studio only supports states in the root item."));
Tr::tr("Qt Design Studio only supports states in the root item."));
newMsg(ErrInvalidIdeInVisualDesigner, Error,
tr("This id might be ambiguous and is not supported in Qt Design Studio."));
Tr::tr("This id might be ambiguous and is not supported in Qt Design Studio."));
newMsg(ErrUnsupportedRootTypeInVisualDesigner, Error,
tr("This type (%1) is not supported as a root element by Qt Design Studio."), 1);
Tr::tr("This type (%1) is not supported as a root element by Qt Design Studio."), 1);
newMsg(ErrUnsupportedRootTypeInQmlUi, Error,
tr("This type (%1) is not supported as a root element of a UI file (.ui.qml)."), 1);
Tr::tr("This type (%1) is not supported as a root element of a UI file (.ui.qml)."), 1);
newMsg(ErrUnsupportedTypeInQmlUi, Error,
tr("This type (%1) is not supported in a UI file (.ui.qml)."), 1);
Tr::tr("This type (%1) is not supported in a UI file (.ui.qml)."), 1);
newMsg(ErrFunctionsNotSupportedInQmlUi, Error,
tr("Functions are not supported in a UI file (.ui.qml)."));
Tr::tr("Functions are not supported in a UI file (.ui.qml)."));
newMsg(ErrBlocksNotSupportedInQmlUi, Error,
tr("JavaScript blocks are not supported in a UI file (.ui.qml)."));
Tr::tr("JavaScript blocks are not supported in a UI file (.ui.qml)."));
newMsg(ErrBehavioursNotSupportedInQmlUi, Error,
tr("Behavior type is not supported in a UI file (.ui.qml)."));
Tr::tr("Behavior type is not supported in a UI file (.ui.qml)."));
newMsg(ErrStatesOnlyInRootItemInQmlUi, Error,
tr("States are only supported in the root item in a UI file (.ui.qml)."));
Tr::tr("States are only supported in the root item in a UI file (.ui.qml)."));
newMsg(ErrReferenceToParentItemNotSupportedInQmlUi, Error,
tr("Referencing the parent of the root item is not supported in a UI file (.ui.qml)."));
Tr::tr("Referencing the parent of the root item is not supported in a UI file (.ui.qml)."));
newMsg(ErrDoNotMixTranslationFunctionsInQmlUi, Error,
tr("Do not mix translation functions in a UI file (.ui.qml)."));
Tr::tr("Do not mix translation functions in a UI file (.ui.qml)."));
newMsg(StateCannotHaveChildItem, Error,
tr("A State cannot have a child item (%1)."), 1);
Tr::tr("A State cannot have a child item (%1)."), 1);
newMsg(WarnDuplicateImport, Warning,
tr("Duplicate import (%1)."), 1);
Tr::tr("Duplicate import (%1)."), 1);
newMsg(ErrHitMaximumRecursion, Error,
tr("Hit maximum recursion limit when visiting AST."));
Tr::tr("Hit maximum recursion limit when visiting AST."));
newMsg(ErrTypeIsInstantiatedRecursively, Error,
tr("Type cannot be instantiated recursively (%1)."), 1);
Tr::tr("Type cannot be instantiated recursively (%1)."), 1);
newMsg(WarnLogicalValueDoesNotDependOnValues, Warning,
tr("Logical value does not depend on actual values."));
Tr::tr("Logical value does not depend on actual values."));
newMsg(ErrToManyComponentChildren, Error,
tr("Components are only allowed to have a single child element."));
Tr::tr("Components are only allowed to have a single child element."));
newMsg(WarnComponentRequiresChildren, Warning,
tr("Components require a child element."));
Tr::tr("Components require a child element."));
newMsg(ErrAliasReferRoot, Error,
tr("Do not reference the root item as alias."));
Tr::tr("Do not reference the root item as alias."));
newMsg(WarnAliasReferRootHierarchy, Warning,
tr("Avoid referencing the root item in a hierarchy."));
Tr::tr("Avoid referencing the root item in a hierarchy."));
}
} // anonymous namespace

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -9,7 +9,7 @@ namespace QmlJS {
struct Tr
{
Q_DECLARE_TR_FUNCTIONS(QmlJS)
Q_DECLARE_TR_FUNCTIONS(QtC::QmlJS)
};
} // QmlJS

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljstypedescriptionreader.h"
@@ -9,6 +9,7 @@
#include "parser/qmljsengine_p.h"
#include "qmljsinterpreter.h"
#include "qmljstr.h"
#include "qmljsutils.h"
#include <utils/qtcassert.h>
@@ -69,18 +70,18 @@ QString TypeDescriptionReader::warningMessage() const
void TypeDescriptionReader::readDocument(UiProgram *ast)
{
if (!ast) {
addError(SourceLocation(), tr("Could not parse document."));
addError(SourceLocation(), Tr::tr("Could not parse document."));
return;
}
if (!ast->headers || ast->headers->next || !AST::cast<AST::UiImport *>(ast->headers->headerItem)) {
addError(SourceLocation(), tr("Expected a single import."));
addError(SourceLocation(), Tr::tr("Expected a single import."));
return;
}
UiImport *import = AST::cast<AST::UiImport *>(ast->headers->headerItem);
if (toString(import->importUri) != QLatin1String("QtQuick.tooling")) {
addError(import->importToken, tr("Expected import of QtQuick.tooling."));
addError(import->importToken, Tr::tr("Expected import of QtQuick.tooling."));
return;
}
@@ -88,24 +89,24 @@ void TypeDescriptionReader::readDocument(UiProgram *ast)
if (UiVersionSpecifier *uiVersion = import->version) {
version = ComponentVersion(import->version->majorVersion, import->version->minorVersion);
if (version.majorVersion() != 1) {
addError(uiVersion->majorToken, tr("Major version different from 1 not supported."));
addError(uiVersion->majorToken, Tr::tr("Major version different from 1 not supported."));
return;
}
}
if (!ast->members || !ast->members->member || ast->members->next) {
addError(SourceLocation(), tr("Expected document to contain a single object definition."));
addError(SourceLocation(), Tr::tr("Expected document to contain a single object definition."));
return;
}
UiObjectDefinition *module = AST::cast<UiObjectDefinition *>(ast->members->member);
if (!module) {
addError(SourceLocation(), tr("Expected document to contain a single object definition."));
addError(SourceLocation(), Tr::tr("Expected document to contain a single object definition."));
return;
}
if (toString(module->qualifiedTypeNameId) != QLatin1String("Module")) {
addError(SourceLocation(), tr("Expected document to contain a Module {} member."));
addError(SourceLocation(), Tr::tr("Expected document to contain a Module {} member."));
return;
}
@@ -161,12 +162,12 @@ void TypeDescriptionReader::readDependencies(UiScriptBinding *ast)
{
ExpressionStatement *stmt = AST::cast<ExpressionStatement*>(ast->statement);
if (!stmt) {
addError(ast->statement->firstSourceLocation(), tr("Expected dependency definitions"));
addError(ast->statement->firstSourceLocation(), Tr::tr("Expected dependency definitions"));
return;
}
ArrayPattern *exp = AST::cast<ArrayPattern *>(stmt->expression);
if (!exp) {
addError(stmt->expression->firstSourceLocation(), tr("Expected dependency definitions"));
addError(stmt->expression->firstSourceLocation(), Tr::tr("Expected dependency definitions"));
return;
}
for (PatternElementList *l = exp->elements; l; l = l->next) {
@@ -219,7 +220,7 @@ void TypeDescriptionReader::readComponent(UiObjectDefinition *ast)
}
if (fmo->className().isEmpty()) {
addError(ast->firstSourceLocation(), tr("Component definition is missing a name binding."));
addError(ast->firstSourceLocation(), Tr::tr("Component definition is missing a name binding."));
return;
}
@@ -250,7 +251,7 @@ void TypeDescriptionReader::readModuleApi(UiObjectDefinition *ast)
}
if (!apiInfo.version.isValid()) {
addError(ast->firstSourceLocation(), tr("ModuleApi definition has no or invalid version binding."));
addError(ast->firstSourceLocation(), Tr::tr("ModuleApi definition has no or invalid version binding."));
return;
}
@@ -287,7 +288,7 @@ void TypeDescriptionReader::readSignalOrMethod(UiObjectDefinition *ast, bool isM
}
if (fmm.methodName().isEmpty()) {
addError(ast->firstSourceLocation(), tr("Method or signal is missing a name script binding."));
addError(ast->firstSourceLocation(), Tr::tr("Method or signal is missing a name script binding."));
return;
}
@@ -307,7 +308,7 @@ void TypeDescriptionReader::readProperty(UiObjectDefinition *ast, FakeMetaObject
UiObjectMember *member = it->member;
UiScriptBinding *script = AST::cast<UiScriptBinding *>(member);
if (!script) {
addWarning(member->firstSourceLocation(), tr("Expected script binding."));
addWarning(member->firstSourceLocation(), Tr::tr("Expected script binding."));
continue;
}
@@ -327,7 +328,7 @@ void TypeDescriptionReader::readProperty(UiObjectDefinition *ast, FakeMetaObject
}
if (name.isEmpty() || type.isEmpty()) {
addError(ast->firstSourceLocation(), tr("Property object is missing a name or type script binding."));
addError(ast->firstSourceLocation(), Tr::tr("Property object is missing a name or type script binding."));
return;
}
@@ -342,7 +343,7 @@ void TypeDescriptionReader::readEnum(UiObjectDefinition *ast, FakeMetaObject::Pt
UiObjectMember *member = it->member;
UiScriptBinding *script = AST::cast<UiScriptBinding *>(member);
if (!script) {
addWarning(member->firstSourceLocation(), tr("Expected script binding."));
addWarning(member->firstSourceLocation(), Tr::tr("Expected script binding."));
continue;
}
@@ -365,7 +366,7 @@ void TypeDescriptionReader::readParameter(UiObjectDefinition *ast, FakeMetaMetho
UiObjectMember *member = it->member;
UiScriptBinding *script = AST::cast<UiScriptBinding *>(member);
if (!script) {
addWarning(member->firstSourceLocation(), tr("Expected script binding."));
addWarning(member->firstSourceLocation(), Tr::tr("Expected script binding."));
continue;
}
@@ -391,19 +392,19 @@ QString TypeDescriptionReader::readStringBinding(UiScriptBinding *ast)
QTC_ASSERT(ast, return QString());
if (!ast->statement) {
addError(ast->colonToken, tr("Expected string after colon."));
addError(ast->colonToken, Tr::tr("Expected string after colon."));
return QString();
}
ExpressionStatement *expStmt = AST::cast<ExpressionStatement *>(ast->statement);
if (!expStmt) {
addError(ast->statement->firstSourceLocation(), tr("Expected string after colon."));
addError(ast->statement->firstSourceLocation(), Tr::tr("Expected string after colon."));
return QString();
}
StringLiteral *stringLit = AST::cast<StringLiteral *>(expStmt->expression);
if (!stringLit) {
addError(expStmt->firstSourceLocation(), tr("Expected string after colon."));
addError(expStmt->firstSourceLocation(), Tr::tr("Expected string after colon."));
return QString();
}
@@ -415,20 +416,20 @@ bool TypeDescriptionReader::readBoolBinding(AST::UiScriptBinding *ast)
QTC_ASSERT(ast, return false);
if (!ast->statement) {
addError(ast->colonToken, tr("Expected boolean after colon."));
addError(ast->colonToken, Tr::tr("Expected boolean after colon."));
return false;
}
ExpressionStatement *expStmt = AST::cast<ExpressionStatement *>(ast->statement);
if (!expStmt) {
addError(ast->statement->firstSourceLocation(), tr("Expected boolean after colon."));
addError(ast->statement->firstSourceLocation(), Tr::tr("Expected boolean after colon."));
return false;
}
TrueLiteral *trueLit = AST::cast<TrueLiteral *>(expStmt->expression);
FalseLiteral *falseLit = AST::cast<FalseLiteral *>(expStmt->expression);
if (!trueLit && !falseLit) {
addError(expStmt->firstSourceLocation(), tr("Expected true or false after colon."));
addError(expStmt->firstSourceLocation(), Tr::tr("Expected true or false after colon."));
return false;
}
@@ -440,19 +441,19 @@ double TypeDescriptionReader::readNumericBinding(AST::UiScriptBinding *ast)
QTC_ASSERT(ast, return qQNaN());
if (!ast->statement) {
addError(ast->colonToken, tr("Expected numeric literal after colon."));
addError(ast->colonToken, Tr::tr("Expected numeric literal after colon."));
return 0;
}
ExpressionStatement *expStmt = AST::cast<ExpressionStatement *>(ast->statement);
if (!expStmt) {
addError(ast->statement->firstSourceLocation(), tr("Expected numeric literal after colon."));
addError(ast->statement->firstSourceLocation(), Tr::tr("Expected numeric literal after colon."));
return 0;
}
NumericLiteral *numericLit = AST::cast<NumericLiteral *>(expStmt->expression);
if (!numericLit) {
addError(expStmt->firstSourceLocation(), tr("Expected numeric literal after colon."));
addError(expStmt->firstSourceLocation(), Tr::tr("Expected numeric literal after colon."));
return 0;
}
@@ -464,19 +465,19 @@ ComponentVersion TypeDescriptionReader::readNumericVersionBinding(UiScriptBindin
ComponentVersion invalidVersion;
if (!ast || !ast->statement) {
addError((ast ? ast->colonToken : SourceLocation()), tr("Expected numeric literal after colon."));
addError((ast ? ast->colonToken : SourceLocation()), Tr::tr("Expected numeric literal after colon."));
return invalidVersion;
}
ExpressionStatement *expStmt = AST::cast<ExpressionStatement *>(ast->statement);
if (!expStmt) {
addError(ast->statement->firstSourceLocation(), tr("Expected numeric literal after colon."));
addError(ast->statement->firstSourceLocation(), Tr::tr("Expected numeric literal after colon."));
return invalidVersion;
}
NumericLiteral *numericLit = AST::cast<NumericLiteral *>(expStmt->expression);
if (!numericLit) {
addError(expStmt->firstSourceLocation(), tr("Expected numeric literal after colon."));
addError(expStmt->firstSourceLocation(), Tr::tr("Expected numeric literal after colon."));
return invalidVersion;
}
@@ -489,7 +490,7 @@ int TypeDescriptionReader::readIntBinding(AST::UiScriptBinding *ast)
int i = static_cast<int>(v);
if (i != v) {
addError(ast->firstSourceLocation(), tr("Expected integer after colon."));
addError(ast->firstSourceLocation(), Tr::tr("Expected integer after colon."));
return 0;
}
@@ -501,26 +502,26 @@ void TypeDescriptionReader::readExports(UiScriptBinding *ast, FakeMetaObject::Pt
QTC_ASSERT(ast, return);
if (!ast->statement) {
addError(ast->colonToken, tr("Expected array of strings after colon."));
addError(ast->colonToken, Tr::tr("Expected array of strings after colon."));
return;
}
ExpressionStatement *expStmt = AST::cast<ExpressionStatement *>(ast->statement);
if (!expStmt) {
addError(ast->statement->firstSourceLocation(), tr("Expected array of strings after colon."));
addError(ast->statement->firstSourceLocation(), Tr::tr("Expected array of strings after colon."));
return;
}
ArrayPattern *arrayLit = AST::cast<ArrayPattern *>(expStmt->expression);
if (!arrayLit) {
addError(expStmt->firstSourceLocation(), tr("Expected array of strings after colon."));
addError(expStmt->firstSourceLocation(), Tr::tr("Expected array of strings after colon."));
return;
}
for (PatternElementList *it = arrayLit->elements; it; it = it->next) {
StringLiteral *stringLit = AST::cast<StringLiteral *>(it->element->initializer);
if (!stringLit) {
addError(arrayLit->firstSourceLocation(), tr("Expected array literal with only string literal members."));
addError(arrayLit->firstSourceLocation(), Tr::tr("Expected array literal with only string literal members."));
return;
}
QString exp = stringLit->value.toString();
@@ -529,7 +530,7 @@ void TypeDescriptionReader::readExports(UiScriptBinding *ast, FakeMetaObject::Pt
ComponentVersion version(exp.mid(spaceIdx + 1));
if (spaceIdx == -1 || !version.isValid()) {
addError(stringLit->firstSourceLocation(), tr("Expected string literal to contain 'Package/Name major.minor' or 'Name major.minor'."));
addError(stringLit->firstSourceLocation(), Tr::tr("Expected string literal to contain 'Package/Name major.minor' or 'Name major.minor'."));
continue;
}
QString package;
@@ -547,19 +548,19 @@ void TypeDescriptionReader::readMetaObjectRevisions(UiScriptBinding *ast, FakeMe
QTC_ASSERT(ast, return);
if (!ast->statement) {
addError(ast->colonToken, tr("Expected array of numbers after colon."));
addError(ast->colonToken, Tr::tr("Expected array of numbers after colon."));
return;
}
ExpressionStatement *expStmt = AST::cast<ExpressionStatement *>(ast->statement);
if (!expStmt) {
addError(ast->statement->firstSourceLocation(), tr("Expected array of numbers after colon."));
addError(ast->statement->firstSourceLocation(), Tr::tr("Expected array of numbers after colon."));
return;
}
ArrayPattern *arrayLit = AST::cast<ArrayPattern *>(expStmt->expression);
if (!arrayLit) {
addError(expStmt->firstSourceLocation(), tr("Expected array of numbers after colon."));
addError(expStmt->firstSourceLocation(), Tr::tr("Expected array of numbers after colon."));
return;
}
@@ -568,19 +569,19 @@ void TypeDescriptionReader::readMetaObjectRevisions(UiScriptBinding *ast, FakeMe
for (PatternElementList *it = arrayLit->elements; it; it = it->next, ++exportIndex) {
NumericLiteral *numberLit = cast<NumericLiteral *>(it->element->initializer);
if (!numberLit) {
addError(arrayLit->firstSourceLocation(), tr("Expected array literal with only number literal members."));
addError(arrayLit->firstSourceLocation(), Tr::tr("Expected array literal with only number literal members."));
return;
}
if (exportIndex >= exportCount) {
addError(numberLit->firstSourceLocation(), tr("Meta object revision without matching export."));
addError(numberLit->firstSourceLocation(), Tr::tr("Meta object revision without matching export."));
return;
}
const double v = numberLit->value;
const int metaObjectRevision = static_cast<int>(v);
if (metaObjectRevision != v) {
addError(numberLit->firstSourceLocation(), tr("Expected integer."));
addError(numberLit->firstSourceLocation(), Tr::tr("Expected integer."));
return;
}
@@ -593,13 +594,13 @@ void TypeDescriptionReader::readEnumValues(AST::UiScriptBinding *ast, LanguageUt
if (!ast)
return;
if (!ast->statement) {
addError(ast->colonToken, tr("Expected object literal after colon."));
addError(ast->colonToken, Tr::tr("Expected object literal after colon."));
return;
}
auto *expStmt = AST::cast<ExpressionStatement *>(ast->statement);
if (!expStmt) {
addError(ast->statement->firstSourceLocation(), tr("Expected expression after colon."));
addError(ast->statement->firstSourceLocation(), Tr::tr("Expected expression after colon."));
return;
}
@@ -611,7 +612,7 @@ void TypeDescriptionReader::readEnumValues(AST::UiScriptBinding *ast, LanguageUt
continue;
}
}
addError(it->firstSourceLocation(), tr("Expected strings as enum keys."));
addError(it->firstSourceLocation(), Tr::tr("Expected strings as enum keys."));
}
} else if (auto *arrayLit = AST::cast<ArrayPattern *>(expStmt->expression)) {
for (PatternElementList *it = arrayLit->elements; it; it = it->next) {
@@ -621,10 +622,10 @@ void TypeDescriptionReader::readEnumValues(AST::UiScriptBinding *ast, LanguageUt
continue;
}
}
addError(it->firstSourceLocation(), tr("Expected strings as enum keys."));
addError(it->firstSourceLocation(), Tr::tr("Expected strings as enum keys."));
}
} else {
addError(ast->statement->firstSourceLocation(),
tr("Expected either array or object literal as enum definition."));
Tr::tr("Expected either array or object literal as enum definition."));
}
}

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
@@ -8,9 +8,6 @@
#include <languageutils/fakemetaobject.h>
// for Q_DECLARE_TR_FUNCTIONS
#include <QCoreApplication>
QT_BEGIN_NAMESPACE
class QIODevice;
class QBuffer;
@@ -28,8 +25,6 @@ class UiScriptBinding;
class QMLJS_EXPORT TypeDescriptionReader
{
Q_DECLARE_TR_FUNCTIONS(QmlJS::TypeDescriptionReader)
public:
explicit TypeDescriptionReader(const QString &fileName, const QString &data);
~TypeDescriptionReader();

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsutils.h"

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsvalueowner.h"

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

View File

@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once