forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/5.0'
Change-Id: I9409f35cb9d1bc2e57631d2bfa3a0931ff5dd259
This commit is contained in:
@@ -4,6 +4,7 @@ add_qtc_library(QmlJS
|
||||
SOURCES
|
||||
jsoncheck.cpp jsoncheck.h
|
||||
parser/qmldirparser.cpp parser/qmldirparser_p.h
|
||||
parser/qmlimportresolver.cpp parser/qmlimportresolver_p.h
|
||||
parser/qmljsast.cpp parser/qmljsast_p.h
|
||||
parser/qmljsastfwd_p.h
|
||||
parser/qmljsastvisitor.cpp parser/qmljsastvisitor_p.h
|
||||
|
||||
@@ -10,6 +10,21 @@
|
||||
# cd src/libs/qmljs/parser
|
||||
# QTDIR=~/path/to/qtdeclarative-checkout ./gen-parser.sh
|
||||
|
||||
###
|
||||
# to update this script:
|
||||
# 1. do all changes & commit them
|
||||
# 2. run this script commenting out the two patch commands in the last lines below
|
||||
# 3. update the first patch using
|
||||
# # git diff > grammar.patch
|
||||
# 4. uncomment the first (grammar) patch, re-run script
|
||||
# 5. update the second patch with
|
||||
# # git diff > parser.patch
|
||||
# 6. parser.patch needs to be manually edited to remove the patching
|
||||
# of non relevant files (gen-parser.sh, grammar.patch, parser.patch, qmljs.g)
|
||||
# 7. test by running again with the patch commands activated and verify the diffs.
|
||||
# 8. commit the updated .patch files
|
||||
###
|
||||
|
||||
if [ -z "$QTDIR" -o -z "$QLALR" ]; then
|
||||
echo "Usage: QTDIR=~/path/to/qtdeclarative-checkout QLALR=~/path/to/qlalr $0" 1>&2
|
||||
exit 1
|
||||
@@ -18,7 +33,7 @@ fi
|
||||
|
||||
me=$(dirname $0)
|
||||
|
||||
for i in $QTDIR/src/qml/parser/*.{g,h,cpp,pri}; do
|
||||
for i in $QTDIR/src/qml/parser/*.{g,h,cpp}; do
|
||||
if ! echo $i | grep -q qmljsglobal; then
|
||||
sed -f $me/cmd.sed $i > $me/$(echo $(basename $i) | sed s/qqmljs/qmljs/)
|
||||
fi
|
||||
@@ -59,9 +74,9 @@ sed -i -e 's/qt_qnan/qQNaN/' $me/qmljsengine_p.cpp
|
||||
sed -i -e 's|#include <QtCore/private/qnumeric_p.h>|#include <QtCore/qnumeric.h>|' $me/qmljsengine_p.cpp
|
||||
perl -p -0777 -i -e 's/QT_QML_BEGIN_NAMESPACE/#include <qmljs\/qmljsconstants.h>\nQT_QML_BEGIN_NAMESPACE/' qmljsengine_p.h
|
||||
|
||||
patch -p1 < grammar.patch
|
||||
patch -R -p5 < grammar.patch
|
||||
$QLALR qmljs.g
|
||||
|
||||
./changeLicense.py $me/../qmljs_global.h qml*.{cpp,h}
|
||||
|
||||
patch -p1 < parser.patch
|
||||
patch -p5 -R < parser.patch
|
||||
|
||||
@@ -1,21 +1,56 @@
|
||||
diff -u parser-genOut/qmljs.g parser/qmljs.g
|
||||
--- parser-genOut/qmljs.g 2020-03-02 13:53:50.000000000 +0100
|
||||
+++ parser/qmljs.g 2020-03-02 13:55:50.000000000 +0100
|
||||
@@ -379,7 +379,7 @@
|
||||
diff --git a/src/libs/qmljs/parser/qmljs.g b/src/libs/qmljs/parser/qmljs.g
|
||||
index ae79830d2e..32a2f6f4b0 100644
|
||||
--- a/src/libs/qmljs/parser/qmljs.g
|
||||
+++ b/src/libs/qmljs/parser/qmljs.g
|
||||
@@ -380,7 +380,7 @@ public:
|
||||
inline DiagnosticMessage diagnosticMessage() const
|
||||
{
|
||||
for (const DiagnosticMessage &d : diagnostic_messages) {
|
||||
- if (d.type != QtWarningMsg)
|
||||
+ if (d.kind != Severity::Warning)
|
||||
- if (d.kind != Severity::Warning)
|
||||
+ if (d.type != QtWarningMsg)
|
||||
return d;
|
||||
}
|
||||
|
||||
@@ -423,7 +423,7 @@
|
||||
@@ -424,7 +424,7 @@ protected:
|
||||
DiagnosticMessage error;
|
||||
error.loc = location;
|
||||
error.message = message;
|
||||
- error.type = kind;
|
||||
+ error.kind = DiagnosticMessage::qtMsgTypeToKind(kind);
|
||||
- error.kind = DiagnosticMessage::qtMsgTypeToKind(kind);
|
||||
+ error.type = kind;
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -445,8 +445,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;
|
||||
|
||||
@@ -838,7 +838,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.")));
|
||||
@@ -851,11 +851,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.")));
|
||||
|
||||
@@ -1,83 +1,464 @@
|
||||
diff -u parser-genOut/qmljsgrammar.cpp parser/qmljsgrammar.cpp
|
||||
--- parser-genOut/qmljsgrammar.cpp 2020-03-02 13:53:50.000000000 +0100
|
||||
+++ parser/qmljsgrammar.cpp 2020-03-02 14:16:26.000000000 +0100
|
||||
@@ -21,7 +21,8 @@
|
||||
diff --git a/src/libs/qmljs/parser/qmldirparser.cpp b/src/libs/qmljs/parser/qmldirparser.cpp
|
||||
index cba1cf62c3..404beefe4a 100644
|
||||
--- a/src/libs/qmljs/parser/qmldirparser.cpp
|
||||
+++ b/src/libs/qmljs/parser/qmldirparser.cpp
|
||||
@@ -25,14 +25,10 @@
|
||||
|
||||
#include "qmldirparser_p.h"
|
||||
|
||||
-#include <utils/qtcassert.h>
|
||||
-
|
||||
#include <QtCore/QtDebug>
|
||||
|
||||
QT_QML_BEGIN_NAMESPACE
|
||||
|
||||
-using namespace LanguageUtils;
|
||||
-
|
||||
static int parseInt(QStringView str, bool *ok)
|
||||
{
|
||||
int pos = 0;
|
||||
@@ -50,45 +46,17 @@ static int parseInt(QStringView str, bool *ok)
|
||||
return number;
|
||||
}
|
||||
|
||||
-static bool parseVersion(const QString &str, int *major, int *minor)
|
||||
+static QTypeRevision parseVersion(const QString &str)
|
||||
{
|
||||
const int dotIndex = str.indexOf(QLatin1Char('.'));
|
||||
if (dotIndex != -1 && str.indexOf(QLatin1Char('.'), dotIndex + 1) == -1) {
|
||||
bool ok = false;
|
||||
- *major = parseInt(QStringView(str.constData(), dotIndex), &ok);
|
||||
- if (ok)
|
||||
- *minor = parseInt(QStringView(str.constData() + dotIndex + 1, str.length() - dotIndex - 1),
|
||||
- &ok);
|
||||
- return ok;
|
||||
- }
|
||||
- return false;
|
||||
-}
|
||||
-
|
||||
-static ComponentVersion parseImportVersion(const QString &str)
|
||||
-{
|
||||
- int minor = -1;
|
||||
- int major = -1;
|
||||
- const int dotIndex = str.indexOf(QLatin1Char('.'));
|
||||
- bool ok = false;
|
||||
- if (dotIndex != -1 && str.indexOf(QLatin1Char('.'), dotIndex + 1) == -1) {
|
||||
- major = parseInt(QStringView(str.constData(), dotIndex), &ok);
|
||||
- if (ok) {
|
||||
- if (str.length() > dotIndex + 1) {
|
||||
- minor = parseInt(QStringView(str.constData() + dotIndex + 1, str.length() - dotIndex - 1),
|
||||
- &ok);
|
||||
- if (!ok)
|
||||
- minor = ComponentVersion::NoVersion;
|
||||
- } else {
|
||||
- minor = ComponentVersion::MaxVersion;
|
||||
- }
|
||||
- }
|
||||
- } else if (str.length() > 0) {
|
||||
- QTC_ASSERT(str != QLatin1String("auto"), return ComponentVersion(-1, -1));
|
||||
- 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()
|
||||
@@ -131,12 +99,12 @@ bool QmlDirParser::parse(const QString &source)
|
||||
auto readImport = [&](const QString *sections, int sectionCount, Import::Flags flags) {
|
||||
Import import;
|
||||
if (sectionCount == 2) {
|
||||
- import = Import(sections[1], ComponentVersion(), flags);
|
||||
+ import = Import(sections[1], QTypeRevision(), flags);
|
||||
} else if (sectionCount == 3) {
|
||||
if (sections[2] == QLatin1String("auto")) {
|
||||
- import = Import(sections[1], ComponentVersion(), flags | Import::Auto);
|
||||
+ import = Import(sections[1], QTypeRevision(), flags | Import::Auto);
|
||||
} else {
|
||||
- const auto version = parseImportVersion(sections[2]);
|
||||
+ const auto version = parseVersion(sections[2]);
|
||||
if (version.isValid()) {
|
||||
import = Import(sections[1], version, flags);
|
||||
} else {
|
||||
@@ -274,7 +242,7 @@ bool QmlDirParser::parse(const QString &source)
|
||||
QStringLiteral("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1));
|
||||
continue;
|
||||
}
|
||||
- Component entry(sections[1], sections[2], -1, -1);
|
||||
+ Component entry(sections[1], sections[2], QTypeRevision());
|
||||
entry.internal = true;
|
||||
_components.insert(entry.typeName, entry);
|
||||
} else if (sections[0] == QLatin1String("singleton")) {
|
||||
@@ -285,16 +253,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
|
||||
- Component entry(sections[1], sections[2], -1, -1);
|
||||
+ Component entry(sections[1], sections[2], QTypeRevision());
|
||||
entry.singleton = true;
|
||||
_components.insert(entry.typeName, entry);
|
||||
} else {
|
||||
// handle qmldir module listing case where singleton is defined in the following pattern:
|
||||
// singleton TestSingletonType 2.0 TestSingletonType20.qml
|
||||
- int major, minor;
|
||||
- if (parseVersion(sections[2], &major, &minor)) {
|
||||
+ const QTypeRevision version = parseVersion(sections[2]);
|
||||
+ if (version.isValid()) {
|
||||
const QString &fileName = sections[3];
|
||||
- Component entry(sections[1], fileName, major, minor);
|
||||
+ Component entry(sections[1], fileName, version);
|
||||
entry.singleton = true;
|
||||
_components.insert(entry.typeName, entry);
|
||||
} else {
|
||||
@@ -341,19 +309,19 @@ bool QmlDirParser::parse(const QString &source)
|
||||
_preferredPath = sections[1];
|
||||
} else if (sectionCount == 2) {
|
||||
// No version specified (should only be used for relative qmldir files)
|
||||
- const Component entry(sections[0], sections[1], -1, -1);
|
||||
+ const Component entry(sections[0], sections[1], QTypeRevision());
|
||||
_components.insert(entry.typeName, entry);
|
||||
} else if (sectionCount == 3) {
|
||||
- int major, minor;
|
||||
- if (parseVersion(sections[1], &major, &minor)) {
|
||||
+ const QTypeRevision version = parseVersion(sections[1]);
|
||||
+ if (version.isValid()) {
|
||||
const QString &fileName = sections[2];
|
||||
|
||||
if (fileName.endsWith(QLatin1String(".js")) || fileName.endsWith(QLatin1String(".mjs"))) {
|
||||
// A 'js' extension indicates a namespaced script import
|
||||
- const Script entry(sections[0], fileName, major, minor);
|
||||
+ const Script entry(sections[0], fileName, version);
|
||||
_scripts.append(entry);
|
||||
} else {
|
||||
- const Component entry(sections[0], fileName, major, minor);
|
||||
+ const Component entry(sections[0], fileName, version);
|
||||
_components.insert(entry.typeName, entry);
|
||||
}
|
||||
} else {
|
||||
@@ -400,15 +368,17 @@ QList<QmlJS::DiagnosticMessage> QmlDirParser::errors(const QString &uri) const
|
||||
|
||||
QDebug &operator<< (QDebug &debug, const QmlDirParser::Component &component)
|
||||
{
|
||||
- const QString output = QStringLiteral("{%1 %2.%3}").
|
||||
- arg(component.typeName).arg(component.majorVersion).arg(component.minorVersion);
|
||||
+ const QString output = QStringLiteral("{%1 %2.%3}")
|
||||
+ .arg(component.typeName).arg(component.version.majorVersion())
|
||||
+ .arg(component.version.minorVersion());
|
||||
return debug << qPrintable(output);
|
||||
}
|
||||
|
||||
QDebug &operator<< (QDebug &debug, const QmlDirParser::Script &script)
|
||||
{
|
||||
- const QString output = QStringLiteral("{%1 %2.%3}").
|
||||
- arg(script.nameSpace).arg(script.majorVersion).arg(script.minorVersion);
|
||||
+ const QString output = QStringLiteral("{%1 %2.%3}")
|
||||
+ .arg(script.nameSpace).arg(script.version.majorVersion())
|
||||
+ .arg(script.version.minorVersion());
|
||||
return debug << qPrintable(output);
|
||||
}
|
||||
|
||||
diff --git a/src/libs/qmljs/parser/qmldirparser_p.h b/src/libs/qmljs/parser/qmldirparser_p.h
|
||||
index 529a44078a..f83a4ec8a0 100644
|
||||
--- a/src/libs/qmljs/parser/qmldirparser_p.h
|
||||
+++ b/src/libs/qmljs/parser/qmldirparser_p.h
|
||||
@@ -39,11 +39,8 @@
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QDebug>
|
||||
-
|
||||
-#include <languageutils/componentversion.h>
|
||||
-
|
||||
+#include <QtCore/QTypeRevision>
|
||||
#include "qmljs/parser/qmljsglobal_p.h"
|
||||
-#include "qmljs/parser/qmljsengine_p.h"
|
||||
#include "qmljs/parser/qmljsdiagnosticmessage_p.h"
|
||||
|
||||
QT_QML_BEGIN_NAMESPACE
|
||||
@@ -90,8 +87,8 @@ public:
|
||||
{
|
||||
Component() = default;
|
||||
|
||||
- Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion)
|
||||
- : typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion),
|
||||
+ Component(const QString &typeName, const QString &fileName, QTypeRevision version)
|
||||
+ : typeName(typeName), fileName(fileName), version(version),
|
||||
internal(false), singleton(false)
|
||||
{
|
||||
checkNonRelative("Component", typeName, fileName);
|
||||
@@ -99,8 +96,7 @@ public:
|
||||
|
||||
QString typeName;
|
||||
QString fileName;
|
||||
- int majorVersion = 0;
|
||||
- int minorVersion = 0;
|
||||
+ QTypeRevision version = QTypeRevision::zero();
|
||||
bool internal = false;
|
||||
bool singleton = false;
|
||||
};
|
||||
@@ -109,16 +105,15 @@ public:
|
||||
{
|
||||
Script() = default;
|
||||
|
||||
- Script(const QString &nameSpace, const QString &fileName, int majorVersion, int minorVersion)
|
||||
- : nameSpace(nameSpace), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion)
|
||||
+ Script(const QString &nameSpace, const QString &fileName, QTypeRevision version)
|
||||
+ : nameSpace(nameSpace), fileName(fileName), version(version)
|
||||
{
|
||||
checkNonRelative("Script", nameSpace, fileName);
|
||||
}
|
||||
|
||||
QString nameSpace;
|
||||
QString fileName;
|
||||
- int majorVersion = 0;
|
||||
- int minorVersion = 0;
|
||||
+ QTypeRevision version = QTypeRevision::zero();
|
||||
};
|
||||
|
||||
struct Import
|
||||
@@ -131,13 +126,13 @@ public:
|
||||
Q_DECLARE_FLAGS(Flags, Flag)
|
||||
|
||||
Import() = default;
|
||||
- Import(QString module, LanguageUtils::ComponentVersion version, Flags flags)
|
||||
+ Import(QString module, QTypeRevision version, Flags flags)
|
||||
: module(module), version(version), flags(flags)
|
||||
{
|
||||
}
|
||||
|
||||
QString module;
|
||||
- LanguageUtils::ComponentVersion version; // invalid version is latest version, unless Flag::Auto
|
||||
+ QTypeRevision version; // invalid version is latest version, unless Flag::Auto
|
||||
Flags flags;
|
||||
};
|
||||
|
||||
diff --git a/src/libs/qmljs/parser/qmlimportresolver.cpp b/src/libs/qmljs/parser/qmlimportresolver.cpp
|
||||
index 06f04a14e7..2a6608a1da 100644
|
||||
--- a/src/libs/qmljs/parser/qmlimportresolver.cpp
|
||||
+++ b/src/libs/qmljs/parser/qmlimportresolver.cpp
|
||||
@@ -41,7 +41,7 @@ enum ImportVersion { FullyVersioned, PartiallyVersioned, Unversioned };
|
||||
- base/QtQml/Models
|
||||
*/
|
||||
QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths,
|
||||
- LanguageUtils::ComponentVersion version)
|
||||
+ QTypeRevision version)
|
||||
{
|
||||
static const QLatin1Char Slash('/');
|
||||
static const QLatin1Char Backslash('\\');
|
||||
@@ -46,13 +46,13 @@ QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths
|
||||
static const QLatin1Char Slash('/');
|
||||
static const QLatin1Char Backslash('\\');
|
||||
|
||||
- const QList<QStringView> parts = uri.split(u'.', Qt::SkipEmptyParts);
|
||||
+ const QVector<QStringView> parts = uri.split(u'.', Qt::SkipEmptyParts);
|
||||
|
||||
QStringList importPaths;
|
||||
// fully & partially versioned parts + 1 unversioned for each base path
|
||||
importPaths.reserve(2 * parts.count() + 1);
|
||||
|
||||
- auto versionString = [](LanguageUtils::ComponentVersion version, ImportVersion mode)
|
||||
+ auto versionString = [](QTypeRevision version, ImportVersion mode)
|
||||
{
|
||||
if (mode == FullyVersioned) {
|
||||
// extension with fully encoded version number (eg. MyModule.3.2)
|
||||
@@ -67,7 +67,7 @@ QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths
|
||||
return QString();
|
||||
};
|
||||
|
||||
- auto joinStringRefs = [](const QList<QStringView> &refs, const QChar &sep) {
|
||||
+ auto joinStringRefs = [](const QVector<QStringView> &refs, const QChar &sep) {
|
||||
QString str;
|
||||
for (auto it = refs.cbegin(); it != refs.cend(); ++it) {
|
||||
if (it != refs.cbegin())
|
||||
@@ -77,9 +77,9 @@ QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths
|
||||
return str;
|
||||
};
|
||||
|
||||
- const ImportVersion initial = ((version.minorVersion() >= 0)
|
||||
+ const ImportVersion initial = (version.hasMinorVersion())
|
||||
? FullyVersioned
|
||||
- : ((version.majorVersion() >= 0) ? PartiallyVersioned : Unversioned));
|
||||
+ : (version.hasMajorVersion() ? PartiallyVersioned : Unversioned);
|
||||
for (int mode = initial; mode <= Unversioned; ++mode) {
|
||||
const QString ver = versionString(version, ImportVersion(mode));
|
||||
|
||||
diff --git a/src/libs/qmljs/parser/qmlimportresolver_p.h b/src/libs/qmljs/parser/qmlimportresolver_p.h
|
||||
index 8f0bf7f6e4..8d0b4ed838 100644
|
||||
--- a/src/libs/qmljs/parser/qmlimportresolver_p.h
|
||||
+++ b/src/libs/qmljs/parser/qmlimportresolver_p.h
|
||||
@@ -40,11 +40,12 @@
|
||||
|
||||
#include "qmljsglobal_p.h"
|
||||
#include <QtCore/qstring.h>
|
||||
-#include <languageutils/componentversion.h>
|
||||
+#include <QtCore/qversionnumber.h>
|
||||
|
||||
QT_QML_BEGIN_NAMESPACE
|
||||
|
||||
QML_PARSER_EXPORT QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths,
|
||||
- LanguageUtils::ComponentVersion version);
|
||||
+ QTypeRevision version);
|
||||
|
||||
QT_QML_END_NAMESPACE
|
||||
+
|
||||
diff --git a/src/libs/qmljs/parser/qmljsast_p.h b/src/libs/qmljs/parser/qmljsast_p.h
|
||||
index ba1f642629..e286571e2e 100644
|
||||
--- a/src/libs/qmljs/parser/qmljsast_p.h
|
||||
+++ b/src/libs/qmljs/parser/qmljsast_p.h
|
||||
@@ -654,12 +654,12 @@ class QML_PARSER_EXPORT UiVersionSpecifier : public Node
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(UiVersionSpecifier)
|
||||
|
||||
- UiVersionSpecifier(int majorum) : majorVersion(majorum)
|
||||
+ UiVersionSpecifier(int majorum) : version(QTypeRevision::fromMajorVersion(majorum))
|
||||
{
|
||||
kind = K;
|
||||
}
|
||||
|
||||
- UiVersionSpecifier(int majorum, int minorum) : majorVersion(majorum), minorVersion(minorum)
|
||||
+ UiVersionSpecifier(int majorum, int minorum) : version(QTypeRevision::fromVersion(majorum, minorum))
|
||||
{
|
||||
kind = K;
|
||||
}
|
||||
@@ -674,8 +674,7 @@ public:
|
||||
}
|
||||
|
||||
// attributes:
|
||||
- int majorVersion = -1;
|
||||
- int minorVersion = -1;
|
||||
+ QTypeRevision version;
|
||||
SourceLocation majorToken;
|
||||
SourceLocation minorToken;
|
||||
};
|
||||
@@ -880,12 +879,11 @@ 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>
|
||||
@@ -3724,3 +3722,4 @@ public:
|
||||
|
||||
|
||||
QT_QML_END_NAMESPACE
|
||||
+
|
||||
diff --git a/src/libs/qmljs/parser/qmljsgrammar.cpp b/src/libs/qmljs/parser/qmljsgrammar.cpp
|
||||
index 3d60e96373..01b98a5033 100644
|
||||
--- a/src/libs/qmljs/parser/qmljsgrammar.cpp
|
||||
+++ b/src/libs/qmljs/parser/qmljsgrammar.cpp
|
||||
@@ -21,8 +21,7 @@
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** 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!
|
||||
-***************************************************************************/
|
||||
-// This file was generated by qlalr - DO NOT EDIT!
|
||||
+***************************************************************************// This file was generated by qlalr - DO NOT EDIT!
|
||||
#include "qmljsgrammar_p.h"
|
||||
|
||||
|
||||
const char *const QmlJSGrammar::spell [] = {
|
||||
diff -u parser-genOut/qmljsgrammar_p.h parser/qmljsgrammar_p.h
|
||||
--- parser/qmljsgrammar_p.h 2020-03-03 13:51:43.000000000 +0100
|
||||
+++ parser-fixed2/qmljsgrammar_p.h 2020-03-02 17:20:56.000000000 +0100
|
||||
@@ -21,11 +21,13 @@
|
||||
diff --git a/src/libs/qmljs/parser/qmljsgrammar_p.h b/src/libs/qmljs/parser/qmljsgrammar_p.h
|
||||
index 43ad1b4950..ae32388aa5 100644
|
||||
--- a/src/libs/qmljs/parser/qmljsgrammar_p.h
|
||||
+++ b/src/libs/qmljs/parser/qmljsgrammar_p.h
|
||||
@@ -21,13 +21,11 @@
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** 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!
|
||||
-***************************************************************************/
|
||||
-// 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 QmlJSGrammar
|
||||
+class QML_PARSER_EXPORT QmlJSGrammar
|
||||
-#include "qmljsglobal_p.h"
|
||||
|
||||
-class QML_PARSER_EXPORT QmlJSGrammar
|
||||
+class QmlJSGrammar
|
||||
{
|
||||
public:
|
||||
enum VariousConstants {
|
||||
diff -u parser-genOut/qmljslexer_p.h parser/qmljslexer_p.h
|
||||
--- parser-genOut/qmljslexer_p.h 2020-03-02 13:53:50.000000000 +0100
|
||||
+++ parser/qmljslexer_p.h 2020-03-02 13:55:13.000000000 +0100
|
||||
@@ -47,7 +47,7 @@
|
||||
namespace QmlJS {
|
||||
|
||||
class Engine;
|
||||
-struct DiagnosticMessage;
|
||||
+class DiagnosticMessage;
|
||||
class Directives;
|
||||
|
||||
class QML_PARSER_EXPORT Lexer: public QmlJSGrammar
|
||||
diff -u parser-genOut/qmljsparser.cpp parser/qmljsparser.cpp
|
||||
--- parser-genOut/qmljsparser.cpp 2020-03-02 13:53:50.000000000 +0100
|
||||
+++ parser/qmljsparser.cpp 2020-03-02 14:16:01.000000000 +0100
|
||||
@@ -22,5 +22,6 @@
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
+#line 172 "qmljs.g"
|
||||
|
||||
#include "qmljs/parser/qmljsengine_p.h"
|
||||
diff -u parser-genOut/qmljsparser_p.h parser/qmljsparser_p.h
|
||||
--- parser-genOut/qmljsparser_p.h 2020-03-02 13:53:50.000000000 +0100
|
||||
+++ parser/qmljsparser_p.h 2020-03-02 14:13:25.000000000 +0100
|
||||
@@ -22,6 +22,7 @@
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
+#line 223 "qmljs.g"
|
||||
|
||||
|
||||
//
|
||||
@@ -215,3 +213,4 @@ public:
|
||||
|
||||
diff -u parser-genOut/parser.pri parser/parser.pri
|
||||
--- parser-genOut/parser.pri 2020-03-02 15:40:09.000000000 +0100
|
||||
+++ parser/parser.pri 2020-03-02 15:41:11.000000000 +0100
|
||||
@@ -22,10 +22,10 @@
|
||||
$$PWD/qmljsparser.cpp \
|
||||
|
||||
-CONFIG += qlalr
|
||||
+#CONFIG += qlalr
|
||||
QLALRSOURCES = $$PWD/qmljs.g
|
||||
-QMAKE_QLALRFLAGS = --no-debug --qt
|
||||
+#QMAKE_QLALRFLAGS = --no-debug --qt
|
||||
|
||||
OTHER_FILES += $$QLALRSOURCES
|
||||
|
||||
# make sure we install the headers generated by qlalr
|
||||
-private_headers.CONFIG += no_check_exist
|
||||
+#private_headers.CONFIG += no_check_exist
|
||||
|
||||
#endif // QMLJSGRAMMAR_P_H
|
||||
+
|
||||
diff --git a/src/libs/qmljs/parser/qmljslexer.cpp b/src/libs/qmljs/parser/qmljslexer.cpp
|
||||
index 6c4eb70744..ec57f04cb7 100644
|
||||
--- a/src/libs/qmljs/parser/qmljslexer.cpp
|
||||
+++ b/src/libs/qmljs/parser/qmljslexer.cpp
|
||||
@@ -30,19 +30,12 @@
|
||||
#include "qmljs/parser/qmljsdiagnosticmessage_p.h"
|
||||
#include "qmljs/parser/qmljsmemorypool_p.h"
|
||||
|
||||
+
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
#include <QtCore/qvarlengtharray.h>
|
||||
#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
|
||||
-
|
||||
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 429c0f6619..794270b032 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
|
||||
namespace QmlJS {
|
||||
|
||||
class Engine;
|
||||
-class DiagnosticMessage;
|
||||
+struct DiagnosticMessage;
|
||||
class Directives;
|
||||
|
||||
class QML_PARSER_EXPORT Lexer: public QmlJSGrammar
|
||||
diff --git a/src/libs/qmljs/parser/qmljssourcelocation_p.h b/src/libs/qmljs/parser/qmljssourcelocation_p.h
|
||||
index f9ffa21714..5dff8c75dd 100644
|
||||
--- a/src/libs/qmljs/parser/qmljssourcelocation_p.h
|
||||
+++ b/src/libs/qmljs/parser/qmljssourcelocation_p.h
|
||||
@@ -95,14 +95,14 @@ public:
|
||||
|
||||
friend size_t qHash(const SourceLocation &location, size_t seed = 0)
|
||||
{
|
||||
- return (seed ^ (size_t(location.offset) << 8) ^ size_t(location.length)
|
||||
- ^ (size_t(location.startLine) << 16) ^ (size_t(location.startColumn) << 24));
|
||||
+ return qHashMulti(seed, location.offset, location.length,
|
||||
+ location.startLine, location.startColumn);
|
||||
}
|
||||
|
||||
friend bool operator==(const SourceLocation &a, const SourceLocation &b)
|
||||
{
|
||||
- return a.offset == b.offset && a.length == b.length && a.startLine == b.startLine
|
||||
- && a.startColumn == b.startColumn;
|
||||
+ return a.offset == b.offset && a.length == b.length
|
||||
+ && a.startLine == b.startLine && a.startColumn == b.startColumn;
|
||||
}
|
||||
|
||||
friend bool operator!=(const SourceLocation &a, const SourceLocation &b) { return !(a == b); }
|
||||
@@ -124,3 +124,4 @@ public:
|
||||
} // namespace QmlJS
|
||||
|
||||
QT_QML_END_NAMESPACE
|
||||
+
|
||||
|
||||
@@ -3,6 +3,7 @@ HEADERS += \
|
||||
$$PWD/qmljsastfwd_p.h \
|
||||
$$PWD/qmljsastvisitor_p.h \
|
||||
$$PWD/qmljsengine_p.h \
|
||||
$$PWD/qmlimportresolver_p.h \
|
||||
$$PWD/qmljslexer_p.h \
|
||||
$$PWD/qmljsglobal_p.h \
|
||||
$$PWD/qmljssourcelocation_p.h \
|
||||
@@ -16,6 +17,7 @@ SOURCES += \
|
||||
$$PWD/qmljsast.cpp \
|
||||
$$PWD/qmljsastvisitor.cpp \
|
||||
$$PWD/qmljsengine_p.cpp \
|
||||
$$PWD/qmlimportresolver.cpp \
|
||||
$$PWD/qmljslexer.cpp \
|
||||
$$PWD/qmldirparser.cpp \
|
||||
$$PWD/qmljsgrammar.cpp \
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
@@ -102,7 +102,7 @@ void QmlDirParser::clear()
|
||||
_plugins.clear();
|
||||
_designerSupported = false;
|
||||
_typeInfos.clear();
|
||||
_className.clear();
|
||||
_classNames.clear();
|
||||
}
|
||||
|
||||
inline static void scanSpace(const QChar *&ch) {
|
||||
@@ -258,7 +258,6 @@ bool QmlDirParser::parse(const QString &source)
|
||||
"not %1.").arg(sections[1]));
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (sections[0] == QLatin1String("classname")) {
|
||||
if (sectionCount < 2) {
|
||||
reportError(lineNumber, 0,
|
||||
@@ -267,7 +266,7 @@ bool QmlDirParser::parse(const QString &source)
|
||||
continue;
|
||||
}
|
||||
|
||||
_className = sections[1];
|
||||
_classNames.append(sections[1]);
|
||||
|
||||
} else if (sections[0] == QLatin1String("internal")) {
|
||||
if (sectionCount != 3) {
|
||||
@@ -308,19 +307,38 @@ bool QmlDirParser::parse(const QString &source)
|
||||
QStringLiteral("typeinfo requires 1 argument, but %1 were provided").arg(sectionCount - 1));
|
||||
continue;
|
||||
}
|
||||
#ifdef QT_CREATOR
|
||||
TypeInfo typeInfo(sections[1]);
|
||||
_typeInfos.append(typeInfo);
|
||||
#endif
|
||||
|
||||
_typeInfos.append(sections[1]);
|
||||
} else if (sections[0] == QLatin1String("designersupported")) {
|
||||
if (sectionCount != 1)
|
||||
reportError(lineNumber, 0, QStringLiteral("designersupported does not expect any argument"));
|
||||
else
|
||||
_designerSupported = true;
|
||||
} else if (sections[0] == QLatin1String("depends") || sections[0] == QLatin1String("import")) {
|
||||
} else if (sections[0] == QLatin1String("import")
|
||||
|| sections[0] == QLatin1String("depends")) {
|
||||
if (!readImport(sections, sectionCount, Import::Default))
|
||||
continue;
|
||||
} else if (sections[0] == QLatin1String("prefer")) {
|
||||
if (sectionCount < 2) {
|
||||
reportError(lineNumber, 0,
|
||||
QStringLiteral("prefer directive requires one argument, "
|
||||
"but %1 were provided").arg(sectionCount - 1));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!_preferredPath.isEmpty()) {
|
||||
reportError(lineNumber, 0, QStringLiteral(
|
||||
"only one prefer directive may be defined in a qmldir file"));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!sections[1].endsWith(u'/')) {
|
||||
// Yes. People should realize it's a directory.
|
||||
reportError(lineNumber, 0, QStringLiteral(
|
||||
"the preferred directory has to end with a '/'"));
|
||||
continue;
|
||||
}
|
||||
|
||||
_preferredPath = sections[1];
|
||||
} else if (sectionCount == 2) {
|
||||
// No version specified (should only be used for relative qmldir files)
|
||||
const Component entry(sections[0], sections[1], -1, -1);
|
||||
@@ -361,14 +379,6 @@ void QmlDirParser::reportError(quint16 line, quint16 column, const QString &desc
|
||||
_errors.append(error);
|
||||
}
|
||||
|
||||
bool QmlDirParser::hasError() const
|
||||
{
|
||||
if (! _errors.isEmpty())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void QmlDirParser::setError(const QmlJS::DiagnosticMessage &e)
|
||||
{
|
||||
_errors.clear();
|
||||
@@ -388,56 +398,6 @@ QList<QmlJS::DiagnosticMessage> QmlDirParser::errors(const QString &uri) const
|
||||
return errors;
|
||||
}
|
||||
|
||||
QString QmlDirParser::typeNamespace() const
|
||||
{
|
||||
return _typeNamespace;
|
||||
}
|
||||
|
||||
void QmlDirParser::setTypeNamespace(const QString &s)
|
||||
{
|
||||
_typeNamespace = s;
|
||||
}
|
||||
|
||||
QList<QmlDirParser::Plugin> QmlDirParser::plugins() const
|
||||
{
|
||||
return _plugins;
|
||||
}
|
||||
|
||||
QMultiHash<QString, QmlDirParser::Component> QmlDirParser::components() const
|
||||
{
|
||||
return _components;
|
||||
}
|
||||
|
||||
QList<QmlDirParser::Import> QmlDirParser::dependencies() const
|
||||
{
|
||||
return _dependencies;
|
||||
}
|
||||
|
||||
QList<QmlDirParser::Import> QmlDirParser::imports() const
|
||||
{
|
||||
return _imports;
|
||||
}
|
||||
|
||||
QList<QmlDirParser::Script> QmlDirParser::scripts() const
|
||||
{
|
||||
return _scripts;
|
||||
}
|
||||
|
||||
QList<QmlDirParser::TypeInfo> QmlDirParser::typeInfos() const
|
||||
{
|
||||
return _typeInfos;
|
||||
}
|
||||
|
||||
bool QmlDirParser::designerSupported() const
|
||||
{
|
||||
return _designerSupported;
|
||||
}
|
||||
|
||||
QString QmlDirParser::className() const
|
||||
{
|
||||
return _className;
|
||||
}
|
||||
|
||||
QDebug &operator<< (QDebug &debug, const QmlDirParser::Component &component)
|
||||
{
|
||||
const QString output = QStringLiteral("{%1 %2.%3}").
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
@@ -55,12 +55,12 @@ public:
|
||||
void clear();
|
||||
bool parse(const QString &source);
|
||||
|
||||
bool hasError() const;
|
||||
bool hasError() const { return !_errors.isEmpty(); }
|
||||
void setError(const QmlJS::DiagnosticMessage &);
|
||||
QList<QmlJS::DiagnosticMessage> errors(const QString &uri) const;
|
||||
|
||||
QString typeNamespace() const;
|
||||
void setTypeNamespace(const QString &s);
|
||||
QString typeNamespace() const { return _typeNamespace; }
|
||||
void setTypeNamespace(const QString &s) { _typeNamespace = s; }
|
||||
|
||||
static void checkNonRelative(const char *item, const QString &typeName, const QString &fileName)
|
||||
{
|
||||
@@ -141,25 +141,16 @@ public:
|
||||
Flags flags;
|
||||
};
|
||||
|
||||
QMultiHash<QString,Component> components() const;
|
||||
QList<Import> dependencies() const;
|
||||
QList<Import> imports() const;
|
||||
QList<Script> scripts() const;
|
||||
QList<Plugin> plugins() const;
|
||||
bool designerSupported() const;
|
||||
QMultiHash<QString,Component> components() const { return _components; }
|
||||
QList<Import> dependencies() const { return _dependencies; }
|
||||
QList<Import> imports() const { return _imports; }
|
||||
QList<Script> scripts() const { return _scripts; }
|
||||
QList<Plugin> plugins() const { return _plugins; }
|
||||
bool designerSupported() const { return _designerSupported; }
|
||||
|
||||
struct TypeInfo
|
||||
{
|
||||
TypeInfo() = default;
|
||||
TypeInfo(const QString &fileName)
|
||||
: fileName(fileName) {}
|
||||
|
||||
QString fileName;
|
||||
};
|
||||
|
||||
QList<TypeInfo> typeInfos() const;
|
||||
|
||||
QString className() const;
|
||||
QStringList typeInfos() const { return _typeInfos; }
|
||||
QStringList classNames() const { return _classNames; }
|
||||
QString preferredPath() const { return _preferredPath; }
|
||||
|
||||
private:
|
||||
bool maybeAddComponent(const QString &typeName, const QString &fileName, const QString &version, QHash<QString,Component> &hash, int lineNumber = -1, bool multi = true);
|
||||
@@ -168,19 +159,21 @@ private:
|
||||
private:
|
||||
QList<QmlJS::DiagnosticMessage> _errors;
|
||||
QString _typeNamespace;
|
||||
QString _preferredPath;
|
||||
QMultiHash<QString,Component> _components;
|
||||
QList<Import> _dependencies;
|
||||
QList<Import> _imports;
|
||||
QList<Script> _scripts;
|
||||
QList<Plugin> _plugins;
|
||||
bool _designerSupported = false;
|
||||
QList<TypeInfo> _typeInfos;
|
||||
QString _className;
|
||||
QStringList _typeInfos;
|
||||
QStringList _classNames;
|
||||
};
|
||||
|
||||
using QmlDirComponents = QMultiHash<QString,QmlDirParser::Component>;
|
||||
using QmlDirScripts = QList<QmlDirParser::Script>;
|
||||
using QmlDirPlugins = QList<QmlDirParser::Plugin>;
|
||||
using QmlDirImports = QList<QmlDirParser::Import>;
|
||||
|
||||
QDebug &operator<< (QDebug &, const QmlDirParser::Component &);
|
||||
QDebug &operator<< (QDebug &, const QmlDirParser::Script &);
|
||||
|
||||
117
src/libs/qmljs/parser/qmlimportresolver.cpp
Normal file
117
src/libs/qmljs/parser/qmlimportresolver.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** 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-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmlimportresolver_p.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
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.
|
||||
|
||||
For example, QtQml.Models 2.0:
|
||||
- base/QtQml/Models.2.0
|
||||
- base/QtQml.2.0/Models
|
||||
- base/QtQml/Models.2
|
||||
- base/QtQml.2/Models
|
||||
- base/QtQml/Models
|
||||
*/
|
||||
QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths,
|
||||
LanguageUtils::ComponentVersion version)
|
||||
{
|
||||
static const QLatin1Char Slash('/');
|
||||
static const QLatin1Char Backslash('\\');
|
||||
|
||||
const QList<QStringView> parts
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2)
|
||||
= uri.split(u'.', Qt::SkipEmptyParts);
|
||||
#else
|
||||
= Utils::transform(uri.toString().split('.', Qt::SkipEmptyParts), [](const QString &s) {
|
||||
return QStringView(s);
|
||||
});
|
||||
#endif
|
||||
|
||||
QStringList importPaths;
|
||||
// fully & partially versioned parts + 1 unversioned for each base path
|
||||
importPaths.reserve(2 * parts.count() + 1);
|
||||
|
||||
auto versionString = [](LanguageUtils::ComponentVersion version, ImportVersion mode)
|
||||
{
|
||||
if (mode == FullyVersioned) {
|
||||
// extension with fully encoded version number (eg. MyModule.3.2)
|
||||
return QString::fromLatin1(".%1.%2").arg(version.majorVersion())
|
||||
.arg(version.minorVersion());
|
||||
}
|
||||
if (mode == PartiallyVersioned) {
|
||||
// extension with encoded version major (eg. MyModule.3)
|
||||
return QString::fromLatin1(".%1").arg(version.majorVersion());
|
||||
}
|
||||
// else extension without version number (eg. MyModule)
|
||||
return QString();
|
||||
};
|
||||
|
||||
auto joinStringRefs = [](const QList<QStringView> &refs, const QChar &sep) {
|
||||
QString str;
|
||||
for (auto it = refs.cbegin(); it != refs.cend(); ++it) {
|
||||
if (it != refs.cbegin())
|
||||
str += sep;
|
||||
str += (*it).toString();
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
const ImportVersion initial = ((version.minorVersion() >= 0)
|
||||
? FullyVersioned
|
||||
: ((version.majorVersion() >= 0) ? PartiallyVersioned : Unversioned));
|
||||
for (int mode = initial; mode <= Unversioned; ++mode) {
|
||||
const QString ver = versionString(version, ImportVersion(mode));
|
||||
|
||||
for (const QString &path : basePaths) {
|
||||
QString dir = path;
|
||||
if (!dir.endsWith(Slash) && !dir.endsWith(Backslash))
|
||||
dir += Slash;
|
||||
|
||||
// append to the end
|
||||
importPaths += dir + joinStringRefs(parts, Slash) + ver;
|
||||
|
||||
if (mode != Unversioned) {
|
||||
// insert in the middle
|
||||
for (int index = parts.count() - 2; index >= 0; --index) {
|
||||
importPaths += dir + joinStringRefs(parts.mid(0, index + 1), Slash)
|
||||
+ ver + Slash
|
||||
+ joinStringRefs(parts.mid(index + 1), Slash);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return importPaths;
|
||||
}
|
||||
|
||||
QT_QML_END_NAMESPACE
|
||||
50
src/libs/qmljs/parser/qmlimportresolver_p.h
Normal file
50
src/libs/qmljs/parser/qmlimportresolver_p.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** 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-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qmljs/parser/qmljsglobal_p.h"
|
||||
|
||||
#include "qmljsglobal_p.h"
|
||||
#include <QtCore/qstring.h>
|
||||
#include <languageutils/componentversion.h>
|
||||
|
||||
QT_QML_BEGIN_NAMESPACE
|
||||
|
||||
QML_PARSER_EXPORT QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths,
|
||||
LanguageUtils::ComponentVersion version);
|
||||
|
||||
QT_QML_END_NAMESPACE
|
||||
@@ -81,6 +81,7 @@
|
||||
%token T_COMPATIBILITY_SEMICOLON
|
||||
%token T_ARROW "=>"
|
||||
%token T_QUESTION_QUESTION "??"
|
||||
%token T_QUESTION_DOT "?."
|
||||
%token T_ENUM "enum"
|
||||
%token T_ELLIPSIS "..."
|
||||
%token T_YIELD "yield"
|
||||
@@ -835,18 +836,32 @@ UiImport: UiImportHead Semicolon;
|
||||
UiVersionSpecifier: T_VERSION_NUMBER T_DOT T_VERSION_NUMBER;
|
||||
/.
|
||||
case $rule_number: {
|
||||
auto version = new (pool) AST::UiVersionSpecifier(sym(1).dval, sym(3).dval);
|
||||
const int major = sym(1).dval;
|
||||
const int minor = sym(3).dval;
|
||||
if (major < 0 || major >= 255 || minor < 0 || minor >= 255) {
|
||||
diagnostic_messages.append(
|
||||
compileError(loc(1),
|
||||
QLatin1String("Invalid version. Version numbers must be >= 0 and < 255.")));
|
||||
return false;
|
||||
}
|
||||
auto version = new (pool) AST::UiVersionSpecifier(major, minor);
|
||||
version->majorToken = loc(1);
|
||||
version->minorToken = loc(3);
|
||||
sym(1).UiVersionSpecifier = version;
|
||||
} break;
|
||||
./
|
||||
|
||||
|
||||
UiVersionSpecifier: T_VERSION_NUMBER;
|
||||
/.
|
||||
case $rule_number: {
|
||||
auto version = new (pool) AST::UiVersionSpecifier(sym(1).dval, 0);
|
||||
const int major = sym(1).dval;
|
||||
if (major < 0 || major >= 255) {
|
||||
diagnostic_messages.append(
|
||||
compileError(loc(1),
|
||||
QLatin1String("Invalid major version. Version numbers must be >= 0 and < 255.")));
|
||||
return false;
|
||||
}
|
||||
auto version = new (pool) AST::UiVersionSpecifier(sym(1).dval);
|
||||
version->majorToken = loc(1);
|
||||
sym(1).UiVersionSpecifier = version;
|
||||
} break;
|
||||
@@ -1320,6 +1335,7 @@ UiObjectMember: T_DEFAULT UiObjectMemberPropertyNoInitialiser;
|
||||
} break;
|
||||
./
|
||||
|
||||
|
||||
UiObjectMember: T_REQUIRED UiObjectMemberListPropertyNoInitialiser;
|
||||
/.
|
||||
case $rule_number: {
|
||||
@@ -2277,7 +2293,16 @@ MemberExpression: MemberExpression T_LBRACKET Expression_In T_RBRACKET;
|
||||
sym(1).Node = node;
|
||||
} break;
|
||||
./
|
||||
|
||||
MemberExpression: MemberExpression T_QUESTION_DOT T_LBRACKET Expression_In T_RBRACKET;
|
||||
/.
|
||||
case $rule_number: {
|
||||
AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(4).Expression);
|
||||
node->lbracketToken = loc(3);
|
||||
node->rbracketToken = loc(5);
|
||||
node->isOptional = true;
|
||||
sym(1).Node = node;
|
||||
} break;
|
||||
./
|
||||
|
||||
-- the identifier has to be "target", catched at codegen time
|
||||
NewTarget: T_NEW T_DOT T_IDENTIFIER;
|
||||
@@ -2300,6 +2325,17 @@ MemberExpression: MemberExpression T_DOT IdentifierName;
|
||||
} break;
|
||||
./
|
||||
|
||||
MemberExpression: MemberExpression T_QUESTION_DOT IdentifierName;
|
||||
/.
|
||||
case $rule_number: {
|
||||
AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
|
||||
node->dotToken = loc(2);
|
||||
node->identifierToken = loc(3);
|
||||
node->isOptional = true;
|
||||
sym(1).Node = node;
|
||||
} break;
|
||||
./
|
||||
|
||||
MemberExpression: MetaProperty;
|
||||
|
||||
MemberExpression: T_NEW MemberExpression T_LPAREN Arguments T_RPAREN;
|
||||
@@ -2348,6 +2384,17 @@ CallExpression: MemberExpression T_LPAREN Arguments T_RPAREN;
|
||||
} break;
|
||||
./
|
||||
|
||||
CallExpression: MemberExpression T_QUESTION_DOT T_LPAREN Arguments T_RPAREN;
|
||||
/.
|
||||
case $rule_number: {
|
||||
AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(4).ArgumentList);
|
||||
node->lparenToken = loc(3);
|
||||
node->rparenToken = loc(5);
|
||||
node->isOptional = true;
|
||||
sym(1).Node = node;
|
||||
} break;
|
||||
./
|
||||
|
||||
CallExpression: Super T_LPAREN Arguments T_RPAREN;
|
||||
/. case $rule_number: Q_FALLTHROUGH(); ./
|
||||
CallExpression: CallExpression T_LPAREN Arguments T_RPAREN;
|
||||
@@ -2360,6 +2407,18 @@ CallExpression: CallExpression T_LPAREN Arguments T_RPAREN;
|
||||
} break;
|
||||
./
|
||||
|
||||
CallExpression: CallExpression T_QUESTION_DOT T_LPAREN Arguments T_RPAREN;
|
||||
/.
|
||||
case $rule_number: {
|
||||
AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(4).ArgumentList);
|
||||
node->lparenToken = loc(3);
|
||||
node->rparenToken = loc(5);
|
||||
node->isOptional = true;
|
||||
sym(1).Node = node;
|
||||
} break;
|
||||
./
|
||||
|
||||
|
||||
CallExpression: CallExpression T_LBRACKET Expression_In T_RBRACKET;
|
||||
/.
|
||||
case $rule_number: {
|
||||
@@ -2370,6 +2429,17 @@ CallExpression: CallExpression T_LBRACKET Expression_In T_RBRACKET;
|
||||
} break;
|
||||
./
|
||||
|
||||
CallExpression: CallExpression T_QUESTION_DOT T_LBRACKET Expression_In T_RBRACKET;
|
||||
/.
|
||||
case $rule_number: {
|
||||
AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(4).Expression);
|
||||
node->lbracketToken = loc(3);
|
||||
node->rbracketToken = loc(5);
|
||||
node->isOptional = true;
|
||||
sym(1).Node = node;
|
||||
} break;
|
||||
./
|
||||
|
||||
CallExpression: CallExpression T_DOT IdentifierName;
|
||||
/.
|
||||
case $rule_number: {
|
||||
@@ -2380,6 +2450,17 @@ CallExpression: CallExpression T_DOT IdentifierName;
|
||||
} break;
|
||||
./
|
||||
|
||||
CallExpression: CallExpression T_QUESTION_DOT IdentifierName;
|
||||
/.
|
||||
case $rule_number: {
|
||||
AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
|
||||
node->dotToken = loc(2);
|
||||
node->identifierToken = loc(3);
|
||||
node->isOptional = true;
|
||||
sym(1).Node = node;
|
||||
} break;
|
||||
./
|
||||
|
||||
Arguments: ;
|
||||
/.
|
||||
case $rule_number: {
|
||||
@@ -2673,6 +2754,12 @@ RelationalOperator: T_INSTANCEOF;
|
||||
sym(1).ival = QSOperator::InstanceOf;
|
||||
} break;
|
||||
./
|
||||
RelationalOperator: T_AS;
|
||||
/.
|
||||
case $rule_number: {
|
||||
sym(1).ival = QSOperator::As;
|
||||
} break;
|
||||
./
|
||||
|
||||
RelationalExpression_In: RelationalExpression_In T_IN ShiftExpression;
|
||||
/.
|
||||
@@ -2683,20 +2770,6 @@ RelationalExpression_In: RelationalExpression_In T_IN ShiftExpression;
|
||||
} break;
|
||||
./
|
||||
|
||||
TypeAssertExpression_In: RelationalExpression_In T_AS Type;
|
||||
/. case $rule_number: Q_FALLTHROUGH(); ./
|
||||
TypeAssertExpression: RelationalExpression T_AS Type;
|
||||
/.
|
||||
case $rule_number: {
|
||||
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::As, sym(3).Expression);
|
||||
node->operatorToken = loc(2);
|
||||
sym(1).Node = node;
|
||||
} break;
|
||||
./
|
||||
|
||||
RelationalExpression_In: TypeAssertExpression_In;
|
||||
RelationalExpression: TypeAssertExpression;
|
||||
|
||||
EqualityExpression_In: RelationalExpression_In;
|
||||
EqualityExpression: RelationalExpression;
|
||||
|
||||
@@ -2873,6 +2946,9 @@ AssignmentExpression: LeftHandSideExpression T_EQ AssignmentExpression;
|
||||
AssignmentExpression_In: LeftHandSideExpression T_EQ AssignmentExpression_In;
|
||||
/.
|
||||
case $rule_number: {
|
||||
if (sym(1).Expression->containsOptionalChain()) {
|
||||
syntaxError(loc(1), QStringLiteral("Optional chains are not permitted on the left-hand-side in assignments"));
|
||||
}
|
||||
// need to convert the LHS to an AssignmentPattern if it was an Array/ObjectLiteral
|
||||
if (AST::Pattern *p = sym(1).Expression->patternCast()) {
|
||||
SourceLocation errorLoc;
|
||||
@@ -2903,6 +2979,9 @@ AssignmentExpression: LeftHandSideExpression AssignmentOperator AssignmentExpres
|
||||
AssignmentExpression_In: LeftHandSideExpression AssignmentOperator AssignmentExpression_In;
|
||||
/.
|
||||
case $rule_number: {
|
||||
if (sym(1).Expression->containsOptionalChain()) {
|
||||
syntaxError(loc(1), QStringLiteral("Optional chains are not permitted on the left-hand-side in assignments"));
|
||||
}
|
||||
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, sym(2).ival, sym(3).Expression);
|
||||
node->operatorToken = loc(2);
|
||||
sym(1).Node = node;
|
||||
@@ -4019,15 +4098,14 @@ ArrowFunction_In: ArrowParameters T_ARROW ConciseBodyLookahead AssignmentExpress
|
||||
/.
|
||||
case $rule_number: {
|
||||
AST::ReturnStatement *ret = new (pool) AST::ReturnStatement(sym(4).Expression);
|
||||
ret->returnToken = sym(4).Node->firstSourceLocation().zeroLength();
|
||||
ret->semicolonToken = sym(4).Node->lastSourceLocation().zeroLengthEnd(driver->code());
|
||||
ret->returnToken = sym(4).Node->firstSourceLocation().startZeroLengthLocation();
|
||||
ret->semicolonToken = sym(4).Node->lastSourceLocation().endZeroLengthLocation(driver->code());
|
||||
AST::StatementList *statements = (new (pool) AST::StatementList(ret))->finish();
|
||||
AST::FunctionExpression *f = new (pool)
|
||||
AST::FunctionExpression(QStringView(), sym(1).FormalParameterList, statements);
|
||||
AST::FunctionExpression *f = new (pool) AST::FunctionExpression(QStringView(), sym(1).FormalParameterList, statements);
|
||||
f->isArrowFunction = true;
|
||||
f->functionToken = sym(1).Node ? sym(1).Node->firstSourceLocation().zeroLength() : loc(1).zeroLength();
|
||||
f->lbraceToken = sym(4).Node->firstSourceLocation().zeroLength();
|
||||
f->rbraceToken = sym(4).Node->lastSourceLocation().zeroLengthEnd(driver->code());
|
||||
f->functionToken = sym(1).Node ? sym(1).Node->firstSourceLocation().startZeroLengthLocation() : loc(1).startZeroLengthLocation();
|
||||
f->lbraceToken = sym(4).Node->firstSourceLocation().startZeroLengthLocation();
|
||||
f->rbraceToken = sym(4).Node->lastSourceLocation().endZeroLengthLocation(driver->code());
|
||||
sym(1).Node = f;
|
||||
} break;
|
||||
./
|
||||
@@ -4039,8 +4117,8 @@ ArrowFunction_In: ArrowParameters T_ARROW ConciseBodyLookahead T_FORCE_BLOCK Fun
|
||||
case $rule_number: {
|
||||
AST::FunctionExpression *f = new (pool) AST::FunctionExpression(QStringView(), sym(1).FormalParameterList, sym(6).StatementList);
|
||||
f->isArrowFunction = true;
|
||||
f->functionToken = sym(1).Node ? sym(1).Node->firstSourceLocation().zeroLength() : loc(1).zeroLength();
|
||||
f->lbraceToken = loc(5);
|
||||
f->functionToken = sym(1).Node ? sym(1).Node->firstSourceLocation().startZeroLengthLocation() : loc(1).startZeroLengthLocation();
|
||||
f->lbraceToken = loc(6);
|
||||
f->rbraceToken = loc(7);
|
||||
sym(1).Node = f;
|
||||
} break;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
@@ -23,11 +23,11 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QLocale>
|
||||
#include "qmljsast_p.h"
|
||||
|
||||
#include "qmljsastvisitor_p.h"
|
||||
|
||||
#include <QLocale>
|
||||
#include <qlocale.h>
|
||||
|
||||
QT_QML_BEGIN_NAMESPACE
|
||||
|
||||
@@ -104,6 +104,44 @@ ExpressionNode *ExpressionNode::expressionCast()
|
||||
return this;
|
||||
}
|
||||
|
||||
bool ExpressionNode::containsOptionalChain() const
|
||||
{
|
||||
for (const Node *node = this;;) {
|
||||
switch (node->kind) {
|
||||
case Kind_FieldMemberExpression: {
|
||||
const auto *fme = AST::cast<const FieldMemberExpression*>(node);
|
||||
if (fme->isOptional)
|
||||
return true;
|
||||
node = fme->base;
|
||||
break;
|
||||
}
|
||||
case Kind_ArrayMemberExpression: {
|
||||
const auto *ame = AST::cast<const ArrayMemberExpression*>(node);
|
||||
if (ame->isOptional)
|
||||
return true;
|
||||
node = ame->base;
|
||||
break;
|
||||
}
|
||||
case Kind_CallExpression: {
|
||||
const auto *ce = AST::cast<const CallExpression*>(node);
|
||||
if (ce->isOptional)
|
||||
return true;
|
||||
node = ce->base;
|
||||
break;
|
||||
}
|
||||
case Kind_NestedExpression: {
|
||||
const auto *ne = AST::cast<const NestedExpression*>(node);
|
||||
node = ne->expression;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// These unhandled nodes lead to invalid lvalues anyway, so they do not need to be handled here.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
FormalParameterList *ExpressionNode::reparseAsFormalParameterList(MemoryPool *pool)
|
||||
{
|
||||
AST::ExpressionNode *expr = this;
|
||||
@@ -145,6 +183,12 @@ BinaryExpression *BinaryExpression::binaryExpressionCast()
|
||||
return this;
|
||||
}
|
||||
|
||||
void TypeExpression::accept0(BaseVisitor *visitor)
|
||||
{
|
||||
visitor->visit(this);
|
||||
visitor->endVisit(this);
|
||||
}
|
||||
|
||||
Statement *Statement::statementCast()
|
||||
{
|
||||
return this;
|
||||
@@ -989,7 +1033,13 @@ BoundNames FormalParameterList::formals() const
|
||||
// change the name of the earlier argument to enforce the lookup semantics from the spec
|
||||
formals[duplicateIndex].id += QLatin1String("#") + QString::number(i);
|
||||
}
|
||||
formals += {name, it->element->typeAnnotation};
|
||||
formals += {
|
||||
name,
|
||||
it->element->typeAnnotation,
|
||||
it->element->isInjectedSignalParameter
|
||||
? BoundName::Injected
|
||||
: BoundName::Declared
|
||||
};
|
||||
}
|
||||
++i;
|
||||
}
|
||||
@@ -1392,7 +1442,8 @@ void PatternElement::boundNames(BoundNames *names)
|
||||
else if (PatternPropertyList *p = propertyList())
|
||||
p->boundNames(names);
|
||||
} else {
|
||||
names->append({bindingIdentifier.toString(), typeAnnotation});
|
||||
names->append({bindingIdentifier.toString(), typeAnnotation,
|
||||
isInjectedSignalParameter ? BoundName::Injected : BoundName::Declared});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "qmljs/parser/qmljsmemorypool_p.h"
|
||||
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qversionnumber.h>
|
||||
|
||||
QT_QML_BEGIN_NAMESPACE
|
||||
|
||||
@@ -201,6 +202,7 @@ public:
|
||||
Kind_SwitchStatement,
|
||||
Kind_TemplateLiteral,
|
||||
Kind_TaggedTemplate,
|
||||
Kind_TypeExpression,
|
||||
Kind_ThisExpression,
|
||||
Kind_ThrowStatement,
|
||||
Kind_TildeExpression,
|
||||
@@ -319,8 +321,7 @@ public:
|
||||
QMLJS_DECLARE_AST_NODE(UiQualifiedId)
|
||||
|
||||
UiQualifiedId(QStringView name)
|
||||
: next(this)
|
||||
, name(name)
|
||||
: next(this), name(name)
|
||||
{ kind = K; }
|
||||
|
||||
UiQualifiedId(UiQualifiedId *previous, QStringView name)
|
||||
@@ -444,6 +445,7 @@ public:
|
||||
ExpressionNode() {}
|
||||
|
||||
ExpressionNode *expressionCast() override;
|
||||
bool containsOptionalChain() const;
|
||||
|
||||
AST::FormalParameterList *reparseAsFormalParameterList(MemoryPool *pool);
|
||||
|
||||
@@ -489,6 +491,26 @@ public:
|
||||
SourceLocation rparenToken;
|
||||
};
|
||||
|
||||
|
||||
class QML_PARSER_EXPORT TypeExpression : public ExpressionNode
|
||||
{
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(TypeExpression)
|
||||
TypeExpression(Type *t) : m_type(t) { kind = K; }
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
|
||||
SourceLocation firstSourceLocation() const override {
|
||||
return m_type->firstSourceLocation();
|
||||
}
|
||||
|
||||
SourceLocation lastSourceLocation() const override {
|
||||
return m_type->lastSourceLocation();
|
||||
}
|
||||
|
||||
Type *m_type;
|
||||
};
|
||||
|
||||
class QML_PARSER_EXPORT ThisExpression: public LeftHandSideExpression
|
||||
{
|
||||
public:
|
||||
@@ -513,11 +535,8 @@ class QML_PARSER_EXPORT IdentifierExpression: public LeftHandSideExpression
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(IdentifierExpression)
|
||||
|
||||
IdentifierExpression(QStringView n)
|
||||
: name(n)
|
||||
{
|
||||
kind = K;
|
||||
}
|
||||
IdentifierExpression(QStringView n):
|
||||
name (n) { kind = K; }
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
|
||||
@@ -635,7 +654,15 @@ class QML_PARSER_EXPORT UiVersionSpecifier : public Node
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(UiVersionSpecifier)
|
||||
|
||||
UiVersionSpecifier(int majorum, int minorum) : majorVersion(majorum), minorVersion(minorum) { kind = K; }
|
||||
UiVersionSpecifier(int majorum) : majorVersion(majorum)
|
||||
{
|
||||
kind = K;
|
||||
}
|
||||
|
||||
UiVersionSpecifier(int majorum, int minorum) : majorVersion(majorum), minorVersion(minorum)
|
||||
{
|
||||
kind = K;
|
||||
}
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
|
||||
@@ -647,8 +674,8 @@ public:
|
||||
}
|
||||
|
||||
// attributes:
|
||||
int majorVersion;
|
||||
int minorVersion;
|
||||
int majorVersion = -1;
|
||||
int minorVersion = -1;
|
||||
SourceLocation majorToken;
|
||||
SourceLocation minorToken;
|
||||
};
|
||||
@@ -658,11 +685,8 @@ class QML_PARSER_EXPORT StringLiteral : public LeftHandSideExpression
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(StringLiteral)
|
||||
|
||||
StringLiteral(QStringView v)
|
||||
: value(v)
|
||||
{
|
||||
kind = K;
|
||||
}
|
||||
StringLiteral(QStringView v):
|
||||
value (v) { kind = K; }
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
|
||||
@@ -683,10 +707,7 @@ public:
|
||||
QMLJS_DECLARE_AST_NODE(TemplateLiteral)
|
||||
|
||||
TemplateLiteral(QStringView str, QStringView raw, ExpressionNode *e)
|
||||
: value(str)
|
||||
, rawValue(raw)
|
||||
, expression(e)
|
||||
, next(nullptr)
|
||||
: value(str), rawValue(raw), expression(e), next(nullptr)
|
||||
{ kind = K; }
|
||||
|
||||
SourceLocation firstSourceLocation() const override
|
||||
@@ -712,12 +733,8 @@ class QML_PARSER_EXPORT RegExpLiteral: public LeftHandSideExpression
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(RegExpLiteral)
|
||||
|
||||
RegExpLiteral(QStringView p, int f)
|
||||
: pattern(p)
|
||||
, flags(f)
|
||||
{
|
||||
kind = K;
|
||||
}
|
||||
RegExpLiteral(QStringView p, int f):
|
||||
pattern (p), flags (f) { kind = K; }
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
|
||||
@@ -857,13 +874,20 @@ public:
|
||||
|
||||
struct QML_PARSER_EXPORT BoundName
|
||||
{
|
||||
enum Type {
|
||||
Declared,
|
||||
Injected,
|
||||
};
|
||||
|
||||
QString id;
|
||||
TypeAnnotation *typeAnnotation = nullptr;
|
||||
BoundName(const QString &id, TypeAnnotation *typeAnnotation)
|
||||
: id(id), typeAnnotation(typeAnnotation)
|
||||
TypeAnnotation *typeAnnotation;
|
||||
Type typeAnnotationType;
|
||||
BoundName(const QString &id, TypeAnnotation *typeAnnotation, Type type = Declared)
|
||||
: id(id), typeAnnotation(typeAnnotation), typeAnnotationType(type)
|
||||
{}
|
||||
BoundName() = default;
|
||||
QString typeName() const { return typeAnnotation ? typeAnnotation->type->toString() : QString(); }
|
||||
bool isInjected() const { return typeAnnotation && typeAnnotationType == Injected; }
|
||||
};
|
||||
|
||||
struct BoundNames : public QVector<BoundName>
|
||||
@@ -907,13 +931,8 @@ public:
|
||||
: initializer(i), type(t)
|
||||
{ kind = K; }
|
||||
|
||||
PatternElement(QStringView n,
|
||||
TypeAnnotation *typeAnnotation = nullptr,
|
||||
ExpressionNode *i = nullptr,
|
||||
Type t = Binding)
|
||||
: bindingIdentifier(n)
|
||||
, initializer(i)
|
||||
, type(t)
|
||||
PatternElement(QStringView n, TypeAnnotation *typeAnnotation = nullptr, ExpressionNode *i = nullptr, Type t = Binding)
|
||||
: bindingIdentifier(n), initializer(i), type(t)
|
||||
, typeAnnotation(typeAnnotation)
|
||||
{
|
||||
Q_ASSERT(t >= RestElement);
|
||||
@@ -956,6 +975,7 @@ public:
|
||||
// when used in a VariableDeclarationList
|
||||
VariableScope scope = VariableScope::NoScope;
|
||||
bool isForDeclaration = false;
|
||||
bool isInjectedSignalParameter = false;
|
||||
};
|
||||
|
||||
class QML_PARSER_EXPORT PatternElementList : public Node
|
||||
@@ -1008,8 +1028,7 @@ public:
|
||||
{ kind = K; }
|
||||
|
||||
PatternProperty(PropertyName *name, QStringView n, ExpressionNode *i = nullptr)
|
||||
: PatternElement(n, /*type annotation*/ nullptr, i)
|
||||
, name(name)
|
||||
: PatternElement(n, /*type annotation*/nullptr, i), name(name)
|
||||
{ kind = K; }
|
||||
|
||||
PatternProperty(PropertyName *name, Pattern *pattern, ExpressionNode *i = nullptr)
|
||||
@@ -1078,11 +1097,8 @@ class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(IdentifierPropertyName)
|
||||
|
||||
IdentifierPropertyName(QStringView n)
|
||||
: id(n)
|
||||
{
|
||||
kind = K;
|
||||
}
|
||||
IdentifierPropertyName(QStringView n):
|
||||
id (n) { kind = K; }
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
|
||||
@@ -1097,11 +1113,8 @@ class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(StringLiteralPropertyName)
|
||||
|
||||
StringLiteralPropertyName(QStringView n)
|
||||
: id(n)
|
||||
{
|
||||
kind = K;
|
||||
}
|
||||
StringLiteralPropertyName(QStringView n):
|
||||
id (n) { kind = K; }
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
|
||||
@@ -1173,6 +1186,7 @@ public:
|
||||
ExpressionNode *expression;
|
||||
SourceLocation lbracketToken;
|
||||
SourceLocation rbracketToken;
|
||||
bool isOptional = false;
|
||||
};
|
||||
|
||||
class QML_PARSER_EXPORT FieldMemberExpression: public LeftHandSideExpression
|
||||
@@ -1180,11 +1194,9 @@ class QML_PARSER_EXPORT FieldMemberExpression: public LeftHandSideExpression
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(FieldMemberExpression)
|
||||
|
||||
FieldMemberExpression(ExpressionNode *b, QStringView n)
|
||||
: base(b)
|
||||
, name(n)
|
||||
{
|
||||
kind = K; }
|
||||
FieldMemberExpression(ExpressionNode *b, QStringView n):
|
||||
base (b), name (n)
|
||||
{ kind = K; }
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
|
||||
@@ -1199,6 +1211,7 @@ public:
|
||||
QStringView name;
|
||||
SourceLocation dotToken;
|
||||
SourceLocation identifierToken;
|
||||
bool isOptional = false;
|
||||
};
|
||||
|
||||
class QML_PARSER_EXPORT TaggedTemplate : public LeftHandSideExpression
|
||||
@@ -1291,6 +1304,7 @@ public:
|
||||
ArgumentList *arguments;
|
||||
SourceLocation lparenToken;
|
||||
SourceLocation rparenToken;
|
||||
bool isOptional = false;
|
||||
};
|
||||
|
||||
class QML_PARSER_EXPORT ArgumentList: public Node
|
||||
@@ -1972,11 +1986,8 @@ class QML_PARSER_EXPORT ContinueStatement: public Statement
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(ContinueStatement)
|
||||
|
||||
ContinueStatement(QStringView l = QStringView())
|
||||
: label(l)
|
||||
{
|
||||
kind = K;
|
||||
}
|
||||
ContinueStatement(QStringView l = QStringView()):
|
||||
label (l) { kind = K; }
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
|
||||
@@ -1998,11 +2009,8 @@ class QML_PARSER_EXPORT BreakStatement: public Statement
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(BreakStatement)
|
||||
|
||||
BreakStatement(QStringView l)
|
||||
: label(l)
|
||||
{
|
||||
kind = K;
|
||||
}
|
||||
BreakStatement(QStringView l):
|
||||
label (l) { kind = K; }
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
|
||||
@@ -2229,11 +2237,9 @@ class QML_PARSER_EXPORT LabelledStatement: public Statement
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(LabelledStatement)
|
||||
|
||||
LabelledStatement(QStringView l, Statement *stmt)
|
||||
: label(l)
|
||||
, statement(stmt)
|
||||
{
|
||||
kind = K; }
|
||||
LabelledStatement(QStringView l, Statement *stmt):
|
||||
label (l), statement (stmt)
|
||||
{ kind = K; }
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
|
||||
@@ -2364,16 +2370,10 @@ class QML_PARSER_EXPORT FunctionExpression: public ExpressionNode
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(FunctionExpression)
|
||||
|
||||
FunctionExpression(QStringView n,
|
||||
FormalParameterList *f,
|
||||
StatementList *b,
|
||||
TypeAnnotation *typeAnnotation = nullptr)
|
||||
: name(n)
|
||||
, formals(f)
|
||||
, body(b)
|
||||
, typeAnnotation(typeAnnotation)
|
||||
{
|
||||
kind = K; }
|
||||
FunctionExpression(QStringView n, FormalParameterList *f, StatementList *b, TypeAnnotation *typeAnnotation = nullptr):
|
||||
name (n), formals (f), body (b),
|
||||
typeAnnotation(typeAnnotation)
|
||||
{ kind = K; }
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
|
||||
@@ -2405,13 +2405,9 @@ class QML_PARSER_EXPORT FunctionDeclaration: public FunctionExpression
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(FunctionDeclaration)
|
||||
|
||||
FunctionDeclaration(QStringView n,
|
||||
FormalParameterList *f,
|
||||
StatementList *b,
|
||||
TypeAnnotation *typeAnnotation = nullptr)
|
||||
: FunctionExpression(n, f, b, typeAnnotation)
|
||||
{
|
||||
kind = K; }
|
||||
FunctionDeclaration(QStringView n, FormalParameterList *f, StatementList *b, TypeAnnotation *typeAnnotation = nullptr):
|
||||
FunctionExpression(n, f, b, typeAnnotation)
|
||||
{ kind = K; }
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
};
|
||||
@@ -2507,11 +2503,8 @@ public:
|
||||
QMLJS_DECLARE_AST_NODE(ClassExpression)
|
||||
|
||||
ClassExpression(QStringView n, ExpressionNode *heritage, ClassElementList *elements)
|
||||
: name(n)
|
||||
, heritage(heritage)
|
||||
, elements(elements)
|
||||
{
|
||||
kind = K; }
|
||||
: name(n), heritage(heritage), elements(elements)
|
||||
{ kind = K; }
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
|
||||
@@ -2540,8 +2533,7 @@ public:
|
||||
|
||||
ClassDeclaration(QStringView n, ExpressionNode *heritage, ClassElementList *elements)
|
||||
: ClassExpression(n, heritage, elements)
|
||||
{
|
||||
kind = K; }
|
||||
{ kind = K; }
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
};
|
||||
@@ -2617,8 +2609,7 @@ public:
|
||||
}
|
||||
|
||||
ImportSpecifier(QStringView identifier, QStringView importedBinding)
|
||||
: identifier(identifier)
|
||||
, importedBinding(importedBinding)
|
||||
: identifier(identifier), importedBinding(importedBinding)
|
||||
{
|
||||
kind = K;
|
||||
}
|
||||
@@ -2852,15 +2843,13 @@ public:
|
||||
QMLJS_DECLARE_AST_NODE(ExportSpecifier)
|
||||
|
||||
ExportSpecifier(QStringView identifier)
|
||||
: identifier(identifier)
|
||||
, exportedIdentifier(identifier)
|
||||
: identifier(identifier), exportedIdentifier(identifier)
|
||||
{
|
||||
kind = K;
|
||||
}
|
||||
|
||||
ExportSpecifier(QStringView identifier, QStringView exportedIdentifier)
|
||||
: identifier(identifier)
|
||||
, exportedIdentifier(exportedIdentifier)
|
||||
: identifier(identifier), exportedIdentifier(exportedIdentifier)
|
||||
{
|
||||
kind = K;
|
||||
}
|
||||
@@ -2959,7 +2948,6 @@ public:
|
||||
ExportDeclaration(FromClause *fromClause)
|
||||
: fromClause(fromClause)
|
||||
{
|
||||
exportAll = true;
|
||||
kind = K;
|
||||
}
|
||||
|
||||
@@ -2982,6 +2970,11 @@ public:
|
||||
kind = K;
|
||||
}
|
||||
|
||||
bool exportsAll() const
|
||||
{
|
||||
return fromClause && !exportClause;
|
||||
}
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
|
||||
SourceLocation firstSourceLocation() const override
|
||||
@@ -2991,7 +2984,6 @@ public:
|
||||
|
||||
// attributes
|
||||
SourceLocation exportToken;
|
||||
bool exportAll = false;
|
||||
ExportClause *exportClause = nullptr;
|
||||
FromClause *fromClause = nullptr;
|
||||
Node *variableStatementOrDeclaration = nullptr;
|
||||
@@ -3048,8 +3040,7 @@ public:
|
||||
QMLJS_DECLARE_AST_NODE(UiImport)
|
||||
|
||||
UiImport(QStringView fileName)
|
||||
: fileName(fileName)
|
||||
, importUri(nullptr)
|
||||
: fileName(fileName), importUri(nullptr)
|
||||
{ kind = K; }
|
||||
|
||||
UiImport(UiQualifiedId *uri)
|
||||
@@ -3154,7 +3145,7 @@ public:
|
||||
QMLJS_DECLARE_AST_NODE(UiRequired)
|
||||
|
||||
UiRequired(QStringView name)
|
||||
: name(name)
|
||||
:name(name)
|
||||
{ kind = K; }
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
@@ -3319,16 +3310,12 @@ 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(UiQualifiedId *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, UiQualifiedId *t, QStringView n):
|
||||
type (t), name (n)
|
||||
{
|
||||
kind = K;
|
||||
next = previous->next;
|
||||
@@ -3368,43 +3355,29 @@ class QML_PARSER_EXPORT UiPublicMember: public UiObjectMember
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(UiPublicMember)
|
||||
|
||||
UiPublicMember(UiQualifiedId *memberType, QStringView name)
|
||||
: type(Property)
|
||||
, memberType(memberType)
|
||||
, name(name)
|
||||
, statement(nullptr)
|
||||
, binding(nullptr)
|
||||
, isDefaultMember(false)
|
||||
, isReadonlyMember(false)
|
||||
, parameters(nullptr)
|
||||
UiPublicMember(UiQualifiedId *memberType,
|
||||
QStringView name)
|
||||
: type(Property), memberType(memberType), name(name), statement(nullptr), binding(nullptr), isDefaultMember(false), isReadonlyMember(false), parameters(nullptr)
|
||||
{ kind = K; }
|
||||
|
||||
UiPublicMember(UiQualifiedId *memberType, QStringView name, Statement *statement)
|
||||
: type(Property)
|
||||
, memberType(memberType)
|
||||
, name(name)
|
||||
, statement(statement)
|
||||
, binding(nullptr)
|
||||
, isDefaultMember(false)
|
||||
, isReadonlyMember(false)
|
||||
, parameters(nullptr)
|
||||
UiPublicMember(UiQualifiedId *memberType,
|
||||
QStringView name,
|
||||
Statement *statement)
|
||||
: type(Property), memberType(memberType), name(name), statement(statement), binding(nullptr), isDefaultMember(false), isReadonlyMember(false), parameters(nullptr)
|
||||
{ kind = K; }
|
||||
|
||||
void accept0(BaseVisitor *visitor) override;
|
||||
|
||||
SourceLocation firstSourceLocation() const override
|
||||
{
|
||||
if (requiredToken.isValid()) {
|
||||
if (defaultToken.isValid() && defaultToken.offset < requiredToken.offset)
|
||||
return defaultToken;
|
||||
return requiredToken;
|
||||
}
|
||||
if (defaultToken.isValid())
|
||||
return defaultToken;
|
||||
if (readonlyToken.isValid())
|
||||
return readonlyToken;
|
||||
if (defaultToken.isValid())
|
||||
return defaultToken;
|
||||
else if (readonlyToken.isValid())
|
||||
return readonlyToken;
|
||||
else if (requiredToken.isValid())
|
||||
return requiredToken;
|
||||
|
||||
return propertyToken;
|
||||
return propertyToken;
|
||||
}
|
||||
|
||||
SourceLocation lastSourceLocation() const override
|
||||
@@ -3468,9 +3441,8 @@ class QML_PARSER_EXPORT UiInlineComponent: public UiObjectMember
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(UiInlineComponent)
|
||||
|
||||
UiInlineComponent(QStringView inlineComponentName, UiObjectDefinition *inlineComponent)
|
||||
: name(inlineComponentName)
|
||||
, component(inlineComponent)
|
||||
UiInlineComponent(QStringView inlineComponentName, UiObjectDefinition* inlineComponent)
|
||||
: name(inlineComponentName), component(inlineComponent)
|
||||
{ kind = K; }
|
||||
|
||||
SourceLocation lastSourceLocation() const override
|
||||
@@ -3596,7 +3568,7 @@ public:
|
||||
{ kind = K; }
|
||||
|
||||
SourceLocation firstSourceLocation() const override
|
||||
{ return qualifiedId->identifierToken; }
|
||||
{ Q_ASSERT(qualifiedId); return qualifiedId->identifierToken; }
|
||||
|
||||
SourceLocation lastSourceLocation() const override
|
||||
{ return rbracketToken; }
|
||||
@@ -3616,9 +3588,7 @@ class QML_PARSER_EXPORT UiEnumMemberList: public Node
|
||||
QMLJS_DECLARE_AST_NODE(UiEnumMemberList)
|
||||
public:
|
||||
UiEnumMemberList(QStringView member, double v = 0.0)
|
||||
: next(this)
|
||||
, member(member)
|
||||
, value(v)
|
||||
: next(this), member(member), value(v)
|
||||
{ kind = K; }
|
||||
|
||||
UiEnumMemberList(UiEnumMemberList *previous, QStringView member)
|
||||
@@ -3631,8 +3601,7 @@ public:
|
||||
}
|
||||
|
||||
UiEnumMemberList(UiEnumMemberList *previous, QStringView member, double v)
|
||||
: member(member)
|
||||
, value(v)
|
||||
: member(member), value(v)
|
||||
{
|
||||
kind = K;
|
||||
next = previous->next;
|
||||
@@ -3670,7 +3639,8 @@ class QML_PARSER_EXPORT UiEnumDeclaration: public UiObjectMember
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(UiEnumDeclaration)
|
||||
|
||||
UiEnumDeclaration(QStringView name, UiEnumMemberList *members)
|
||||
UiEnumDeclaration(QStringView name,
|
||||
UiEnumMemberList *members)
|
||||
: name(name)
|
||||
, members(members)
|
||||
{ kind = K; }
|
||||
@@ -3754,4 +3724,3 @@ public:
|
||||
|
||||
|
||||
QT_QML_END_NAMESPACE
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
@@ -50,6 +50,7 @@ class Visitor;
|
||||
class Node;
|
||||
class ExpressionNode;
|
||||
class Statement;
|
||||
class TypeExpression;
|
||||
class ThisExpression;
|
||||
class IdentifierExpression;
|
||||
class NullExpression;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
@@ -126,6 +126,9 @@ public:
|
||||
virtual void endVisit(UiRequired *) = 0;
|
||||
|
||||
// QmlJS
|
||||
virtual bool visit(TypeExpression *) = 0;
|
||||
virtual void endVisit(TypeExpression *) = 0;
|
||||
|
||||
virtual bool visit(ThisExpression *) = 0;
|
||||
virtual void endVisit(ThisExpression *) = 0;
|
||||
|
||||
@@ -467,6 +470,9 @@ public:
|
||||
void endVisit(UiRequired *) override {}
|
||||
|
||||
// QmlJS
|
||||
bool visit(TypeExpression *) override { return true; }
|
||||
void endVisit(TypeExpression *) override {}
|
||||
|
||||
bool visit(ThisExpression *) override { return true; }
|
||||
void endVisit(ThisExpression *) override {}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
@@ -26,11 +26,9 @@
|
||||
#include "qmljsengine_p.h"
|
||||
#include "qmljsglobal_p.h"
|
||||
|
||||
#include <utils/porting.h>
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/qhash.h>
|
||||
#include <QtCore/qnumeric.h>
|
||||
#include <QtCore/qhash.h>
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
QT_QML_BEGIN_NAMESPACE
|
||||
|
||||
@@ -138,9 +136,7 @@ QStringView Engine::newStringRef(const QString &text)
|
||||
}
|
||||
|
||||
QStringView Engine::newStringRef(const QChar *chars, int size)
|
||||
{
|
||||
return newStringRef(QString(chars, size));
|
||||
}
|
||||
{ return newStringRef(QString(chars, size)); }
|
||||
|
||||
} // end of namespace QmlJS
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
@@ -37,16 +37,14 @@
|
||||
//
|
||||
|
||||
#include "qmljsglobal_p.h"
|
||||
#include "qmljs/parser/qmljssourcelocation_p.h"
|
||||
|
||||
#include "qmljs/parser/qmljsmemorypool_p.h"
|
||||
#include "qmljs/parser/qmljssourcelocation_p.h"
|
||||
#include <qmljs/qmljsconstants.h>
|
||||
|
||||
#include <utils/porting.h>
|
||||
|
||||
#include <QString>
|
||||
#include <QSet>
|
||||
|
||||
#include <qmljs/qmljsconstants.h>
|
||||
QT_QML_BEGIN_NAMESPACE
|
||||
|
||||
namespace QmlJS {
|
||||
@@ -107,10 +105,7 @@ public:
|
||||
|
||||
MemoryPool *pool();
|
||||
|
||||
inline QStringView midRef(int position, int size)
|
||||
{
|
||||
return Utils::midView(_code, position, size);
|
||||
}
|
||||
inline QStringView midRef(int position, int size) { return QStringView{_code}.mid(position, size); }
|
||||
|
||||
QStringView newStringRef(const QString &s);
|
||||
QStringView newStringRef(const QChar *chars, int size);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
@@ -32,23 +32,23 @@ class QML_PARSER_EXPORT QmlJSGrammar
|
||||
public:
|
||||
enum VariousConstants {
|
||||
EOF_SYMBOL = 0,
|
||||
REDUCE_HERE = 131,
|
||||
REDUCE_HERE = 132,
|
||||
T_AND = 1,
|
||||
T_AND_AND = 2,
|
||||
T_AND_EQ = 3,
|
||||
T_ARROW = 96,
|
||||
T_AS = 116,
|
||||
T_AS = 117,
|
||||
T_AT = 90,
|
||||
T_AUTOMATIC_SEMICOLON = 64,
|
||||
T_BREAK = 4,
|
||||
T_CASE = 5,
|
||||
T_CATCH = 6,
|
||||
T_CLASS = 102,
|
||||
T_CLASS = 103,
|
||||
T_COLON = 7,
|
||||
T_COMMA = 8,
|
||||
T_COMMENT = 94,
|
||||
T_COMPATIBILITY_SEMICOLON = 95,
|
||||
T_COMPONENT = 108,
|
||||
T_COMPONENT = 109,
|
||||
T_CONST = 88,
|
||||
T_CONTINUE = 9,
|
||||
T_DEBUGGER = 91,
|
||||
@@ -58,32 +58,32 @@ public:
|
||||
T_DIVIDE_EQ = 13,
|
||||
T_DO = 14,
|
||||
T_DOT = 15,
|
||||
T_ELLIPSIS = 99,
|
||||
T_ELLIPSIS = 100,
|
||||
T_ELSE = 16,
|
||||
T_ENUM = 98,
|
||||
T_ENUM = 99,
|
||||
T_EQ = 17,
|
||||
T_EQ_EQ = 18,
|
||||
T_EQ_EQ_EQ = 19,
|
||||
T_ERROR = 120,
|
||||
T_EXPORT = 105,
|
||||
T_EXTENDS = 103,
|
||||
T_ERROR = 121,
|
||||
T_EXPORT = 106,
|
||||
T_EXTENDS = 104,
|
||||
T_FALSE = 87,
|
||||
T_FEED_JS_EXPRESSION = 124,
|
||||
T_FEED_JS_MODULE = 126,
|
||||
T_FEED_JS_SCRIPT = 125,
|
||||
T_FEED_JS_STATEMENT = 123,
|
||||
T_FEED_UI_OBJECT_MEMBER = 122,
|
||||
T_FEED_UI_PROGRAM = 121,
|
||||
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_FINALLY = 20,
|
||||
T_FOR = 21,
|
||||
T_FORCE_BLOCK = 128,
|
||||
T_FORCE_DECLARATION = 127,
|
||||
T_FOR_LOOKAHEAD_OK = 129,
|
||||
T_FROM = 106,
|
||||
T_FORCE_BLOCK = 129,
|
||||
T_FORCE_DECLARATION = 128,
|
||||
T_FOR_LOOKAHEAD_OK = 130,
|
||||
T_FROM = 107,
|
||||
T_FUNCTION = 23,
|
||||
T_FUNCTION_STAR = 22,
|
||||
T_GE = 24,
|
||||
T_GET = 118,
|
||||
T_GET = 119,
|
||||
T_GT = 25,
|
||||
T_GT_GT = 26,
|
||||
T_GT_GT_EQ = 27,
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
T_GT_GT_GT_EQ = 29,
|
||||
T_IDENTIFIER = 30,
|
||||
T_IF = 31,
|
||||
T_IMPORT = 114,
|
||||
T_IMPORT = 115,
|
||||
T_IN = 32,
|
||||
T_INSTANCEOF = 33,
|
||||
T_LBRACE = 34,
|
||||
@@ -110,46 +110,47 @@ public:
|
||||
T_NOT = 45,
|
||||
T_NOT_EQ = 46,
|
||||
T_NOT_EQ_EQ = 47,
|
||||
T_NO_SUBSTITUTION_TEMPLATE = 109,
|
||||
T_NO_SUBSTITUTION_TEMPLATE = 110,
|
||||
T_NULL = 85,
|
||||
T_NUMERIC_LITERAL = 48,
|
||||
T_OF = 117,
|
||||
T_ON = 130,
|
||||
T_OF = 118,
|
||||
T_ON = 131,
|
||||
T_OR = 49,
|
||||
T_OR_EQ = 51,
|
||||
T_OR_OR = 52,
|
||||
T_PLUS = 53,
|
||||
T_PLUS_EQ = 54,
|
||||
T_PLUS_PLUS = 55,
|
||||
T_PRAGMA = 115,
|
||||
T_PRAGMA = 116,
|
||||
T_PROPERTY = 70,
|
||||
T_PUBLIC = 113,
|
||||
T_PUBLIC = 114,
|
||||
T_QUESTION = 56,
|
||||
T_QUESTION_DOT = 98,
|
||||
T_QUESTION_QUESTION = 97,
|
||||
T_RBRACE = 57,
|
||||
T_RBRACKET = 58,
|
||||
T_READONLY = 72,
|
||||
T_REMAINDER = 59,
|
||||
T_REMAINDER_EQ = 60,
|
||||
T_REQUIRED = 107,
|
||||
T_REQUIRED = 108,
|
||||
T_RESERVED_WORD = 92,
|
||||
T_RETURN = 61,
|
||||
T_RPAREN = 62,
|
||||
T_SEMICOLON = 63,
|
||||
T_SET = 119,
|
||||
T_SET = 120,
|
||||
T_SIGNAL = 71,
|
||||
T_STAR = 65,
|
||||
T_STAR_EQ = 68,
|
||||
T_STAR_STAR = 66,
|
||||
T_STAR_STAR_EQ = 67,
|
||||
T_STATIC = 104,
|
||||
T_STATIC = 105,
|
||||
T_STRING_LITERAL = 69,
|
||||
T_SUPER = 101,
|
||||
T_SUPER = 102,
|
||||
T_SWITCH = 73,
|
||||
T_TEMPLATE_HEAD = 110,
|
||||
T_TEMPLATE_MIDDLE = 111,
|
||||
T_TEMPLATE_TAIL = 112,
|
||||
T_THEN = 132,
|
||||
T_TEMPLATE_HEAD = 111,
|
||||
T_TEMPLATE_MIDDLE = 112,
|
||||
T_TEMPLATE_TAIL = 113,
|
||||
T_THEN = 133,
|
||||
T_THIS = 74,
|
||||
T_THROW = 75,
|
||||
T_TILDE = 76,
|
||||
@@ -161,20 +162,20 @@ public:
|
||||
T_VOID = 80,
|
||||
T_WHILE = 81,
|
||||
T_WITH = 82,
|
||||
T_WITHOUTAS = 133,
|
||||
T_WITHOUTAS = 134,
|
||||
T_XOR = 83,
|
||||
T_XOR_EQ = 84,
|
||||
T_YIELD = 100,
|
||||
T_YIELD = 101,
|
||||
|
||||
ACCEPT_STATE = 1102,
|
||||
RULE_COUNT = 619,
|
||||
STATE_COUNT = 1103,
|
||||
TERMINAL_COUNT = 134,
|
||||
NON_TERMINAL_COUNT = 238,
|
||||
ACCEPT_STATE = 1114,
|
||||
RULE_COUNT = 622,
|
||||
STATE_COUNT = 1115,
|
||||
TERMINAL_COUNT = 135,
|
||||
NON_TERMINAL_COUNT = 236,
|
||||
|
||||
GOTO_INDEX_OFFSET = 1103,
|
||||
GOTO_INFO_OFFSET = 6857,
|
||||
GOTO_CHECK_OFFSET = 6857
|
||||
GOTO_INDEX_OFFSET = 1115,
|
||||
GOTO_INFO_OFFSET = 7121,
|
||||
GOTO_CHECK_OFFSET = 7121
|
||||
};
|
||||
|
||||
static const char *const spell[];
|
||||
@@ -214,4 +215,3 @@ public:
|
||||
|
||||
|
||||
#endif // QMLJSGRAMMAR_P_H
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
@@ -176,6 +176,7 @@ protected:
|
||||
|
||||
private:
|
||||
inline void scanChar();
|
||||
inline QChar peekChar();
|
||||
int scanToken();
|
||||
int scanNumber(QChar ch);
|
||||
int scanVersionNumber(QChar ch);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
@@ -90,8 +90,7 @@ public:
|
||||
template <typename Tp, typename... Ta> Tp *New(Ta... args)
|
||||
{ return new (this->allocate(sizeof(Tp))) Tp(args...); }
|
||||
|
||||
QStringView newString(const QString &string)
|
||||
{
|
||||
QStringView newString(const QString &string) {
|
||||
strings.append(new QString(string));
|
||||
return QStringView(*strings.last());
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,6 @@
|
||||
|
||||
#line 185 "qmljs.g"
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
@@ -292,27 +290,27 @@ protected:
|
||||
|
||||
|
||||
|
||||
#line 1862 "qmljs.g"
|
||||
#line 1878 "qmljs.g"
|
||||
|
||||
#define J_SCRIPT_REGEXPLITERAL_RULE1 164
|
||||
|
||||
#line 1874 "qmljs.g"
|
||||
#line 1890 "qmljs.g"
|
||||
|
||||
#define J_SCRIPT_REGEXPLITERAL_RULE2 165
|
||||
|
||||
#line 3423 "qmljs.g"
|
||||
#line 3502 "qmljs.g"
|
||||
|
||||
#define J_SCRIPT_EXPRESSIONSTATEMENTLOOKAHEAD_RULE 463
|
||||
#define J_SCRIPT_EXPRESSIONSTATEMENTLOOKAHEAD_RULE 466
|
||||
|
||||
#line 4076 "qmljs.g"
|
||||
#line 4154 "qmljs.g"
|
||||
|
||||
#define J_SCRIPT_CONCISEBODYLOOKAHEAD_RULE 533
|
||||
#define J_SCRIPT_CONCISEBODYLOOKAHEAD_RULE 536
|
||||
|
||||
#line 4618 "qmljs.g"
|
||||
#line 4696 "qmljs.g"
|
||||
|
||||
#define J_SCRIPT_EXPORTDECLARATIONLOOKAHEAD_RULE 602
|
||||
#define J_SCRIPT_EXPORTDECLARATIONLOOKAHEAD_RULE 605
|
||||
|
||||
#line 4902 "qmljs.g"
|
||||
#line 4980 "qmljs.g"
|
||||
|
||||
QT_QML_END_NAMESPACE
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
@@ -26,8 +26,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "qmljsglobal_p.h"
|
||||
|
||||
#include <QtCore/QStringView>
|
||||
#include <QtCore/qhashfunctions.h>
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
@@ -52,13 +51,19 @@ public:
|
||||
startLine(line), startColumn(column)
|
||||
{ }
|
||||
|
||||
bool isValid() const { return length != 0; }
|
||||
bool isValid() const { return *this != SourceLocation(); }
|
||||
|
||||
quint32 begin() const { return offset; }
|
||||
quint32 end() const { return offset + length; }
|
||||
|
||||
SourceLocation zeroLength() const { return SourceLocation(offset, 0, startLine, startColumn); }
|
||||
SourceLocation zeroLengthEnd(QStringView text) const {
|
||||
// Returns a zero length location at the start of the current one.
|
||||
SourceLocation startZeroLengthLocation() const
|
||||
{
|
||||
return SourceLocation(offset, 0, startLine, startColumn);
|
||||
}
|
||||
// Returns a zero length location at the end of the current one.
|
||||
SourceLocation endZeroLengthLocation(QStringView text) const
|
||||
{
|
||||
quint32 i = offset;
|
||||
quint32 endLine = startLine;
|
||||
quint32 endColumn = startColumn;
|
||||
@@ -71,7 +76,7 @@ public:
|
||||
Q_FALLTHROUGH();
|
||||
case '\r':
|
||||
++endLine;
|
||||
++endColumn;
|
||||
endColumn = 1;
|
||||
break;
|
||||
default:
|
||||
++endColumn;
|
||||
@@ -87,6 +92,33 @@ public:
|
||||
quint32 length;
|
||||
quint32 startLine;
|
||||
quint32 startColumn;
|
||||
|
||||
friend size_t qHash(const SourceLocation &location, size_t seed = 0)
|
||||
{
|
||||
return (seed ^ (size_t(location.offset) << 8) ^ size_t(location.length)
|
||||
^ (size_t(location.startLine) << 16) ^ (size_t(location.startColumn) << 24));
|
||||
}
|
||||
|
||||
friend bool operator==(const SourceLocation &a, const SourceLocation &b)
|
||||
{
|
||||
return a.offset == b.offset && a.length == b.length && a.startLine == b.startLine
|
||||
&& a.startColumn == b.startColumn;
|
||||
}
|
||||
|
||||
friend bool operator!=(const SourceLocation &a, const SourceLocation &b) { return !(a == b); }
|
||||
|
||||
// Returns a source location starting at the beginning of l1, l2 and ending at the end of them.
|
||||
// Ignores invalid source locations.
|
||||
friend SourceLocation combine(const SourceLocation &l1, const SourceLocation &l2) {
|
||||
quint32 e = qMax(l1.end(), l2.end());
|
||||
SourceLocation res;
|
||||
if (l1.offset <= l2.offset)
|
||||
res = (l1.isValid() ? l1 : l2);
|
||||
else
|
||||
res = (l2.isValid() ? l2 : l1);
|
||||
res.length = e - res.offset;
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace QmlJS
|
||||
|
||||
@@ -60,6 +60,7 @@ Project {
|
||||
prefix: "parser/"
|
||||
files: [
|
||||
"qmldirparser.cpp", "qmldirparser_p.h",
|
||||
"qmlimportresolver.cpp", "qmlimportresolver_p.h",
|
||||
"qmljsast.cpp", "qmljsast_p.h",
|
||||
"qmljsastfwd_p.h",
|
||||
"qmljsastvisitor.cpp", "qmljsastvisitor_p.h",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
|
||||
@@ -608,9 +608,8 @@ public:
|
||||
class UnsupportedTypesByVisualDesigner : public QStringList
|
||||
{
|
||||
public:
|
||||
UnsupportedTypesByVisualDesigner() : QStringList({"Timer",
|
||||
"Package",
|
||||
"Particles"})
|
||||
UnsupportedTypesByVisualDesigner()
|
||||
: QStringList({"Timer", "Package", "Particles", "ApplicationWindow"})
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -628,11 +627,13 @@ public:
|
||||
class UnsupportedRootObjectTypesByVisualDesigner : public QStringList
|
||||
{
|
||||
public:
|
||||
UnsupportedRootObjectTypesByVisualDesigner() : QStringList({"QtObject"
|
||||
"ListModel"
|
||||
"Component"
|
||||
"Timer"
|
||||
"Package"})
|
||||
UnsupportedRootObjectTypesByVisualDesigner()
|
||||
: QStringList({"QtObject"
|
||||
"ListModel"
|
||||
"Component"
|
||||
"Timer"
|
||||
"Package",
|
||||
"ApplicationWindow"})
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
@@ -370,7 +370,7 @@ LibraryInfo::LibraryInfo(Status status)
|
||||
updateFingerprint();
|
||||
}
|
||||
|
||||
LibraryInfo::LibraryInfo(const QmlDirParser::TypeInfo &typeInfo)
|
||||
LibraryInfo::LibraryInfo(const QString &typeInfo)
|
||||
: _status(Found)
|
||||
{
|
||||
_typeinfos.append(typeInfo);
|
||||
@@ -421,10 +421,10 @@ QByteArray LibraryInfo::calculateFingerprint() const
|
||||
}
|
||||
len = _typeinfos.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
foreach (const QmlDirParser::TypeInfo &typeinfo, _typeinfos) {
|
||||
len = typeinfo.fileName.size();
|
||||
foreach (const QString &typeinfo, _typeinfos) {
|
||||
len = typeinfo.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
hash.addData(reinterpret_cast<const char *>(typeinfo.fileName.constData()),
|
||||
hash.addData(reinterpret_cast<const char *>(typeinfo.constData()),
|
||||
len * sizeofQChar);
|
||||
}
|
||||
len = _metaObjects.size();
|
||||
|
||||
@@ -153,7 +153,7 @@ private:
|
||||
Status _status = NotScanned;
|
||||
QList<QmlDirParser::Component> _components;
|
||||
QList<QmlDirParser::Plugin> _plugins;
|
||||
QList<QmlDirParser::TypeInfo> _typeinfos;
|
||||
QStringList _typeinfos;
|
||||
typedef QList<LanguageUtils::FakeMetaObject::ConstPtr> FakeMetaObjectList;
|
||||
FakeMetaObjectList _metaObjects;
|
||||
QList<ModuleApiInfo> _moduleApis;
|
||||
@@ -167,7 +167,7 @@ private:
|
||||
public:
|
||||
LibraryInfo();
|
||||
explicit LibraryInfo(Status status);
|
||||
explicit LibraryInfo(const QmlDirParser::TypeInfo &typeInfo);
|
||||
explicit LibraryInfo(const QString &typeInfo);
|
||||
explicit LibraryInfo(const QmlDirParser &parser, const QByteArray &fingerprint = QByteArray());
|
||||
~LibraryInfo() = default;
|
||||
LibraryInfo(const LibraryInfo &other) = default;
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
QList<QmlDirParser::Plugin> plugins() const
|
||||
{ return _plugins; }
|
||||
|
||||
QList<QmlDirParser::TypeInfo> typeInfos() const
|
||||
QStringList typeInfos() const
|
||||
{ return _typeinfos; }
|
||||
|
||||
FakeMetaObjectList metaObjects() const
|
||||
|
||||
@@ -811,7 +811,7 @@ static bool findNewQmlApplicationInPath(const QString &path,
|
||||
|
||||
qmltypesFile = it.next();
|
||||
|
||||
LibraryInfo libraryInfo = LibraryInfo(QmlDirParser::TypeInfo(qmltypesFile));
|
||||
LibraryInfo libraryInfo = LibraryInfo(qmltypesFile);
|
||||
const QString libraryPath = dir.absolutePath();
|
||||
newLibraries->insert(libraryPath);
|
||||
modelManager->updateLibraryInfo(path, libraryInfo);
|
||||
|
||||
@@ -154,8 +154,8 @@ void PluginDumper::onLoadPluginTypes(const QString &libraryPath, const QString &
|
||||
}
|
||||
|
||||
// add typeinfo files listed in qmldir
|
||||
foreach (const QmlDirParser::TypeInfo &typeInfo, libraryInfo.typeInfos()) {
|
||||
QString pathNow = makeAbsolute(typeInfo.fileName, canonicalLibraryPath);
|
||||
foreach (const QString &typeInfo, libraryInfo.typeInfos()) {
|
||||
QString pathNow = makeAbsolute(typeInfo, canonicalLibraryPath);
|
||||
if (!plugin.typeInfoPaths.contains(pathNow) && QFile::exists(pathNow))
|
||||
plugin.typeInfoPaths += pathNow;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ protected:
|
||||
if (_hasOpenComment) {
|
||||
newLine();
|
||||
}
|
||||
if (lastLoc.isValid()) {
|
||||
if (lastLoc.length != 0) {
|
||||
QList<SourceLocation> comments = _doc->engine()->comments();
|
||||
for (; _nextComment < comments.size(); ++_nextComment) {
|
||||
SourceLocation commentLoc = comments.at(_nextComment);
|
||||
@@ -237,7 +237,7 @@ protected:
|
||||
|
||||
void out(const SourceLocation &loc)
|
||||
{
|
||||
if (!loc.isValid())
|
||||
if (loc.length == 0)
|
||||
return;
|
||||
out(toString(loc), loc);
|
||||
}
|
||||
@@ -489,7 +489,7 @@ protected:
|
||||
else if (UiImport *import = cast<UiImport *>(ast))
|
||||
firstLoc = import->firstSourceLocation();
|
||||
|
||||
if (firstLoc.isValid() && int(firstLoc.offset) != _lastNewlineOffset) {
|
||||
if (firstLoc.length != 0 && int(firstLoc.offset) != _lastNewlineOffset) {
|
||||
_lastNewlineOffset = firstLoc.offset;
|
||||
|
||||
if (precededByEmptyLine(firstLoc) && !_result.endsWith(QLatin1String("\n\n")))
|
||||
@@ -511,7 +511,7 @@ protected:
|
||||
else if (UiImport *import = cast<UiImport *>(ast))
|
||||
lastLoc = import->lastSourceLocation();
|
||||
|
||||
if (lastLoc.isValid()) {
|
||||
if (lastLoc.length != 0) {
|
||||
const QList<SourceLocation> &comments = _doc->engine()->comments();
|
||||
|
||||
// preserve trailing comments
|
||||
@@ -566,7 +566,7 @@ protected:
|
||||
{
|
||||
for (UiEnumMemberList *it = list; it; it = it->next) {
|
||||
out(it->memberToken);
|
||||
if (it->valueToken.isValid()) {
|
||||
if (it->valueToken.length != 0) {
|
||||
out(" = ");
|
||||
out(it->valueToken);
|
||||
}
|
||||
@@ -1136,7 +1136,7 @@ protected:
|
||||
{
|
||||
out(ast->returnToken);
|
||||
if (ast->expression) {
|
||||
if (ast->returnToken.isValid())
|
||||
if (ast->returnToken.length != 0)
|
||||
out(" ");
|
||||
accept(ast->expression);
|
||||
}
|
||||
@@ -1277,7 +1277,7 @@ protected:
|
||||
out("=> ");
|
||||
out(ast->lbraceToken);
|
||||
if (ast->body) {
|
||||
if (ast->body->next || ast->lbraceToken.isValid()) {
|
||||
if (ast->body->next || ast->lbraceToken.length != 0) {
|
||||
lnAcceptIndented(ast->body);
|
||||
newLine();
|
||||
} else {
|
||||
|
||||
@@ -209,7 +209,7 @@ const QString undefinedVersion = QLatin1String("-1.-1");
|
||||
* undefined version (-1.-1) or if it is empty. False otherwise.
|
||||
*/
|
||||
bool QmlJS::maybeModuleVersion(const QString &version) {
|
||||
QRegularExpression re(QLatin1String("^\\d+\\.\\d+$"));
|
||||
QRegularExpression re(QLatin1String("^\\d+\\.-?\\d+$"));
|
||||
return version.isEmpty() || version == undefinedVersion || re.match(version).hasMatch();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user