Commit 0f9b9b04 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Imported the QML front-end from Qt/Kinetic

parent d08b90b4
......@@ -28,15 +28,15 @@
**************************************************************************/
#include "duidocument.h"
#include "javascriptast_p.h"
#include "javascriptlexer_p.h"
#include "javascriptparser_p.h"
#include "javascriptengine_p.h"
#include "javascriptnodepool_p.h"
#include "qmljsast_p.h"
#include "qmljslexer_p.h"
#include "qmljsparser_p.h"
#include "qmljsengine_p.h"
#include "qmljsnodepool_p.h"
using namespace DuiEditor;
using namespace DuiEditor::Internal;
using namespace JavaScript;
using namespace QmlJS;
DuiDocument::DuiDocument(const QString &fileName)
: _engine(0), _pool(0), _program(0), _fileName(fileName)
......
......@@ -33,8 +33,8 @@
#include <QtCore/QMap>
#include <QtCore/QString>
#include "javascriptengine_p.h"
#include "javascriptastfwd_p.h"
#include "qmljsengine_p.h"
#include "qmljsastfwd_p.h"
namespace DuiEditor {
namespace Internal {
......@@ -52,17 +52,17 @@ public:
static DuiDocument::Ptr create(const QString &fileName);
JavaScript::AST::UiProgram *program() const;
QList<JavaScript::DiagnosticMessage> diagnosticMessages() const;
QmlJS::AST::UiProgram *program() const;
QList<QmlJS::DiagnosticMessage> diagnosticMessages() const;
void setSource(const QString &source);
bool parse();
private:
JavaScript::Engine *_engine;
JavaScript::NodePool *_pool;
JavaScript::AST::UiProgram *_program;
QList<JavaScript::DiagnosticMessage> _diagnosticMessages;
QmlJS::Engine *_engine;
QmlJS::NodePool *_pool;
QmlJS::AST::UiProgram *_program;
QList<QmlJS::DiagnosticMessage> _diagnosticMessages;
QString _fileName;
QString _source;
};
......
......@@ -35,9 +35,9 @@
#include "rewriter_p.h"
#include "javascriptastvisitor_p.h"
#include "javascriptast_p.h"
#include "javascriptengine_p.h"
#include "qmljsastvisitor_p.h"
#include "qmljsast_p.h"
#include "qmljsengine_p.h"
#include <coreplugin/icore.h>
#include <coreplugin/actionmanager/actionmanager.h>
......@@ -61,8 +61,8 @@ enum {
UPDATE_DOCUMENT_DEFAULT_INTERVAL = 250
};
using namespace JavaScript;
using namespace JavaScript::AST;
using namespace QmlJS;
using namespace QmlJS::AST;
namespace DuiEditor {
......
......@@ -32,8 +32,8 @@
#include <texteditor/basetexteditor.h>
#include "javascriptastfwd_p.h"
#include "javascriptengine_p.h"
#include "qmljsastfwd_p.h"
#include "qmljsengine_p.h"
#include "duidocument.h"
QT_BEGIN_NAMESPACE
......@@ -101,7 +101,7 @@ public:
QStringList words() const;
QStringList keywords() const;
QList<JavaScript::DiagnosticMessage> diagnosticMessages() const
QList<QmlJS::DiagnosticMessage> diagnosticMessages() const
{ return m_diagnosticMessages; }
virtual void unCommentSelection();
......@@ -137,8 +137,8 @@ private:
QComboBox *m_methodCombo;
QList<Declaration> m_declarations;
QStringList m_words;
QMap<QString, QList<JavaScript::AST::SourceLocation> > m_ids; // ### use QMultiMap
QList<JavaScript::DiagnosticMessage> m_diagnosticMessages;
QMap<QString, QList<QmlJS::AST::SourceLocation> > m_ids; // ### use QMultiMap
QList<QmlJS::DiagnosticMessage> m_diagnosticMessages;
DuiDocument::Ptr m_document;
};
......
......@@ -7,15 +7,10 @@ include(../../plugins/texteditor/texteditor.pri)
include(../../shared/qscripthighlighter/qscripthighlighter.pri)
include(../../shared/indenter/indenter.pri)
DUI=$$(QTDIR_DUI)
isEmpty(DUI):DUI=$$fromfile($$(QTDIR)/.qmake.cache,QT_SOURCE_TREE)
include(parser/parser.pri)
include(rewriter/rewriter.pri)
!isEmpty(DUI):exists($$DUI/src/declarative/qml/parser) {
include($$DUI/src/declarative/qml/parser/parser.pri)
include($$DUI/src/declarative/qml/rewriter/rewriter.pri)
} else {
error(run with export QTDIR_DUI=<path to kinetic/qt>)
}
INCLUDEPATH += parser rewriter
HEADERS += duieditor.h \
duieditorfactory.h \
......
......@@ -92,7 +92,7 @@ void DuiHoverHandler::showToolTip(TextEditor::ITextEditor *editor, const QPoint
tc.setPosition(pos);
const unsigned line = tc.block().blockNumber() + 1;
foreach (const JavaScript::DiagnosticMessage &m, ed->diagnosticMessages()) {
foreach (const QmlJS::DiagnosticMessage &m, ed->diagnosticMessages()) {
if (m.loc.startLine == line) {
m_toolTip.append(m.message);
break;
......
INCLUDEPATH += $$PWD
HEADERS += $$PWD/qmljsast_p.h \
$$PWD/qmljsastfwd_p.h \
$$PWD/qmljsastvisitor_p.h \
$$PWD/qmljsengine_p.h \
$$PWD/qmljsgrammar_p.h \
$$PWD/qmljslexer_p.h \
$$PWD/qmljsmemorypool_p.h \
$$PWD/qmljsnodepool_p.h \
$$PWD/qmljsparser_p.h \
$$PWD/qmljsprettypretty_p.h
SOURCES += $$PWD/qmljsast.cpp \
$$PWD/qmljsastvisitor.cpp \
$$PWD/qmljsengine_p.cpp \
$$PWD/qmljsgrammar.cpp \
$$PWD/qmljslexer.cpp \
$$PWD/qmljsprettypretty.cpp \
$$PWD/qmljsparser.cpp
This diff is collapsed.
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the QtScript module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the either Technology Preview License Agreement or the
** Beta Release License Agreement.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qmljsast_p.h"
#include "qmljsastvisitor_p.h"
QT_BEGIN_NAMESPACE
namespace QmlJS { namespace AST {
int NumericLiteral::suffixLength[] = {
0, // noSuffix
2, // emSuffix
2, // exSuffix
2, // pxSuffix
2, // cmSuffix
2, // mmSuffix
2, // inSuffix
2, // ptSuffix
2, // pcSuffix
3, // degSuffix
3, // radSuffix
4, // gradSuffix
2, // msSuffix
1, // sSuffix
2, // hzSuffix
3 // khzSuffix
};
const char *const NumericLiteral::suffixSpell[] = {
"",
"em",
"ex",
"px",
"cm",
"mm",
"in",
"pt",
"pc",
"deg",
"rad",
"grad",
"ms",
"s",
"hz",
"khz"
};
ExpressionNode *Node::expressionCast()
{
return 0;
}
BinaryExpression *Node::binaryExpressionCast()
{
return 0;
}
Statement *Node::statementCast()
{
return 0;
}
ExpressionNode *ExpressionNode::expressionCast()
{
return this;
}
BinaryExpression *BinaryExpression::binaryExpressionCast()
{
return this;
}
Statement *Statement::statementCast()
{
return this;
}
void NestedExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(expression, visitor);
}
visitor->endVisit(this);
}
void ThisExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
visitor->endVisit(this);
}
void IdentifierExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
visitor->endVisit(this);
}
void NullExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
visitor->endVisit(this);
}
void TrueLiteral::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
visitor->endVisit(this);
}
void FalseLiteral::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
visitor->endVisit(this);
}
void StringLiteral::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
visitor->endVisit(this);
}
void NumericLiteral::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
visitor->endVisit(this);
}
void RegExpLiteral::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
visitor->endVisit(this);
}
void ArrayLiteral::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(elements, visitor);
acceptChild(elision, visitor);
}
visitor->endVisit(this);
}
void ObjectLiteral::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(properties, visitor);
}
visitor->endVisit(this);
}
void ElementList::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
ElementList *it = this;
do {
acceptChild(it->elision, visitor);
acceptChild(it->expression, visitor);
it = it->next;
} while (it);
}
visitor->endVisit(this);
}
void Elision::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
// ###
}
visitor->endVisit(this);
}
void PropertyNameAndValueList::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
PropertyNameAndValueList *it = this;
do {
acceptChild(it->name, visitor);
acceptChild(it->value, visitor);
it = it->next;
} while (it);
}
visitor->endVisit(this);
}
void IdentifierPropertyName::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
visitor->endVisit(this);
}
void StringLiteralPropertyName::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
visitor->endVisit(this);
}
void NumericLiteralPropertyName::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
visitor->endVisit(this);
}
void ArrayMemberExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(base, visitor);
acceptChild(expression, visitor);
}
visitor->endVisit(this);
}
void FieldMemberExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(base, visitor);
}
visitor->endVisit(this);
}
void NewMemberExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(base, visitor);
acceptChild(arguments, visitor);
}
visitor->endVisit(this);
}
void NewExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(expression, visitor);
}
visitor->endVisit(this);
}
void CallExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(base, visitor);
acceptChild(arguments, visitor);
}
visitor->endVisit(this);
}
void ArgumentList::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
ArgumentList *it = this;
do {
acceptChild(it->expression, visitor);
it = it->next;
} while (it);
}
visitor->endVisit(this);
}
void PostIncrementExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(base, visitor);
}
visitor->endVisit(this);
}
void PostDecrementExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(base, visitor);
}
visitor->endVisit(this);
}
void DeleteExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(expression, visitor);
}
visitor->endVisit(this);
}
void VoidExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(expression, visitor);
}
visitor->endVisit(this);
}
void TypeOfExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(expression, visitor);
}
visitor->endVisit(this);
}
void PreIncrementExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(expression, visitor);
}
visitor->endVisit(this);
}
void PreDecrementExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(expression, visitor);
}
visitor->endVisit(this);
}
void UnaryPlusExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(expression, visitor);
}
visitor->endVisit(this);
}
void UnaryMinusExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(expression, visitor);
}
visitor->endVisit(this);
}
void TildeExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(expression, visitor);
}
visitor->endVisit(this);
}
void NotExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(expression, visitor);
}
visitor->endVisit(this);
}
void BinaryExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(left, visitor);
acceptChild(right, visitor);
}
visitor->endVisit(this);
}