2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2010-01-18 16:15:23 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
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-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;
|
2022-12-19 16:41:00 +01:00
|
|
|
const 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
|
|
|
|
2021-01-19 20:34:51 +01:00
|
|
|
QHash<QString, ObjectValue*> inlineComponents() const {
|
|
|
|
|
return _inlineComponents;
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
|
2015-06-03 15:34:13 +02:00
|
|
|
bool visit(AST::UiProgram *ast) override;
|
|
|
|
|
bool visit(AST::Program *ast) override;
|
2018-06-20 11:32:47 +02:00
|
|
|
void endVisit(AST::UiProgram *) override;
|
2010-02-03 14:31:03 +01:00
|
|
|
|
2010-01-18 16:15:23 +01:00
|
|
|
// Ui
|
2015-06-03 15:34:13 +02:00
|
|
|
bool visit(AST::UiImport *ast) override;
|
|
|
|
|
bool visit(AST::UiPublicMember *ast) override;
|
|
|
|
|
bool visit(AST::UiObjectDefinition *ast) override;
|
|
|
|
|
bool visit(AST::UiObjectBinding *ast) override;
|
|
|
|
|
bool visit(AST::UiScriptBinding *ast) override;
|
|
|
|
|
bool visit(AST::UiArrayBinding *ast) override;
|
2021-01-19 20:34:51 +01:00
|
|
|
bool visit(AST::UiInlineComponent *ast) override;
|
2010-02-03 14:31:03 +01:00
|
|
|
|
|
|
|
|
// QML/JS
|
2021-12-06 09:44:24 +01:00
|
|
|
bool visit(AST::TemplateLiteral *ast) override;
|
2015-06-03 15:34:13 +02:00
|
|
|
bool visit(AST::FunctionDeclaration *ast) override;
|
|
|
|
|
bool visit(AST::FunctionExpression *ast) override;
|
2018-10-16 15:32:58 +02:00
|
|
|
bool visit(AST::PatternElement *ast) 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
|
|
|
|
2020-02-28 17:51:32 +01:00
|
|
|
void throwRecursionDepthError() override;
|
|
|
|
|
|
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;
|
2021-01-19 20:34:51 +01:00
|
|
|
QString _currentComponentName;
|
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;
|
2021-01-19 20:34:51 +01:00
|
|
|
QHash<QString, ObjectValue*> _inlineComponents;
|
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
|