2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-03-18 12:06:43 +01:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-03-18 12:06:43 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-03-18 12:06:43 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:58:39 +01:00
|
|
|
** 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.
|
2011-05-12 13:25:35 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** 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.
|
2010-03-18 12:06:43 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-03-18 12:06:43 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2010-03-18 12:06:43 +01:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 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.
|
|
|
|
|
//
|
|
|
|
|
|
2012-07-31 10:12:26 +02:00
|
|
|
#include <QtCore/QUrl>
|
|
|
|
|
#include <QtCore/QHash>
|
|
|
|
|
#include <QtCore/QDebug>
|
2010-03-18 12:06:43 +01:00
|
|
|
|
2016-04-29 11:00:30 +02:00
|
|
|
#include "qmljsengine_p.h"
|
2012-08-01 07:48:37 +02:00
|
|
|
|
2010-03-18 12:06:43 +01:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
|
|
class QmlError;
|
2012-07-31 10:12:26 +02:00
|
|
|
class QmlEngine;
|
2012-08-01 07:48:37 +02:00
|
|
|
class QML_PARSER_EXPORT QmlDirParser
|
2010-03-18 12:06:43 +01:00
|
|
|
{
|
|
|
|
|
Q_DISABLE_COPY(QmlDirParser)
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
QmlDirParser();
|
|
|
|
|
~QmlDirParser();
|
|
|
|
|
|
2012-07-31 10:12:26 +02:00
|
|
|
bool parse(const QString &source);
|
2010-03-18 12:06:43 +01:00
|
|
|
|
|
|
|
|
bool hasError() const;
|
2012-07-31 10:12:26 +02:00
|
|
|
void setError(const QmlError &);
|
2011-09-13 08:42:52 +02:00
|
|
|
QList<QmlError> errors(const QString &uri) const;
|
2010-03-18 12:06:43 +01:00
|
|
|
|
2012-07-31 10:12:26 +02:00
|
|
|
QString typeNamespace() const;
|
|
|
|
|
void setTypeNamespace(const QString &s);
|
|
|
|
|
|
2010-03-18 12:06:43 +01:00
|
|
|
struct Plugin
|
|
|
|
|
{
|
|
|
|
|
Plugin() {}
|
|
|
|
|
|
|
|
|
|
Plugin(const QString &name, const QString &path)
|
|
|
|
|
: name(name), path(path) {}
|
|
|
|
|
|
|
|
|
|
QString name;
|
|
|
|
|
QString path;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Component
|
|
|
|
|
{
|
|
|
|
|
Component()
|
2013-11-06 14:17:23 +01:00
|
|
|
: majorVersion(0), minorVersion(0), internal(false), singleton(false) {}
|
2010-03-18 12:06:43 +01:00
|
|
|
|
2011-12-07 11:16:26 +01:00
|
|
|
Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion)
|
2010-03-25 14:11:23 +01:00
|
|
|
: typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion),
|
2013-11-06 14:17:23 +01:00
|
|
|
internal(false), singleton(false) {}
|
2010-03-18 12:06:43 +01:00
|
|
|
|
2011-12-07 11:16:26 +01:00
|
|
|
QString typeName;
|
2010-03-18 12:06:43 +01:00
|
|
|
QString fileName;
|
|
|
|
|
int majorVersion;
|
|
|
|
|
int minorVersion;
|
2010-03-25 14:11:23 +01:00
|
|
|
bool internal;
|
2013-11-06 14:17:23 +01:00
|
|
|
bool singleton;
|
2010-03-18 12:06:43 +01:00
|
|
|
};
|
|
|
|
|
|
2012-07-31 10:12:26 +02:00
|
|
|
struct Script
|
|
|
|
|
{
|
|
|
|
|
Script()
|
|
|
|
|
: majorVersion(0), minorVersion(0) {}
|
|
|
|
|
|
|
|
|
|
Script(const QString &nameSpace, const QString &fileName, int majorVersion, int minorVersion)
|
|
|
|
|
: nameSpace(nameSpace), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion) {}
|
|
|
|
|
|
|
|
|
|
QString nameSpace;
|
|
|
|
|
QString fileName;
|
|
|
|
|
int majorVersion;
|
|
|
|
|
int minorVersion;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QHash<QString,Component> components() const;
|
2016-04-29 11:00:30 +02:00
|
|
|
QHash<QString,Component> dependencies() const;
|
2012-07-31 10:12:26 +02:00
|
|
|
QList<Script> scripts() const;
|
2010-03-18 12:06:43 +01:00
|
|
|
QList<Plugin> plugins() const;
|
2016-04-29 11:00:30 +02:00
|
|
|
bool designerSupported() const;
|
2010-03-18 12:06:43 +01:00
|
|
|
|
2011-05-12 13:25:35 +02:00
|
|
|
#ifdef QT_CREATOR
|
|
|
|
|
struct TypeInfo
|
|
|
|
|
{
|
|
|
|
|
TypeInfo() {}
|
|
|
|
|
TypeInfo(const QString &fileName)
|
|
|
|
|
: fileName(fileName) {}
|
|
|
|
|
|
|
|
|
|
QString fileName;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QList<TypeInfo> typeInfos() const;
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-03-18 12:06:43 +01:00
|
|
|
private:
|
2016-04-29 11:00:30 +02:00
|
|
|
bool maybeAddComponent(const QString &typeName, const QString &fileName, const QString &version, QHash<QString,Component> &hash, int lineNumber = -1, bool multi = true);
|
2013-01-22 11:15:23 +01:00
|
|
|
void reportError(quint16 line, quint16 column, const QString &message);
|
2010-03-18 12:06:43 +01:00
|
|
|
|
|
|
|
|
private:
|
2016-04-29 11:00:30 +02:00
|
|
|
QList<QmlJS::DiagnosticMessage> _errors;
|
2012-07-31 10:12:26 +02:00
|
|
|
QString _typeNamespace;
|
|
|
|
|
QHash<QString,Component> _components; // multi hash
|
2016-04-29 11:00:30 +02:00
|
|
|
QHash<QString,Component> _dependencies;
|
2012-07-31 10:12:26 +02:00
|
|
|
QList<Script> _scripts;
|
2010-03-18 12:06:43 +01:00
|
|
|
QList<Plugin> _plugins;
|
2016-04-29 11:00:30 +02:00
|
|
|
bool _designerSupported;
|
2011-05-12 13:25:35 +02:00
|
|
|
#ifdef QT_CREATOR
|
|
|
|
|
QList<TypeInfo> _typeInfos;
|
|
|
|
|
#endif
|
2010-03-18 12:06:43 +01:00
|
|
|
};
|
|
|
|
|
|
2012-07-31 10:12:26 +02:00
|
|
|
typedef QHash<QString,QmlDirParser::Component> QmlDirComponents;
|
|
|
|
|
typedef QList<QmlDirParser::Script> QmlDirScripts;
|
|
|
|
|
typedef QList<QmlDirParser::Plugin> QmlDirPlugins;
|
2010-03-25 14:11:23 +01:00
|
|
|
|
2012-07-31 10:12:26 +02:00
|
|
|
QDebug &operator<< (QDebug &, const QmlDirParser::Component &);
|
|
|
|
|
QDebug &operator<< (QDebug &, const QmlDirParser::Script &);
|
2010-03-25 14:11:23 +01:00
|
|
|
|
2010-03-18 12:06:43 +01:00
|
|
|
QT_END_NAMESPACE
|