Commit a8dbba5f authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

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

parent 57ba6b09
......@@ -7,4 +7,5 @@ SUBDIRS = \
extensionsystem \
utils \
utils/process_stub.pro \
cplusplus
cplusplus \
qml
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
INCLUDEPATH += $$PWD/../../shared
DEPENDPATH += $$PWD/../../shared
LIBS *= -l$$qtLibraryTarget(Qml)
TEMPLATE = lib
CONFIG += dll
TARGET = Qml
DEFINES += QML_BUILD_LIB QT_CREATOR
unix:QMAKE_CXXFLAGS_DEBUG += -O3
include(../../qtcreatorlibrary.pri)
include(qml-lib.pri)
#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
/**************************************************************************
**
** 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;
......
#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;
}
#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
......@@ -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);
}
}
......
......@@ -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;
......
......@@ -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 \
qmlexpressionundercursor.h \
qmlfilewizard.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 \
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 \
qmlexpressionundercursor.cpp \
qmlfilewizard.cpp \
qmlhighlighter.cpp \
qmleditoractionhandler.cpp \
qmlcodecompletion.cpp \
qmlhoverhandler.cpp \
qmldocument.cpp \
qmlmodelmanagerinterface.cpp \
qmlmodelmanager.cpp \
qmlcodeformatter.cpp \
idcollector.cpp \
qmlexpressionundercursor.cpp \
qmllookupcontext.cpp \
qmlresolveexpression.cpp \
qmlsymbol.cpp \
qmlfilewizard.cpp
qmlmodelmanager.cpp \
qmlmodelmanagerinterface.cpp \
qmlresolveexpression.cpp
RESOURCES += qmleditor.qrc
OTHER_FILES += QmlEditor.pluginspec
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)
......@@ -29,7 +29,7 @@
#include "qmleditorplugin.h"
#include "qscripthighlighter.h"
#include "qmlhighlighter.h"
#include "qmleditor.h"
#include "qmleditorconstants.h"
#include "qmleditorfactory.h"
......
#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;
......
#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;
......
......@@ -30,7 +30,7 @@
#ifndef QMLSYNTAXHIGHLIGHTER_H
#define QMLSYNTAXHIGHLIGHTER_H
#include "qscripthighlighter.h"
#include <qscripthighlighter/qscripthighlighter.h>
#include <texteditor/basetexteditor.h>
namespace QmlEditor {
......
......@@ -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>
......
#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;
......
#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 {
......
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment