qmljs: Fix parsing and and loading of qmldir imports

Add most changes to the qmldir parser of Qt6. This is not a direct
application of the changes because they rely on changes to QtBase that
are Q6 only.
Ignore load errors of optional dependencies.

Fixes: QTCREATORBUG-24772
Change-Id: I0b85818b602c8c7c1712e52318b4ca3f15364cc5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Fawzi Mohamed
2020-11-26 07:32:29 +01:00
parent 23501b4271
commit 5ce8cf70e8
6 changed files with 157 additions and 57 deletions

View File

@@ -39,6 +39,9 @@
#include <QtCore/QUrl>
#include <QtCore/QHash>
#include <QtCore/QDebug>
#include <languageutils/componentversion.h>
#include "qmljs/parser/qmljsglobal_p.h"
#include "qmljs/parser/qmljsengine_p.h"
#include "qmljs/parser/qmljsdiagnosticmessage_p.h"
@@ -72,14 +75,15 @@ public:
{
Plugin() = default;
Plugin(const QString &name, const QString &path)
: name(name), path(path)
Plugin(const QString &name, const QString &path, bool optional)
: name(name), path(path), optional(optional)
{
checkNonRelative("Plugin", name, path);
}
QString name;
QString path;
bool optional = false;
};
struct Component
@@ -117,9 +121,29 @@ public:
int minorVersion = 0;
};
struct Import
{
enum Flag {
Default = 0x0,
Auto = 0x1, // forward the version of the importing module
Optional = 0x2 // is not automatically imported but only a tooling hint
};
Q_DECLARE_FLAGS(Flags, Flag)
Import() = default;
Import(QString module, LanguageUtils::ComponentVersion version, Flags flags)
: module(module), version(version), flags(flags)
{
}
QString module;
LanguageUtils::ComponentVersion version; // invalid version is latest version, unless Flag::Auto
Flags flags;
};
QMultiHash<QString,Component> components() const;
QHash<QString,Component> dependencies() const;
QStringList imports() const;
QList<Import> dependencies() const;
QList<Import> imports() const;
QList<Script> scripts() const;
QList<Plugin> plugins() const;
bool designerSupported() const;
@@ -145,8 +169,8 @@ private:
QList<QmlJS::DiagnosticMessage> _errors;
QString _typeNamespace;
QMultiHash<QString,Component> _components;
QHash<QString,Component> _dependencies;
QStringList _imports;
QList<Import> _dependencies;
QList<Import> _imports;
QList<Script> _scripts;
QList<Plugin> _plugins;
bool _designerSupported = false;