Moved files common to the QML editor and Bauhaus into a separate library.

This commit is contained in:
Erik Verbruggen
2009-12-02 17:59:27 +01:00
parent 57ba6b09fc
commit a8dbba5f6f
59 changed files with 568 additions and 1147 deletions

View File

@@ -7,4 +7,5 @@ SUBDIRS = \
extensionsystem \
utils \
utils/process_stub.pro \
cplusplus
cplusplus \
qml

25
src/libs/qml/qml-lib.pri Normal file
View File

@@ -0,0 +1,25 @@
contains(CONFIG, dll) {
DEFINES += QML_BUILD_LIB
} else {
DEFINES += QML_BUILD_STATIC_LIB
}
INCLUDEPATH += $$PWD
include($$PWD/../../shared/qml/qml.pri)
include($$PWD/../../shared/qscripthighlighter/qscripthighlighter.pri)
##contains(QT, gui) {
##HEADERS += \
## $$PWD/Nothing.h
##
##SOURCES += \
## $$PWD/Nothing.cpp
##}
#HEADERS += \
# $$PWD/qmlsymbol.h
#SOURCES += \
# $$PWD/qmlsymbol.cpp

3
src/libs/qml/qml.pri Normal file
View File

@@ -0,0 +1,3 @@
INCLUDEPATH += $$PWD/../../shared
DEPENDPATH += $$PWD/../../shared
LIBS *= -l$$qtLibraryTarget(Qml)

9
src/libs/qml/qml.pro Normal file
View File

@@ -0,0 +1,9 @@
TEMPLATE = lib
CONFIG += dll
TARGET = Qml
DEFINES += QML_BUILD_LIB QT_CREATOR
unix:QMAKE_CXXFLAGS_DEBUG += -O3
include(../../qtcreatorlibrary.pri)
include(qml-lib.pri)

View File

@@ -1,14 +0,0 @@
#ifndef QMLJSGLOBAL_P_H
#define QMLJSGLOBAL_P_H
#include <QtCore/qglobal.h>
#ifdef QT_CREATOR
#define QT_QML_BEGIN_NAMESPACE
#define QT_QML_END_NAMESPACE
#else // !QT_CREATOR
#define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#define QT_QML_END_NAMESPACE QT_END_NAMESPACE
#endif // QT_CREATOR
#endif // QMLJSGLOBAL_P_H

View File

@@ -1,12 +1,42 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "qmlcodecompletion.h"
#include "qmleditor.h"
#include "qmlmodelmanagerinterface.h"
#include "qmlexpressionundercursor.h"
#include "qmllookupcontext.h"
#include "qmlresolveexpression.h"
#include "qmlsymbol.h"
#include <qml/qmlsymbol.h>
#include <texteditor/basetexteditor.h>
#include <QtDebug>
using namespace QmlEditor;

View File

@@ -1,92 +0,0 @@
#include "qmlcodeformatter.h"
#include "qmljsast_p.h"
using namespace QmlEditor::Internal;
using namespace QmlJS;
using namespace QmlJS::AST;
QmlCodeFormatter::QmlCodeFormatter()
{
}
QmlCodeFormatter::~QmlCodeFormatter()
{
}
bool QmlCodeFormatter::visit(QmlJS::AST::UiProgram *ast)
{
Node::accept(ast->imports, this);
if (ast->imports && ast->members)
newline();
Node::accept(ast->members, this);
return false;
}
QString QmlCodeFormatter::operator()(QmlJS::AST::UiProgram *ast, const QString &originalSource, const QList<QmlJS::AST::SourceLocation> & /* comments */, int start, int end)
{
m_result.clear();
m_result.reserve(originalSource.length() * 2);
m_originalSource = originalSource;
m_start = start;
m_end = end;
Node::acceptChild(ast, this);
return m_result;
}
bool QmlCodeFormatter::visit(UiImport *ast)
{
append("import ");
append(ast->fileNameToken);
if (ast->versionToken.isValid()) {
append(' ');
append(ast->versionToken);
}
if (ast->asToken.isValid()) {
append(" as ");
append(ast->importIdToken);
}
if (ast->semicolonToken.isValid())
append(';');
newline();
return false;
}
bool QmlCodeFormatter::visit(UiObjectDefinition *ast)
{
indent();
Node::accept(ast->qualifiedTypeNameId, this);
append(' ');
Node::accept(ast->initializer, this);
newline();
return false;
}
bool QmlCodeFormatter::visit(QmlJS::AST::UiQualifiedId *ast)
{
for (UiQualifiedId *it = ast; it; it = it->next) {
append(it->name->asString());
if (it->next)
append('.');
}
return false;
}
bool QmlCodeFormatter::visit(QmlJS::AST::UiObjectInitializer *ast)
{
append(ast->lbraceToken.offset, ast->rbraceToken.end() - ast->lbraceToken.offset);
return false;
}

View File

@@ -1,82 +0,0 @@
#ifndef QMLCODEFORMATTER_H
#define QMLCODEFORMATTER_H
#include <QString>
#include "qmljsastfwd_p.h"
#include "qmljsastvisitor_p.h"
#include "qmljsengine_p.h"
namespace QmlEditor {
namespace Internal {
class QmlCodeFormatter: protected QmlJS::AST::Visitor
{
public:
QmlCodeFormatter();
~QmlCodeFormatter();
QString operator()(QmlJS::AST::UiProgram *ast, const QString &originalSource, const QList<QmlJS::AST::SourceLocation> &comments, int start = -1, int end = -1);
protected:
virtual bool visit(QmlJS::AST::UiProgram *ast);
// virtual bool visit(UiImportList *ast);
virtual bool visit(QmlJS::AST::UiImport *ast);
// virtual bool visit(UiPublicMember *ast);
// virtual bool visit(UiSourceElement *ast);
virtual bool visit(QmlJS::AST::UiObjectDefinition *ast);
virtual bool visit(QmlJS::AST::UiObjectInitializer *ast);
// virtual bool visit(UiObjectBinding *ast);
// virtual bool visit(UiScriptBinding *ast);
// virtual bool visit(UiArrayBinding *ast);
// virtual bool visit(UiObjectMemberList *ast);
// virtual bool visit(UiArrayMemberList *ast);
virtual bool visit(QmlJS::AST::UiQualifiedId *ast);
// virtual bool visit(UiSignature *ast);
// virtual bool visit(UiFormalList *ast);
// virtual bool visit(UiFormal *ast);
//
// virtual void endVisit(UiProgram *ast);
// virtual void endVisit(UiImport *ast);
// virtual void endVisit(UiPublicMember *ast);
// virtual void endVisit(UiSourceElement *ast);
// virtual void endVisit(UiObjectDefinition *ast);
// virtual void endVisit(UiObjectInitializer *ast);
// virtual void endVisit(UiObjectBinding *ast);
// virtual void endVisit(UiScriptBinding *ast);
// virtual void endVisit(UiArrayBinding *ast);
// virtual void endVisit(UiObjectMemberList *ast);
// virtual void endVisit(UiArrayMemberList *ast);
// virtual void endVisit(UiQualifiedId *ast);
// virtual void endVisit(UiSignature *ast);
// virtual void endVisit(UiFormalList *ast);
// virtual void endVisit(UiFormal *ast);
private:
void append(char c) { m_result += c; }
void append(const char *s) { m_result += s; }
void append(const QString &s) { m_result += s; }
void append(const QmlJS::AST::SourceLocation &loc) { m_result += textAt(loc); }
void append(int pos, int len) { append(textAt(pos, len)); }
QString textAt(const QmlJS::AST::SourceLocation &loc) const
{ return textAt(loc.offset, loc.length); }
QString textAt(int pos, int len) const
{ return m_originalSource.mid(pos, len); }
void indent() { if (m_indentDepth) append(QString(' ', m_indentDepth)); }
void newline() { append('\n'); }
private:
QString m_result;
QString m_originalSource;
int m_start;
int m_end;
unsigned m_indentDepth;
};
} // namespace Internal
} // namespace QmlEditor
#endif // QMLCODEFORMATTER_H

View File

@@ -31,18 +31,17 @@
#include "qmleditorconstants.h"
#include "qmlhighlighter.h"
#include "qmleditorplugin.h"
#include "qmldocument.h"
#include "qmlmodelmanager.h"
#include "qmljsastvisitor_p.h"
#include "qmljsast_p.h"
#include "qmljsengine_p.h"
#include "qmlexpressionundercursor.h"
#include "qmllookupcontext.h"
#include "qmlresolveexpression.h"
#include "rewriter_p.h"
#include "idcollector.h"
#include <qml/parser/qmljsastvisitor_p.h>
#include <qml/parser/qmljsast_p.h>
#include <qml/parser/qmljsengine_p.h>
#include <qml/qmldocument.h>
#include <qml/qmlidcollector.h>
#include <coreplugin/icore.h>
#include <coreplugin/actionmanager/actionmanager.h>
@@ -54,6 +53,7 @@
#include <texteditor/texteditorconstants.h>
#include <texteditor/texteditorsettings.h>
#include <utils/changeset.h>
#include <utils/uncommentselection.h>
#include <QtCore/QTimer>
@@ -572,16 +572,14 @@ void ScriptEditor::renameIdUnderCursor()
QLineEdit::Normal,
id, &ok);
if (ok) {
TextWriter writer;
QString code = toPlainText();
Utils::ChangeSet changeSet;
foreach (const AST::SourceLocation &loc, m_ids.value(id)) {
writer.replace(loc.offset, loc.length, newId);
changeSet.replace(loc.offset, loc.length, newId);
}
QTextCursor tc = textCursor();
writer.write(&tc);
changeSet.apply(&tc);
}
}

View File

@@ -30,13 +30,10 @@
#ifndef QMLEDITORW_H
#define QMLEDITORW_H
#include <qml/qmldocument.h>
#include <qscripthighlighter/qscriptincrementalscanner.h>
#include <texteditor/basetexteditor.h>
#include "qmljsastfwd_p.h"
#include "qmljsengine_p.h"
#include "qmldocument.h"
#include "qscriptincrementalscanner.h"
QT_BEGIN_NAMESPACE
class QComboBox;
class QTimer;

View File

@@ -2,48 +2,43 @@ TEMPLATE = lib
TARGET = QmlEditor
include(../../qtcreatorplugin.pri)
include(qmleditor_dependencies.pri)
include(parser/parser.pri)
include(rewriter/rewriter.pri)
CONFIG += help
DEFINES += QMLEDITOR_LIBRARY \
DEFINES += \
QMLEDITOR_LIBRARY \
QT_CREATOR
INCLUDEPATH += parser \
rewriter
HEADERS += qmleditor.h \
HEADERS += \
qmlcodecompletion.h \
qmleditor.h \
qmleditor_global.h \
qmleditoractionhandler.h \
qmleditorconstants.h \
qmleditorfactory.h \
qmleditorplugin.h \
qmlhighlighter.h \
qmleditoractionhandler.h \
qmlcodecompletion.h \
qmleditorconstants.h \
qmlhoverhandler.h \
qmldocument.h \
qmlmodelmanagerinterface.h \
qmleditor_global.h \
qmlmodelmanager.h \
qmlcodeformatter.h \
idcollector.h \
qmlexpressionundercursor.h \
qmlfilewizard.h \
qmlhighlighter.h \
qmlhoverhandler.h \
qmllookupcontext.h \
qmlresolveexpression.h \
qmlsymbol.h \
qmlfilewizard.h
SOURCES += qmleditor.cpp \
qmlmodelmanager.h \
qmlmodelmanagerinterface.h \
qmlresolveexpression.h
SOURCES += \
qmlcodecompletion.cpp \
qmleditor.cpp \
qmleditoractionhandler.cpp \
qmleditorfactory.cpp \
qmleditorplugin.cpp \
qmlhighlighter.cpp \
qmleditoractionhandler.cpp \
qmlcodecompletion.cpp \
qmlhoverhandler.cpp \
qmldocument.cpp \
qmlmodelmanagerinterface.cpp \
qmlmodelmanager.cpp \
qmlcodeformatter.cpp \
idcollector.cpp \
qmlexpressionundercursor.cpp \
qmlfilewizard.cpp \
qmlhighlighter.cpp \
qmlhoverhandler.cpp \
qmllookupcontext.cpp \
qmlresolveexpression.cpp \
qmlsymbol.cpp \
qmlfilewizard.cpp
qmlmodelmanager.cpp \
qmlmodelmanagerinterface.cpp \
qmlresolveexpression.cpp
RESOURCES += qmleditor.qrc
OTHER_FILES += QmlEditor.pluginspec

View File

@@ -1,6 +1,6 @@
include(../../plugins/coreplugin/coreplugin.pri)
include(../../plugins/texteditor/texteditor.pri)
include(../../plugins/help/help.pri)
include(../../shared/qscripthighlighter/qscripthighlighter.pri)
include(../../shared/indenter/indenter.pri)
include(../../libs/qml/qml.pri)
include(../../libs/utils/utils.pri)

View File

@@ -29,7 +29,7 @@
#include "qmleditorplugin.h"
#include "qscripthighlighter.h"
#include "qmlhighlighter.h"
#include "qmleditor.h"
#include "qmleditorconstants.h"
#include "qmleditorfactory.h"

View File

@@ -1,13 +1,14 @@
#include <QDebug>
#include "qmljsast_p.h"
#include "qmljsastvisitor_p.h"
#include "qmljsengine_p.h"
#include "qmljslexer_p.h"
#include "qmljsnodepool_p.h"
#include "qmljsparser_p.h"
#include "qmlexpressionundercursor.h"
#include <qml/parser/qmljsast_p.h>
#include <qml/parser/qmljsastvisitor_p.h>
#include <qml/parser/qmljsengine_p.h>
#include <qml/parser/qmljslexer_p.h>
#include <qml/parser/qmljsnodepool_p.h>
#include <qml/parser/qmljsparser_p.h>
#include <QDebug>
using namespace QmlJS;
using namespace QmlJS::AST;

View File

@@ -1,14 +1,15 @@
#ifndef QMLEXPRESSIONUNDERCURSOR_H
#define QMLEXPRESSIONUNDERCURSOR_H
#include <qml/parser/qmljsastfwd_p.h>
#include <qml/qmldocument.h>
#include <qml/qmlsymbol.h>
#include <QStack>
#include <QTextBlock>
#include <QTextCursor>
#include "qmldocument.h"
#include "qmljsastfwd_p.h"
#include "qmlsymbol.h"
namespace QmlJS {
class Engine;
class NodePool;

View File

@@ -30,7 +30,7 @@
#ifndef QMLSYNTAXHIGHLIGHTER_H
#define QMLSYNTAXHIGHLIGHTER_H
#include "qscripthighlighter.h"
#include <qscripthighlighter/qscripthighlighter.h>
#include <texteditor/basetexteditor.h>
namespace QmlEditor {

View File

@@ -32,15 +32,15 @@
#include "qmlhoverhandler.h"
#include "qmllookupcontext.h"
#include "qmlresolveexpression.h"
#include "qmlsymbol.h"
#include <coreplugin/icore.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <debugger/debuggerconstants.h>
#include <extensionsystem/pluginmanager.h>
#include <qml/qmlsymbol.h>
#include <texteditor/itexteditor.h>
#include <texteditor/basetexteditor.h>
#include <debugger/debuggerconstants.h>
#include <QtCore/QDebug>
#include <QtCore/QDir>

View File

@@ -1,11 +1,12 @@
#include <QDebug>
#include "qmljsast_p.h"
#include "qmljsengine_p.h"
#include "qmlexpressionundercursor.h"
#include "qmllookupcontext.h"
#include "qmlresolveexpression.h"
#include <qml/parser/qmljsast_p.h>
#include <qml/parser/qmljsengine_p.h>
#include <QDebug>
using namespace QmlEditor;
using namespace QmlEditor::Internal;
using namespace QmlJS;

View File

@@ -1,11 +1,11 @@
#ifndef QMLLOOKUPCONTEXT_H
#define QMLLOOKUPCONTEXT_H
#include <QStack>
#include <qml/parser/qmljsastvisitor_p.h>
#include <qml/qmldocument.h>
#include <qml/qmlsymbol.h>
#include "qmldocument.h"
#include "qmljsastvisitor_p.h"
#include "qmlsymbol.h"
#include <QStack>
namespace QmlEditor {
namespace Internal {

View File

@@ -30,13 +30,14 @@
#ifndef QMLMODELMANAGER_H
#define QMLMODELMANAGER_H
#include "qmlmodelmanagerinterface.h"
#include <qml/qmldocument.h>
#include <QFuture>
#include <QFutureSynchronizer>
#include <QMutex>
#include "qmldocument.h"
#include "qmlmodelmanagerinterface.h"
namespace Core {
class ICore;
}

View File

@@ -30,12 +30,13 @@
#ifndef QMLMODELMANAGERINTERFACE_H
#define QMLMODELMANAGERINTERFACE_H
#include "qmleditor_global.h"
#include <QObject>
#include <QStringList>
#include <QSharedPointer>
#include <qmleditor/qmleditor_global.h>
#include <qmleditor/qmldocument.h>
#include <qml/qmldocument.h>
namespace QmlEditor {

View File

@@ -1,7 +1,8 @@
#include "qmljsast_p.h"
#include "qmljsengine_p.h"
#include "qmlresolveexpression.h"
#include <qml/parser/qmljsast_p.h>
#include <qml/parser/qmljsengine_p.h>
using namespace QmlEditor;
using namespace QmlEditor::Internal;
using namespace QmlJS;

View File

@@ -1,9 +1,10 @@
#ifndef QMLRESOLVEEXPRESSION_H
#define QMLRESOLVEEXPRESSION_H
#include "qmljsastvisitor_p.h"
#include "qmllookupcontext.h"
#include "qmlsymbol.h"
#include <qml/parser/qmljsastvisitor_p.h>
#include <qml/qmlsymbol.h>
namespace QmlEditor {
namespace Internal {

View File

@@ -1,96 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtDeclarative 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 http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "rewriter_p.h"
#include "qmljsast_p.h"
QT_QML_BEGIN_NAMESPACE
using namespace QmlJS;
void Rewriter::replace(const AST::SourceLocation &loc, const QString &text)
{ replace(loc.offset, loc.length, text); }
void Rewriter::remove(const AST::SourceLocation &loc)
{ return replace(loc.offset, loc.length, QString()); }
void Rewriter::remove(const AST::SourceLocation &firstLoc, const AST::SourceLocation &lastLoc)
{ return replace(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset, QString()); }
void Rewriter::insertTextBefore(const AST::SourceLocation &loc, const QString &text)
{ replace(loc.offset, 0, text); }
void Rewriter::insertTextAfter(const AST::SourceLocation &loc, const QString &text)
{ replace(loc.offset + loc.length, 0, text); }
void Rewriter::replace(int offset, int length, const QString &text)
{ textWriter.replace(offset, length, text); }
void Rewriter::insertText(int offset, const QString &text)
{ replace(offset, 0, text); }
void Rewriter::removeText(int offset, int length)
{ replace(offset, length, QString()); }
QString Rewriter::textAt(const AST::SourceLocation &loc) const
{ return _code.mid(loc.offset, loc.length); }
QString Rewriter::textAt(const AST::SourceLocation &firstLoc, const AST::SourceLocation &lastLoc) const
{ return _code.mid(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset); }
void Rewriter::accept(QmlJS::AST::Node *node)
{ QmlJS::AST::Node::acceptChild(node, this); }
void Rewriter::moveTextBefore(const AST::SourceLocation &firstLoc,
const AST::SourceLocation &lastLoc,
const AST::SourceLocation &loc)
{
textWriter.move(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset, loc.offset);
}
void Rewriter::moveTextAfter(const AST::SourceLocation &firstLoc,
const AST::SourceLocation &lastLoc,
const AST::SourceLocation &loc)
{
textWriter.move(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset, loc.offset + loc.length);
}
QT_QML_END_NAMESPACE

View File

@@ -1,9 +0,0 @@
INCLUDEPATH += $$PWD
HEADERS += $$PWD/textwriter_p.h
SOURCES += $$PWD/textwriter.cpp
!no_ast_rewriter {
HEADERS += $$PWD/rewriter_p.h
SOURCES += $$PWD/rewriter.cpp
}

View File

@@ -1,151 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtDeclarative 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 http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef REWRITER_H
#define REWRITER_H
#include <QtCore/QList>
#include <QtCore/QString>
#include "textwriter_p.h"
#include "qmljsastvisitor_p.h"
QT_BEGIN_HEADER
QT_QML_BEGIN_NAMESPACE
namespace QmlJS {
////////////////////////////////////////////////////////////////////////////////
// Replacement
////////////////////////////////////////////////////////////////////////////////
class Replacement
{
int _offset;
int _length;
QString _text;
public:
Replacement(int offset = 0, int length = 0, const QString &text = QString())
: _offset(offset), _length(length), _text(text)
{ }
bool isNull() const { return _offset == _length; }
operator bool() const { return ! isNull(); }
int offset() const { return _offset; }
int length() const { return _length; }
QString text() const { return _text; }
};
////////////////////////////////////////////////////////////////////////////////
// Rewriter
////////////////////////////////////////////////////////////////////////////////
class Rewriter: public AST::Visitor
{
protected:
TextWriter textWriter;
public:
//
// Token based API
//
/// Returns the text of the token at the given \a location.
QString textAt(const AST::SourceLocation &location) const;
QString textAt(const AST::SourceLocation &firstLoc,
const AST::SourceLocation &lastLoc) const;
/// Replace the token at \a loc with the given \a text.
void replace(const AST::SourceLocation &loc, const QString &text);
/// Remove the token at the given \a location.
void remove(const AST::SourceLocation &location);
/// Remove all tokens in the range [\a firstLoc, \a lastLoc].
void remove(const AST::SourceLocation &firstLoc, const AST::SourceLocation &lastLoc);
/// Insert \a text before the token at the given \a location.
void insertTextBefore(const AST::SourceLocation &location, const QString &text);
/// Insert \a text after the token at the given \a location.
void insertTextAfter(const AST::SourceLocation &loc, const QString &text);
void moveTextBefore(const AST::SourceLocation &firstLoc,
const AST::SourceLocation &lastLoc,
const AST::SourceLocation &loc);
void moveTextAfter(const AST::SourceLocation &firstLoc,
const AST::SourceLocation &lastLoc,
const AST::SourceLocation &loc);
//
// low-level offset based API
//
void replace(int offset, int length, const QString &text);
void insertText(int offset, const QString &text);
void removeText(int offset, int length);
/// Visit the given \a node.
void accept(AST::Node *node);
/// Returns the original unchanged source code.
QString code() const { return _code; }
/// Returns the list of replacements.
QList<Replacement> replacementList() const { return _replacementList; }
protected:
/// \internal
void setCode(const QString &code) { _code = code; }
private:
QString _code;
QList<Replacement> _replacementList;
};
} // end of namespace QmlJS
QT_QML_END_NAMESPACE
QT_END_HEADER
#endif // REWRITER_H

View File

@@ -1,217 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtDeclarative 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 http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "textwriter_p.h"
QT_QML_BEGIN_NAMESPACE
using namespace QmlJS;
TextWriter::TextWriter()
:string(0), cursor(0)
{
}
static bool overlaps(int posA, int lengthA, int posB, int lengthB) {
return (posA < posB + lengthB && posA + lengthA > posB + lengthB)
|| (posA < posB && posA + lengthA > posB);
}
bool TextWriter::hasOverlap(int pos, int length)
{
{
QListIterator<Replace> i(replaceList);
while (i.hasNext()) {
const Replace &cmd = i.next();
if (overlaps(pos, length, cmd.pos, cmd.length))
return true;
}
}
{
QListIterator<Move> i(moveList);
while (i.hasNext()) {
const Move &cmd = i.next();
if (overlaps(pos, length, cmd.pos, cmd.length))
return true;
}
return false;
}
}
bool TextWriter::hasMoveInto(int pos, int length)
{
QListIterator<Move> i(moveList);
while (i.hasNext()) {
const Move &cmd = i.next();
if (cmd.to >= pos && cmd.to < pos + length)
return true;
}
return false;
}
void TextWriter::replace(int pos, int length, const QString &replacement)
{
Q_ASSERT(!hasOverlap(pos, length));
Q_ASSERT(!hasMoveInto(pos, length));
Replace cmd;
cmd.pos = pos;
cmd.length = length;
cmd.replacement = replacement;
replaceList += cmd;
}
void TextWriter::move(int pos, int length, int to)
{
Q_ASSERT(!hasOverlap(pos, length));
Move cmd;
cmd.pos = pos;
cmd.length = length;
cmd.to = to;
moveList += cmd;
}
void TextWriter::doReplace(const Replace &replace)
{
int diff = replace.replacement.size() - replace.length;
{
QMutableListIterator<Replace> i(replaceList);
while (i.hasNext()) {
Replace &c = i.next();
if (replace.pos < c.pos)
c.pos += diff;
else if (replace.pos + replace.length < c.pos + c.length)
c.length += diff;
}
}
{
QMutableListIterator<Move> i(moveList);
while (i.hasNext()) {
Move &c = i.next();
if (replace.pos < c.pos)
c.pos += diff;
else if (replace.pos + replace.length < c.pos + c.length)
c.length += diff;
if (replace.pos < c.to)
c.to += diff;
}
}
if (string) {
string->replace(replace.pos, replace.length, replace.replacement);
} else if (cursor) {
cursor->setPosition(replace.pos);
cursor->setPosition(replace.pos + replace.length, QTextCursor::KeepAnchor);
cursor->insertText(replace.replacement);
}
}
void TextWriter::doMove(const Move &move)
{
QString text;
if (string) {
text = string->mid(move.pos, move.length);
} else if (cursor) {
cursor->setPosition(move.pos);
cursor->setPosition(move.pos + move.length, QTextCursor::KeepAnchor);
text = cursor->selectedText();
}
Replace cut;
cut.pos = move.pos;
cut.length = move.length;
Replace paste;
paste.pos = move.to;
paste.length = 0;
paste.replacement = text;
replaceList.append(cut);
replaceList.append(paste);
Replace cmd;
while (!replaceList.isEmpty()) {
cmd = replaceList.first();
replaceList.removeFirst();
doReplace(cmd);
}
}
void TextWriter::write(QString *s)
{
string = s;
write_helper();
string = 0;
}
void TextWriter::write(QTextCursor *textCursor)
{
cursor = textCursor;
write_helper();
cursor = 0;
}
void TextWriter::write_helper()
{
if (cursor)
cursor->beginEditBlock();
{
Replace cmd;
while (!replaceList.isEmpty()) {
cmd = replaceList.first();
replaceList.removeFirst();
doReplace(cmd);
}
}
{
Move cmd;
while (!moveList.isEmpty()) {
cmd = moveList.first();
moveList.removeFirst();
doMove(cmd);
}
}
if (cursor)
cursor->endEditBlock();
}
QT_QML_END_NAMESPACE

View File

@@ -1,101 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtDeclarative 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 http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef TEXTWRITER_H
#define TEXTWRITER_H
#include <QtCore/QString>
#include <QtCore/QList>
#include <QtGui/QTextCursor>
#include "qmljsglobal_p.h"
QT_BEGIN_HEADER
QT_QML_BEGIN_NAMESPACE
namespace QmlJS {
class TextWriter
{
QString *string;
QTextCursor *cursor;
struct Replace {
int pos;
int length;
QString replacement;
};
QList<Replace> replaceList;
struct Move {
int pos;
int length;
int to;
};
QList<Move> moveList;
bool hasOverlap(int pos, int length);
bool hasMoveInto(int pos, int length);
void doReplace(const Replace &replace);
void doMove(const Move &move);
void write_helper();
public:
TextWriter();
void replace(int pos, int length, const QString &replacement);
void move(int pos, int length, int to);
void write(QString *s);
void write(QTextCursor *textCursor);
};
} // end of namespace QmlJS
QT_QML_END_NAMESPACE
QT_END_HEADER
#endif // TEXTWRITER_H

View File

@@ -2,9 +2,9 @@
#define QMLTASKMANAGER_H
#include <projectexplorer/taskwindow.h>
#include <qmleditor/qmldocument.h>
#include <QtCore/QObject>
#include <qml/qmldocument.h>
#include <QtCore/QObject>
namespace QmlProjectManager {
namespace Internal {

View File

@@ -105,7 +105,7 @@
** 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.
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -159,7 +159,7 @@
** 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.
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage

View File

@@ -1,16 +1,17 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtScript module of the Qt Toolkit.
** This file is part of the QtDeclarative 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.
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
** 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$
**
****************************************************************************/

View File

@@ -1,7 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
@@ -9,8 +10,8 @@
** 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.
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
** 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$
**
****************************************************************************/
@@ -118,7 +118,7 @@ _T1 cast(_T2 *ast)
return 0;
}
class Node
class QML_PARSER_EXPORT Node
{
public:
enum Kind {
@@ -2653,7 +2653,7 @@ public:
{ kind = K; }
virtual SourceLocation firstSourceLocation() const
{ return lbracketToken; }
{ return qualifiedId->identifierToken; }
virtual SourceLocation lastSourceLocation() const
{ return rbracketToken; }

View File

@@ -1,16 +1,17 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtScript module of the Qt Toolkit.
** This file is part of the QtDeclarative 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.
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
** 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$
**
****************************************************************************/

View File

@@ -1,16 +1,17 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtScript module of the Qt Toolkit.
** This file is part of the QtDeclarative 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.
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
** 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$
**
****************************************************************************/

View File

@@ -1,16 +1,17 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtScript module of the Qt Toolkit.
** This file is part of the QtDeclarative 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.
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
** 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$
**
****************************************************************************/
@@ -60,7 +60,7 @@ QT_QML_BEGIN_NAMESPACE
namespace QmlJS { namespace AST {
class Visitor
class QML_PARSER_EXPORT Visitor
{
public:
Visitor();

View File

@@ -1,7 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
@@ -9,8 +10,8 @@
** 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.
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
** 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$
**
****************************************************************************/

View File

@@ -1,7 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
@@ -9,8 +10,8 @@
** 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.
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
** 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$
**
****************************************************************************/
@@ -62,7 +62,7 @@
QT_QML_BEGIN_NAMESPACE
namespace QmlJS {
class NameId
class QML_PARSER_EXPORT NameId
{
QString _text;
@@ -101,7 +101,7 @@ class NodePool;
namespace Ecma {
class RegExp
class QML_PARSER_EXPORT RegExp
{
public:
enum RegExpFlag {
@@ -117,7 +117,7 @@ public:
} // end of namespace Ecma
class DiagnosticMessage
class QML_PARSER_EXPORT DiagnosticMessage
{
public:
enum Kind { Warning, Error };
@@ -139,7 +139,7 @@ public:
QString message;
};
class Engine
class QML_PARSER_EXPORT Engine
{
Lexer *_lexer;
NodePool *_nodePool;

View File

@@ -0,0 +1,64 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtDeclarative 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 Technology Preview License Agreement accompanying
** this package.
**
** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QMLJSGLOBAL_P_H
#define QMLJSGLOBAL_P_H
#include <QtCore/qglobal.h>
#ifdef QT_CREATOR
# define QT_QML_BEGIN_NAMESPACE
# define QT_QML_END_NAMESPACE
# ifdef QML_BUILD_LIB
# define QML_PARSER_EXPORT Q_DECL_EXPORT
# elif QML_BUILD_STATIC_LIB
# define QML_PARSER_EXPORT
# else
# define QML_PARSER_EXPORT Q_DECL_IMPORT
# endif // QML_BUILD_LIB
#else // !QT_CREATOR
# define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
# define QT_QML_END_NAMESPACE QT_END_NAMESPACE
# define QML_PARSER_EXPORT
#endif // QT_CREATOR
#endif // QMLJSGLOBAL_P_H

View File

@@ -2,7 +2,8 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
@@ -10,8 +11,8 @@
** 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.
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -21,21 +22,20 @@
** 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.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
** 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$
**
****************************************************************************/

View File

@@ -2,7 +2,8 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
@@ -10,8 +11,8 @@
** 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.
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -21,21 +22,20 @@
** 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.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
** 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$
**
****************************************************************************/

View File

@@ -1,7 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
@@ -9,8 +10,8 @@
** 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.
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
** 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$
**
****************************************************************************/

View File

@@ -1,16 +1,17 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtScript module of the Qt Toolkit.
** This file is part of the QtDeclarative 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.
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
** 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$
**
****************************************************************************/
@@ -64,7 +64,7 @@ namespace QmlJS {
class Engine;
class NameId;
class Lexer
class QML_PARSER_EXPORT Lexer
{
public:
Lexer(Engine *eng, bool tokenizeComments = false);

View File

@@ -1,7 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
@@ -9,8 +10,8 @@
** 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.
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
** 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$
**
****************************************************************************/
@@ -63,7 +63,7 @@ QT_QML_BEGIN_NAMESPACE
namespace QmlJS {
class MemoryPool : public QSharedData
class QML_PARSER_EXPORT MemoryPool : public QSharedData
{
public:
enum { maxBlockCount = -1 };

View File

@@ -1,7 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
@@ -9,8 +10,8 @@
** 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.
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
** 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$
**
****************************************************************************/
@@ -106,7 +106,7 @@ inline NodeType *makeAstNode(MemoryPool *storage, Arg1 arg1, Arg2 arg2, Arg3 arg
return node;
}
class NodePool : public MemoryPool
class QML_PARSER_EXPORT NodePool : public MemoryPool
{
public:
NodePool(const QString &fileName, Engine *engine);

View File

@@ -3,16 +3,17 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtScript module of the Qt Toolkit.
** This file is part of the QtDeclarative 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.
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -22,21 +23,20 @@
** 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.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
** 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$
**
****************************************************************************/
@@ -1749,7 +1749,7 @@ case 337: {
token_buffer[1].loc = yylloc = location(lexer);
if (t_action(errorState, yytoken)) {
const QString msg = qApp->translate("QmlParser", "Unexpected token '%1'").arg(QLatin1String(spell[token_buffer[0].token]));
const QString msg = qApp->translate("QmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token_buffer[0].token]));
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
action = errorState;
@@ -1777,7 +1777,7 @@ case 337: {
for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) {
int a = t_action(errorState, *tk);
if (a > 0 && t_action(a, yytoken)) {
const QString msg = qApp->translate("QmlParser", "Expected token '%1'").arg(QLatin1String(spell[*tk]));
const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk]));
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
yytoken = *tk;
@@ -1800,7 +1800,7 @@ case 337: {
int a = t_action(errorState, tk);
if (a > 0 && t_action(a, yytoken)) {
const QString msg = qApp->translate("QmlParser", "Expected token '%1'").arg(QLatin1String(spell[tk]));
const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk]));
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
yytoken = tk;

View File

@@ -3,16 +3,17 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtScript module of the Qt Toolkit.
** This file is part of the QtDeclarative 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.
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -22,21 +23,20 @@
** 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.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
** 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$
**
****************************************************************************/
@@ -75,7 +75,7 @@ namespace QmlJS {
class Engine;
class NameId;
class Parser: protected QmlJSGrammar
class QML_PARSER_EXPORT Parser: protected QmlJSGrammar
{
public:
union Value {

17
src/shared/qml/qml.pri Normal file
View File

@@ -0,0 +1,17 @@
include(parser/parser.pri)
DEPENDPATH += $$PWD
INCLUDEPATH *= $$PWD/..
HEADERS += \
$$PWD/qml_global.h \
$$PWD/qmlidcollector.h \
$$PWD/qmldocument.h \
$$PWD/qmlsymbol.h
SOURCES += \
$$PWD/qmlidcollector.cpp \
$$PWD/qmldocument.cpp \
$$PWD/qmlsymbol.cpp

View File

@@ -0,0 +1,14 @@
#ifndef QML_GLOBAL_H
#define QML_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(QML_BUILD_LIB)
# define QML_EXPORT Q_DECL_EXPORT
#elif defined(QML_BUILD_STATIC_LIB)
# define QML_EXPORT
#else
# define QML_EXPORT Q_DECL_IMPORT
#endif
#endif // QML_GLOBAL_H

View File

@@ -27,7 +27,7 @@
**
**************************************************************************/
#include "idcollector.h"
#include "qmlidcollector.h"
#include "qmldocument.h"
#include "qmljsast_p.h"
#include "qmljslexer_p.h"
@@ -114,7 +114,7 @@ bool QmlDocument::parse()
if (iter->member)
_symbols.append(new QmlSymbolFromFile(_fileName, iter->member));
Internal::IdCollector collect;
Internal::QmlIdCollector collect;
_ids = collect(this);
}

View File

@@ -35,13 +35,13 @@
#include <QtCore/QSharedPointer>
#include <QtCore/QString>
#include <qmleditor/qmleditor_global.h>
#include <qmleditor/parser/qmljsengine_p.h>
#include <qmleditor/qmlsymbol.h>
#include "parser/qmljsengine_p.h"
#include "qml_global.h"
#include "qmlsymbol.h"
namespace QmlEditor {
class QMLEDITOR_EXPORT QmlDocument
class QML_EXPORT QmlDocument
{
public:
typedef QSharedPointer<QmlDocument> Ptr;
@@ -91,7 +91,7 @@ private:
QmlSymbol::List _symbols;
};
class QMLEDITOR_EXPORT Snapshot: public QMap<QString, QmlDocument::Ptr>
class QML_EXPORT Snapshot: public QMap<QString, QmlDocument::Ptr>
{
public:
Snapshot();

View File

@@ -1,6 +1,6 @@
#include <QDebug>
#include "idcollector.h"
#include "qmlidcollector.h"
#include "qmljsast_p.h"
#include "qmljsengine_p.h"
@@ -9,7 +9,7 @@ using namespace QmlJS::AST;
using namespace QmlEditor;
using namespace QmlEditor::Internal;
QMap<QString, QmlIdSymbol*> IdCollector::operator()(QmlDocument *doc)
QMap<QString, QmlIdSymbol*> QmlIdCollector::operator()(QmlDocument *doc)
{
_doc = doc;
_ids.clear();
@@ -20,7 +20,7 @@ QMap<QString, QmlIdSymbol*> IdCollector::operator()(QmlDocument *doc)
return _ids;
}
bool IdCollector::visit(UiArrayBinding *ast)
bool QmlIdCollector::visit(UiArrayBinding *ast)
{
QmlSymbolFromFile *oldSymbol = switchSymbol(ast);
Node::accept(ast->members, this);
@@ -28,7 +28,7 @@ bool IdCollector::visit(UiArrayBinding *ast)
return false;
}
bool IdCollector::visit(QmlJS::AST::UiObjectBinding *ast)
bool QmlIdCollector::visit(QmlJS::AST::UiObjectBinding *ast)
{
QmlSymbolFromFile *oldSymbol = switchSymbol(ast);
Node::accept(ast->initializer, this);
@@ -36,7 +36,7 @@ bool IdCollector::visit(QmlJS::AST::UiObjectBinding *ast)
return false;
}
bool IdCollector::visit(QmlJS::AST::UiObjectDefinition *ast)
bool QmlIdCollector::visit(QmlJS::AST::UiObjectDefinition *ast)
{
QmlSymbolFromFile *oldSymbol = switchSymbol(ast);
Node::accept(ast->initializer, this);
@@ -44,7 +44,7 @@ bool IdCollector::visit(QmlJS::AST::UiObjectDefinition *ast)
return false;
}
bool IdCollector::visit(QmlJS::AST::UiScriptBinding *ast)
bool QmlIdCollector::visit(QmlJS::AST::UiScriptBinding *ast)
{
if (!(ast->qualifiedId->next) && ast->qualifiedId->name->asString() == "id")
if (ExpressionStatement *e = cast<ExpressionStatement*>(ast->statement))
@@ -55,7 +55,7 @@ bool IdCollector::visit(QmlJS::AST::UiScriptBinding *ast)
return false;
}
QmlSymbolFromFile *IdCollector::switchSymbol(QmlJS::AST::UiObjectMember *node)
QmlSymbolFromFile *QmlIdCollector::switchSymbol(QmlJS::AST::UiObjectMember *node)
{
QmlSymbolFromFile *newSymbol = 0;
@@ -77,7 +77,7 @@ QmlSymbolFromFile *IdCollector::switchSymbol(QmlJS::AST::UiObjectMember *node)
return oldSymbol;
}
void IdCollector::addId(const QString &id, QmlJS::AST::UiScriptBinding *ast)
void QmlIdCollector::addId(const QString &id, QmlJS::AST::UiScriptBinding *ast)
{
if (!_ids.contains(id) && _currentSymbol) {
QmlSymbolFromFile *symbol = _currentSymbol->findMember(ast);

View File

@@ -1,19 +1,19 @@
#ifndef IDCOLLECTOR_H
#define IDCOLLECTOR_H
#ifndef QMLIDCOLLECTOR_H
#define QMLIDCOLLECTOR_H
#include <QMap>
#include <QPair>
#include <QStack>
#include <QString>
#include "qmldocument.h"
#include "qmljsastvisitor_p.h"
#include "qmlsymbol.h"
#include <qml/parser/qmljsastvisitor_p.h>
#include <qml/qmldocument.h>
#include <qml/qmlsymbol.h>
namespace QmlEditor {
namespace Internal {
class IdCollector: protected QmlJS::AST::Visitor
class QML_EXPORT QmlIdCollector: protected QmlJS::AST::Visitor
{
public:
QMap<QString, QmlIdSymbol*> operator()(QmlDocument *doc);
@@ -37,4 +37,4 @@ private:
} // namespace Internal
} // namespace QmlEditor
#endif // IDCOLLECTOR_H
#endif // QMLIDCOLLECTOR_H

View File

@@ -4,11 +4,12 @@
#include <QList>
#include <QString>
#include <qmleditor/parser/qmljsastfwd_p.h>
#include <qml/parser/qmljsastfwd_p.h>
#include <qml/qml_global.h>
namespace QmlEditor {
class QmlSymbol
class QML_EXPORT QmlSymbol
{
public:
typedef QList<QmlSymbol*> List;
@@ -33,7 +34,7 @@ protected:
List _members;
};
class QmlBuildInSymbol: public QmlSymbol
class QML_EXPORT QmlBuildInSymbol: public QmlSymbol
{
public:
QmlBuildInSymbol(const QString &name): _name(name) {}
@@ -51,7 +52,7 @@ private:
QString _name;
};
class QmlSymbolFromFile: public QmlSymbol
class QML_EXPORT QmlSymbolFromFile: public QmlSymbol
{
public:
QmlSymbolFromFile(const QString &fileName, QmlJS::AST::UiObjectMember *node);
@@ -81,7 +82,7 @@ private:
QList<QmlJS::AST::Node*> todo;
};
class QmlIdSymbol: public QmlSymbolFromFile
class QML_EXPORT QmlIdSymbol: public QmlSymbolFromFile
{
public:
QmlIdSymbol(const QString &fileName, QmlJS::AST::UiScriptBinding *idNode, QmlSymbolFromFile *parentNode);
@@ -107,7 +108,7 @@ private:
QmlSymbolFromFile *_parentNode;
};
class QmlPropertyDefinitionSymbol: public QmlSymbolFromFile
class QML_EXPORT QmlPropertyDefinitionSymbol: public QmlSymbolFromFile
{
public:
QmlPropertyDefinitionSymbol(const QString &fileName, QmlJS::AST::UiPublicMember *propertyNode);

View File

@@ -30,7 +30,8 @@
#ifndef QSCRIPTSYNTAXHIGHLIGHTER_H
#define QSCRIPTSYNTAXHIGHLIGHTER_H
#include "qscriptincrementalscanner.h"
#include <qscripthighlighter/qscripthighlighter_global.h>
#include <qscripthighlighter/qscriptincrementalscanner.h>
#include <QtCore/QVector>
#include <QtCore/QSet>
@@ -38,7 +39,7 @@
namespace SharedTools {
class QScriptHighlighter : public QSyntaxHighlighter
class QSCRIPTHIGHLIGHTER_EXPORT QScriptHighlighter : public QSyntaxHighlighter
{
Q_OBJECT
public:

View File

@@ -1,4 +1,11 @@
INCLUDEPATH *= $$PWD
INCLUDEPATH *= $$PWD $$PWD/..
SOURCES += $$PWD/qscripthighlighter.cpp $$PWD/qscriptincrementalscanner.cpp
HEADERS += $$PWD/qscripthighlighter.h $$PWD/qscriptincrementalscanner.h
DEFINES += QSCRIPTHIGHLIGHTER_BUILD_LIB
SOURCES += $$PWD/qscriptincrementalscanner.cpp
HEADERS += $$PWD/qscriptincrementalscanner.h $$PWD/qscripthighlighter_global.h
contains(QT, gui) {
SOURCES += $$PWD/qscripthighlighter.cpp
HEADERS += $$PWD/qscripthighlighter.h
}

View File

@@ -0,0 +1,12 @@
#ifndef QSCRIPTHIGHLIGHTER_GLOBAL_H
#define QSCRIPTHIGHLIGHTER_GLOBAL_H
#include <QtCore/QtGlobal>
#ifdef QSCRIPTHIGHLIGHTER_BUILD_LIB
# define QSCRIPTHIGHLIGHTER_EXPORT Q_DECL_EXPORT
#else // !QSCRIPTHIGHLIGHTER
# define QSCRIPTHIGHLIGHTER_EXPORT Q_DECL_IMPORT
#endif // QSCRIPTHIGHLIGHTER
#endif // QSCRIPTHIGHLIGHTER_GLOBAL_H

View File

@@ -1,13 +1,15 @@
#ifndef QSCRIPTINCREMENTALSCANNER_H
#define QSCRIPTINCREMENTALSCANNER_H
#include <qscripthighlighter/qscripthighlighter_global.h>
#include <QtCore/QList>
#include <QtCore/QSet>
#include <QtCore/QString>
namespace SharedTools {
class QScriptIncrementalScanner
class QSCRIPTHIGHLIGHTER_EXPORT QScriptIncrementalScanner
{
public: