forked from qt-creator/qt-creator
Update qmljs parser to Qt 5.15 parser
* parser side support for annotations, inline components, new UiVersion and all the things included in QT 5.15 parser * SourceLocation moved from QmlJS:AST to QmlJS * Visitors now need to handle throwRecursionDepthError * BaseVisitor for visitors that want to override all visit Task-number: QTCREATORBUG-23591 Change-Id: I682a30d0b08b6c929739fd0e339ef6fbde3eb630 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
@@ -39,34 +39,44 @@
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QDebug>
|
||||
#include "qmljsengine_p.h"
|
||||
#include "qmljsglobal_p.h"
|
||||
#include "qmljs/parser/qmljsglobal_p.h"
|
||||
#include "qmljs/parser/qmljsengine_p.h"
|
||||
#include "qmljs/parser/qmljsdiagnosticmessage_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
QT_QML_BEGIN_NAMESPACE
|
||||
|
||||
class QmlError;
|
||||
class QmlEngine;
|
||||
class QML_PARSER_EXPORT QmlDirParser
|
||||
{
|
||||
public:
|
||||
QmlDirParser();
|
||||
~QmlDirParser();
|
||||
|
||||
void clear();
|
||||
bool parse(const QString &source);
|
||||
|
||||
bool hasError() const;
|
||||
void setError(const QmlError &);
|
||||
QList<QmlError> errors(const QString &uri) const;
|
||||
void setError(const QmlJS::DiagnosticMessage &);
|
||||
QList<QmlJS::DiagnosticMessage> errors(const QString &uri) const;
|
||||
|
||||
QString typeNamespace() const;
|
||||
void setTypeNamespace(const QString &s);
|
||||
|
||||
static void checkNonRelative(const char *item, const QString &typeName, const QString &fileName)
|
||||
{
|
||||
if (fileName.startsWith(QLatin1Char('/'))) {
|
||||
qWarning() << item << typeName
|
||||
<< "is specified with non-relative URL" << fileName << "in a qmldir file."
|
||||
<< "URLs in qmldir files should be relative to the qmldir file's directory.";
|
||||
}
|
||||
}
|
||||
|
||||
struct Plugin
|
||||
{
|
||||
Plugin() {}
|
||||
Plugin() = default;
|
||||
|
||||
Plugin(const QString &name, const QString &path)
|
||||
: name(name), path(path) {}
|
||||
: name(name), path(path)
|
||||
{
|
||||
checkNonRelative("Plugin", name, path);
|
||||
}
|
||||
|
||||
QString name;
|
||||
QString path;
|
||||
@@ -74,11 +84,14 @@ public:
|
||||
|
||||
struct Component
|
||||
{
|
||||
Component() {}
|
||||
Component() = default;
|
||||
|
||||
Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion)
|
||||
: typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion),
|
||||
internal(false), singleton(false) {}
|
||||
internal(false), singleton(false)
|
||||
{
|
||||
checkNonRelative("Component", typeName, fileName);
|
||||
}
|
||||
|
||||
QString typeName;
|
||||
QString fileName;
|
||||
@@ -90,10 +103,13 @@ public:
|
||||
|
||||
struct Script
|
||||
{
|
||||
Script() {}
|
||||
Script() = default;
|
||||
|
||||
Script(const QString &nameSpace, const QString &fileName, int majorVersion, int minorVersion)
|
||||
: nameSpace(nameSpace), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion) {}
|
||||
: nameSpace(nameSpace), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion)
|
||||
{
|
||||
checkNonRelative("Script", nameSpace, fileName);
|
||||
}
|
||||
|
||||
QString nameSpace;
|
||||
QString fileName;
|
||||
@@ -101,16 +117,16 @@ public:
|
||||
int minorVersion = 0;
|
||||
};
|
||||
|
||||
QHash<QString,Component> components() const;
|
||||
QMultiHash<QString,Component> components() const;
|
||||
QHash<QString,Component> dependencies() const;
|
||||
QStringList imports() const;
|
||||
QList<Script> scripts() const;
|
||||
QList<Plugin> plugins() const;
|
||||
bool designerSupported() const;
|
||||
|
||||
#ifdef QT_CREATOR
|
||||
struct TypeInfo
|
||||
{
|
||||
TypeInfo() {}
|
||||
TypeInfo() = default;
|
||||
TypeInfo(const QString &fileName)
|
||||
: fileName(fileName) {}
|
||||
|
||||
@@ -118,7 +134,6 @@ public:
|
||||
};
|
||||
|
||||
QList<TypeInfo> typeInfos() const;
|
||||
#endif
|
||||
|
||||
QString className() const;
|
||||
|
||||
@@ -129,23 +144,22 @@ private:
|
||||
private:
|
||||
QList<QmlJS::DiagnosticMessage> _errors;
|
||||
QString _typeNamespace;
|
||||
QHash<QString,Component> _components; // multi hash
|
||||
QMultiHash<QString,Component> _components;
|
||||
QHash<QString,Component> _dependencies;
|
||||
QStringList _imports;
|
||||
QList<Script> _scripts;
|
||||
QList<Plugin> _plugins;
|
||||
bool _designerSupported;
|
||||
#ifdef QT_CREATOR
|
||||
bool _designerSupported = false;
|
||||
QList<TypeInfo> _typeInfos;
|
||||
#endif
|
||||
QString _className;
|
||||
};
|
||||
|
||||
typedef QHash<QString,QmlDirParser::Component> QmlDirComponents;
|
||||
typedef QList<QmlDirParser::Script> QmlDirScripts;
|
||||
typedef QList<QmlDirParser::Plugin> QmlDirPlugins;
|
||||
using QmlDirComponents = QMultiHash<QString,QmlDirParser::Component>;
|
||||
using QmlDirScripts = QList<QmlDirParser::Script>;
|
||||
using QmlDirPlugins = QList<QmlDirParser::Plugin>;
|
||||
|
||||
QDebug &operator<< (QDebug &, const QmlDirParser::Component &);
|
||||
QDebug &operator<< (QDebug &, const QmlDirParser::Script &);
|
||||
|
||||
QT_END_NAMESPACE
|
||||
QT_QML_END_NAMESPACE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user