forked from qt-creator/qt-creator
Update the qml code model parser
Updates the qml code model from qtdeclarative dev (commit: 164d8f66d82deea74464c68a2cdd19e5998835da). Fixes: QTCREATORBUG-28238 Change-Id: I383c98012f1efd56110d43c258fa1b398a6f8255 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -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+ OR GPL-3.0 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+ OR GPL-3.0 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+ OR GPL-3.0 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+ OR GPL-3.0 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;
|
||||
}
|
||||
|
||||
|
@@ -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+ OR GPL-3.0 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 {
|
||||
|
@@ -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+ OR GPL-3.0 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,
|
||||
@@ -292,6 +312,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))
|
||||
|
@@ -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+ OR GPL-3.0 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;
|
||||
|
@@ -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+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "qmlimportresolver_p.h"
|
||||
#include <QtCore/QList>
|
||||
|
@@ -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+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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('>'));
|
||||
};
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
#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;
|
||||
|
||||
|
@@ -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 {}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -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[];
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,5 @@
|
||||
|
||||
#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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
@@ -2100,9 +2100,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.
|
||||
@@ -2118,7 +2118,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())
|
||||
@@ -2142,7 +2142,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;
|
||||
}
|
||||
@@ -2169,9 +2169,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
|
||||
|
Reference in New Issue
Block a user