OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / libs / qmljs / qmljsbind.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef QMLBIND_H
34 #define QMLBIND_H
35
36 #include <qmljs/parser/qmljsastvisitor_p.h>
37 #include <qmljs/qmljsinterpreter.h>
38
39 #include <QtCore/QHash>
40 #include <QtCore/QStringList>
41 #include <QtCore/QSharedPointer>
42 #include <QtCore/QCoreApplication>
43
44 namespace QmlJS {
45
46 class Link;
47 class Document;
48
49 class QMLJS_EXPORT Bind: protected AST::Visitor
50 {
51     Q_DISABLE_COPY(Bind)
52     Q_DECLARE_TR_FUNCTIONS(QmlJS::Bind)
53
54 public:
55     Bind(Document *doc, QList<DiagnosticMessage> *messages);
56     virtual ~Bind();
57
58     QList<Interpreter::ImportInfo> imports() const;
59
60     Interpreter::ObjectValue *idEnvironment() const;
61     Interpreter::ObjectValue *rootObjectValue() const;
62
63     Interpreter::ObjectValue *findQmlObject(AST::Node *node) const;
64     bool usesQmlPrototype(Interpreter::ObjectValue *prototype,
65                           const Interpreter::Context *context) const;
66
67     Interpreter::ObjectValue *findFunctionScope(AST::FunctionExpression *node) const;
68     bool isGroupedPropertyBinding(AST::Node *node) const;
69
70     static QString toString(AST::UiQualifiedId *qualifiedId, QChar delimiter = QChar('.'));
71
72 protected:
73     using AST::Visitor::visit;
74
75     void accept(AST::Node *node);
76
77     virtual bool visit(AST::UiProgram *ast);
78     virtual bool visit(AST::Program *ast);
79
80     // Ui
81     virtual bool visit(AST::UiImport *ast);
82     virtual bool visit(AST::UiPublicMember *ast);
83     virtual bool visit(AST::UiObjectDefinition *ast);
84     virtual bool visit(AST::UiObjectBinding *ast);
85     virtual bool visit(AST::UiScriptBinding *ast);
86     virtual bool visit(AST::UiArrayBinding *ast);
87
88     // QML/JS
89     virtual bool visit(AST::FunctionDeclaration *ast);
90     virtual bool visit(AST::FunctionExpression *ast);
91     virtual bool visit(AST::VariableDeclaration *ast);
92
93     Interpreter::ObjectValue *switchObjectValue(Interpreter::ObjectValue *newObjectValue);
94     Interpreter::ObjectValue *bindObject(AST::UiQualifiedId *qualifiedTypeNameId, AST::UiObjectInitializer *initializer);
95
96 private:
97     Document *_doc;
98     Interpreter::Engine _engine;
99
100     Interpreter::ObjectValue *_currentObjectValue;
101     Interpreter::ObjectValue *_idEnvironment;
102     Interpreter::ObjectValue *_rootObjectValue;
103
104     QHash<AST::Node *, Interpreter::ObjectValue *> _qmlObjects;
105     QSet<AST::Node *> _groupedPropertyBindings;
106     QHash<AST::FunctionExpression *, Interpreter::ObjectValue *> _functionScopes;
107     QStringList _includedScripts;
108
109     QList<Interpreter::ImportInfo> _imports;
110
111     QList<DiagnosticMessage> *_diagnosticMessages;
112 };
113
114 } // namespace Qml
115
116 #endif // QMLBIND_H