2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-01-18 16:15:23 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2010-01-18 16:15:23 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-01-18 16:15:23 +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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2010-01-18 16:15:23 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-01-18 16:15:23 +01:00
|
|
|
|
2013-03-12 12:09:22 +01:00
|
|
|
#ifndef QMLJSBIND_H
|
|
|
|
|
#define QMLJSBIND_H
|
2010-01-18 16:15:23 +01:00
|
|
|
|
2010-01-26 14:50:52 +01:00
|
|
|
#include <qmljs/parser/qmljsastvisitor_p.h>
|
2011-07-01 12:11:02 +02:00
|
|
|
#include <qmljs/qmljsvalueowner.h>
|
2010-01-18 16:15:23 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QHash>
|
|
|
|
|
#include <QCoreApplication>
|
2010-01-28 14:53:53 +01:00
|
|
|
|
2010-01-18 16:15:23 +01:00
|
|
|
namespace QmlJS {
|
|
|
|
|
|
2015-03-04 16:46:23 +01:00
|
|
|
class DiagnosticMessage;
|
2010-02-03 15:59:15 +01:00
|
|
|
class Document;
|
2010-01-28 14:53:53 +01:00
|
|
|
|
2010-01-18 16:15:23 +01:00
|
|
|
class QMLJS_EXPORT Bind: protected AST::Visitor
|
|
|
|
|
{
|
2010-02-03 15:59:15 +01:00
|
|
|
Q_DISABLE_COPY(Bind)
|
2010-09-16 15:29:37 +02:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(QmlJS::Bind)
|
2010-02-03 15:59:15 +01:00
|
|
|
|
2010-02-01 16:39:32 +01:00
|
|
|
public:
|
2011-09-27 15:12:22 +02:00
|
|
|
Bind(Document *doc, QList<DiagnosticMessage> *messages,
|
|
|
|
|
bool isJsLibrary, const QList<ImportInfo> &jsImports);
|
2014-02-07 09:01:53 +01:00
|
|
|
~Bind();
|
2010-01-18 16:15:23 +01:00
|
|
|
|
2011-09-27 15:12:22 +02:00
|
|
|
bool isJsLibrary() const;
|
2011-08-08 12:47:49 +02:00
|
|
|
QList<ImportInfo> imports() const;
|
2010-02-01 17:20:46 +01:00
|
|
|
|
2011-08-08 12:47:49 +02:00
|
|
|
ObjectValue *idEnvironment() const;
|
|
|
|
|
ObjectValue *rootObjectValue() const;
|
2010-02-10 17:05:45 +01:00
|
|
|
|
2011-08-08 12:47:49 +02:00
|
|
|
ObjectValue *findQmlObject(AST::Node *node) const;
|
|
|
|
|
bool usesQmlPrototype(ObjectValue *prototype,
|
|
|
|
|
const ContextPtr &context) const;
|
2010-02-01 12:17:39 +01:00
|
|
|
|
2011-08-08 12:47:49 +02:00
|
|
|
ObjectValue *findAttachedJSScope(AST::Node *node) const;
|
2010-05-12 13:58:23 +02:00
|
|
|
bool isGroupedPropertyBinding(AST::Node *node) const;
|
2010-04-20 15:19:37 +02:00
|
|
|
|
2010-02-10 17:05:45 +01:00
|
|
|
protected:
|
|
|
|
|
using AST::Visitor::visit;
|
2010-02-01 12:17:39 +01:00
|
|
|
|
2010-01-18 16:15:23 +01:00
|
|
|
void accept(AST::Node *node);
|
|
|
|
|
|
2014-09-24 12:49:32 +02:00
|
|
|
bool visit(AST::UiProgram *ast) Q_DECL_OVERRIDE;
|
|
|
|
|
bool visit(AST::Program *ast) Q_DECL_OVERRIDE;
|
2010-02-03 14:31:03 +01:00
|
|
|
|
2010-01-18 16:15:23 +01:00
|
|
|
// Ui
|
2014-09-24 12:49:32 +02:00
|
|
|
bool visit(AST::UiImport *ast) Q_DECL_OVERRIDE;
|
|
|
|
|
bool visit(AST::UiPublicMember *ast) Q_DECL_OVERRIDE;
|
|
|
|
|
bool visit(AST::UiObjectDefinition *ast) Q_DECL_OVERRIDE;
|
|
|
|
|
bool visit(AST::UiObjectBinding *ast) Q_DECL_OVERRIDE;
|
|
|
|
|
bool visit(AST::UiScriptBinding *ast) Q_DECL_OVERRIDE;
|
|
|
|
|
bool visit(AST::UiArrayBinding *ast) Q_DECL_OVERRIDE;
|
2010-02-03 14:31:03 +01:00
|
|
|
|
|
|
|
|
// QML/JS
|
2014-09-24 12:49:32 +02:00
|
|
|
bool visit(AST::FunctionDeclaration *ast) Q_DECL_OVERRIDE;
|
|
|
|
|
bool visit(AST::FunctionExpression *ast) Q_DECL_OVERRIDE;
|
|
|
|
|
bool visit(AST::VariableDeclaration *ast) Q_DECL_OVERRIDE;
|
2010-01-18 16:15:23 +01:00
|
|
|
|
2011-08-08 12:47:49 +02:00
|
|
|
ObjectValue *switchObjectValue(ObjectValue *newObjectValue);
|
|
|
|
|
ObjectValue *bindObject(AST::UiQualifiedId *qualifiedTypeNameId, AST::UiObjectInitializer *initializer);
|
2010-01-26 14:50:52 +01:00
|
|
|
|
2010-01-18 16:15:23 +01:00
|
|
|
private:
|
2010-02-02 15:55:17 +01:00
|
|
|
Document *_doc;
|
2011-08-08 12:47:49 +02:00
|
|
|
ValueOwner _valueOwner;
|
2010-01-26 14:50:52 +01:00
|
|
|
|
2011-08-08 12:47:49 +02:00
|
|
|
ObjectValue *_currentObjectValue;
|
|
|
|
|
ObjectValue *_idEnvironment;
|
|
|
|
|
ObjectValue *_rootObjectValue;
|
2010-01-28 14:53:53 +01:00
|
|
|
|
2011-08-08 12:47:49 +02:00
|
|
|
QHash<AST::Node *, ObjectValue *> _qmlObjects;
|
2011-09-13 10:09:14 +02:00
|
|
|
QMultiHash<QString, const ObjectValue *> _qmlObjectsByPrototypeName;
|
2010-05-12 13:58:23 +02:00
|
|
|
QSet<AST::Node *> _groupedPropertyBindings;
|
2011-08-08 12:47:49 +02:00
|
|
|
QHash<AST::Node *, ObjectValue *> _attachedJSScopes;
|
2010-04-06 09:52:29 +02:00
|
|
|
|
2011-09-27 15:12:22 +02:00
|
|
|
bool _isJsLibrary;
|
2011-08-08 12:47:49 +02:00
|
|
|
QList<ImportInfo> _imports;
|
2010-09-16 15:29:37 +02:00
|
|
|
|
|
|
|
|
QList<DiagnosticMessage> *_diagnosticMessages;
|
2010-01-18 16:15:23 +01:00
|
|
|
};
|
|
|
|
|
|
2011-02-04 09:52:39 +01:00
|
|
|
} // namespace Qml
|
2010-01-18 16:15:23 +01:00
|
|
|
|
2013-03-12 12:09:22 +01:00
|
|
|
#endif // QMLJSBIND_H
|