2010-01-18 16:15:23 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2010-01-18 16:15:23 +01:00
|
|
|
**
|
2012-07-19 12:26:56 +02:00
|
|
|
** Contact: http://www.qt-project.org/
|
2010-01-18 16:15:23 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2010-01-18 16:15:23 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-01-18 16:15:23 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef QMLBIND_H
|
|
|
|
|
#define QMLBIND_H
|
|
|
|
|
|
2010-01-26 14:50:52 +01:00
|
|
|
#include <qmljs/parser/qmljsastvisitor_p.h>
|
|
|
|
|
#include <qmljs/qmljsinterpreter.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 <QStringList>
|
|
|
|
|
#include <QSharedPointer>
|
|
|
|
|
#include <QCoreApplication>
|
2010-01-28 14:53:53 +01:00
|
|
|
|
2010-01-18 16:15:23 +01:00
|
|
|
namespace QmlJS {
|
|
|
|
|
|
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);
|
2010-01-18 16:15:23 +01:00
|
|
|
virtual ~Bind();
|
|
|
|
|
|
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);
|
|
|
|
|
|
2010-02-03 14:31:03 +01:00
|
|
|
virtual bool visit(AST::UiProgram *ast);
|
|
|
|
|
virtual bool visit(AST::Program *ast);
|
|
|
|
|
|
2010-01-18 16:15:23 +01:00
|
|
|
// Ui
|
|
|
|
|
virtual bool visit(AST::UiImport *ast);
|
|
|
|
|
virtual bool visit(AST::UiPublicMember *ast);
|
|
|
|
|
virtual bool visit(AST::UiObjectDefinition *ast);
|
|
|
|
|
virtual bool visit(AST::UiObjectBinding *ast);
|
|
|
|
|
virtual bool visit(AST::UiScriptBinding *ast);
|
|
|
|
|
virtual bool visit(AST::UiArrayBinding *ast);
|
2010-02-03 14:31:03 +01:00
|
|
|
|
|
|
|
|
// QML/JS
|
2010-01-18 16:15:23 +01:00
|
|
|
virtual bool visit(AST::FunctionDeclaration *ast);
|
2010-11-16 13:53:39 +01:00
|
|
|
virtual bool visit(AST::FunctionExpression *ast);
|
2010-02-03 14:31:03 +01:00
|
|
|
virtual bool visit(AST::VariableDeclaration *ast);
|
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
|
|
|
|
|
|
|
|
#endif // QMLBIND_H
|