Commit 96e31c2a authored by Erik Verbruggen's avatar Erik Verbruggen

Started merging the JS and QML editor plug-ins.

parent 898e84ce
......@@ -25,14 +25,13 @@ SUBDIRS = plugin_coreplugin \
# plugin_helloworld \ # sample plugin
plugin_help \
# plugin_regexp \ # don't know what to do with this
plugin_qtscripteditor \
plugin_cpaster \
plugin_cmakeprojectmanager \
plugin_fakevim \
plugin_designer \
plugin_resourceeditor \
plugin_genericprojectmanager \
plugin_qmleditor \
plugin_qmljseditor \
plugin_qmlprojectmanager \
plugin_mercurial \
debugger/dumper.pro
......@@ -154,10 +153,6 @@ plugin_resourceeditor.depends = plugin_coreplugin
plugin_regexp.subdir = regexp
plugin_regexp.depends = plugin_coreplugin
plugin_qtscripteditor.subdir = qtscripteditor
plugin_qtscripteditor.depends = plugin_texteditor
plugin_qtscripteditor.depends += plugin_coreplugin
plugin_cpaster.subdir = cpaster
plugin_cpaster.depends = plugin_texteditor
plugin_cpaster.depends += plugin_coreplugin
......@@ -175,15 +170,15 @@ plugin_genericprojectmanager.depends += plugin_projectexplorer
plugin_genericprojectmanager.depends += plugin_cpptools
plugin_genericprojectmanager.depends += plugin_cppeditor
plugin_qmleditor.subdir = qmleditor
plugin_qmleditor.depends = plugin_texteditor
plugin_qmleditor.depends += plugin_coreplugin
plugin_qmljseditor.subdir = qmljseditor
plugin_qmljseditor.depends = plugin_texteditor
plugin_qmljseditor.depends += plugin_coreplugin
plugin_qmlprojectmanager.subdir = qmlprojectmanager
plugin_qmlprojectmanager.depends = plugin_texteditor
plugin_qmlprojectmanager.depends += plugin_projectexplorer
plugin_qmlprojectmanager.depends += plugin_help
plugin_qmlprojectmanager.depends += plugin_qmleditor
plugin_qmlprojectmanager.depends += plugin_qmljseditor
plugin_qmldesigner.subdir = qmldesigner
plugin_qmldesigner.depends = plugin_coreplugin
......
......@@ -14,7 +14,6 @@ SOURCES += \
$$PWD/firstdefinitionfinder.cpp \
$$PWD/moveobjectbeforeobjectvisitor.cpp
HEADERS += \
$$PWD/qmleditor_global.h \
$$PWD/qmlrewriter.h \
$$PWD/qmlrefactoring.h \
$$PWD/changeobjecttypevisitor.h \
......
<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="application/x-qml">
<sub-class-of type="text/plain"/>
<comment>QML file</comment>
<glob pattern="*.qml"/>
</mime-type>
</mime-info>
include(qmleditor_dependencies.pri)
LIBS *= -l$$qtLibraryTarget(QmlEditor)
<RCC>
<qresource prefix="/qmleditor" >
<file>QmlEditor.mimetypes.xml</file>
</qresource>
</RCC>
/**************************************************************************
**
** 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.
**
**************************************************************************/
#ifndef QMLEDITOR_GLOBAL_H
#define QMLEDITOR_GLOBAL_H
#include <QtGlobal>
#if defined(QMLEDITOR_LIBRARY)
# define QMLEDITOR_EXPORT Q_DECL_EXPORT
#else
# define QMLEDITOR_EXPORT Q_DECL_IMPORT
#endif
#endif // QMLEDITOR_GLOBAL_H
<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="application/x-qml">
<sub-class-of type="text/plain"/>
<comment>QML file</comment>
<glob pattern="*.qml"/>
</mime-type>
<mime-type type="application/javascript">
<alias type="application/x-javascript"/>
<alias type="text/javascript"/>
......
<plugin name="QmlEditor" version="1.3.80" compatVersion="1.3.80">
<plugin name="QmlJSEditor" version="1.3.80" compatVersion="1.3.80">
<vendor>Nokia Corporation</vendor>
<copyright>(C) 2008-2009 Nokia Corporation</copyright>
<license>
......@@ -10,7 +10,7 @@ GNU Lesser General Public License Usage
Alternatively, this plugin may be used under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. 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.
</license>
<description>Editor for QML.</description>
<description>Editor for QML and JavaScript.</description>
<url>http://qt.nokia.com</url>
<dependencyList>
<dependency name="Core" version="1.3.80"/>
......
......@@ -28,7 +28,7 @@
**************************************************************************/
#include "qmlcodecompletion.h"
#include "qmleditor.h"
#include "qmljseditor.h"
#include "qmlmodelmanagerinterface.h"
#include "qmlexpressionundercursor.h"
#include "qmllookupcontext.h"
......@@ -39,8 +39,8 @@
#include <QtDebug>
using namespace QmlEditor;
using namespace QmlEditor::Internal;
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
QmlCodeCompletion::QmlCodeCompletion(QmlModelManagerInterface *modelManager, Qml::QmlTypeSystem *typeSystem, QObject *parent)
: TextEditor::ICompletionCollector(parent),
......@@ -65,7 +65,7 @@ void QmlCodeCompletion::setCaseSensitivity(Qt::CaseSensitivity caseSensitivity)
bool QmlCodeCompletion::supportsEditor(TextEditor::ITextEditable *editor)
{
if (qobject_cast<QmlTextEditor *>(editor->widget()))
if (qobject_cast<QmlJSTextEditor *>(editor->widget()))
return true;
return false;
......@@ -78,7 +78,7 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
{
m_editor = editor;
QmlTextEditor *edit = qobject_cast<QmlTextEditor *>(m_editor->widget());
QmlJSTextEditor *edit = qobject_cast<QmlJSTextEditor *>(m_editor->widget());
if (! edit)
return -1;
......
......@@ -37,7 +37,7 @@ namespace TextEditor {
class ITextEditable;
}
namespace QmlEditor {
namespace QmlJSEditor {
class QmlModelManagerInterface;
......@@ -73,6 +73,6 @@ private:
} // end of namespace Internal
} // end of namespace QmlEditor
} // end of namespace QmlJSEditor
#endif // QMLCODECOMPLETION_H
......@@ -42,7 +42,7 @@ using namespace Qml;
using namespace QmlJS;
using namespace QmlJS::AST;
namespace QmlEditor {
namespace QmlJSEditor {
namespace Internal {
class PositionCalculator: protected Visitor
{
......@@ -204,8 +204,8 @@ namespace QmlEditor {
}
}
using namespace QmlEditor;
using namespace QmlEditor::Internal;
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
QmlExpressionUnderCursor::QmlExpressionUnderCursor()
: _expressionNode(0),
......
......@@ -30,7 +30,6 @@
#ifndef QMLEXPRESSIONUNDERCURSOR_H
#define QMLEXPRESSIONUNDERCURSOR_H
#include <qmljs/parser/qmljsastfwd_p.h>
#include <qmljs/qmldocument.h>
#include <qmljs/qmlsymbol.h>
......@@ -44,7 +43,7 @@ namespace QmlJS {
class NodePool;
}
namespace QmlEditor {
namespace QmlJSEditor {
namespace Internal {
class QmlExpressionUnderCursor
......@@ -84,6 +83,6 @@ private:
};
} // namespace Internal
} // namespace QmlEditor
} // namespace QmlJSEditor
#endif // QMLEXPRESSIONUNDERCURSOR_H
......@@ -27,13 +27,13 @@
**
**************************************************************************/
#include "qmleditorconstants.h"
#include "qmljseditorconstants.h"
#include "qmlfilewizard.h"
#include <QtCore/QFileInfo>
#include <QtCore/QTextStream>
using namespace QmlEditor;
using namespace QmlJSEditor;
QmlFileWizard::QmlFileWizard(const BaseFileWizardParameters &parameters,
QObject *parent):
......@@ -46,11 +46,11 @@ Core::GeneratedFiles QmlFileWizard::generateFilesFromPath(const QString &path,
QString * /*errorMessage*/) const
{
const QString mimeType = QLatin1String(Constants::QMLEDITOR_MIMETYPE);
const QString mimeType = QLatin1String(Constants::QMLJSEDITOR_MIMETYPE);
const QString fileName = Core::BaseFileWizard::buildFileName(path, name, preferredSuffix(mimeType));
Core::GeneratedFile file(fileName);
file.setEditorId(QLatin1String(Constants::C_QMLEDITOR_ID));
file.setEditorId(QLatin1String(Constants::C_QMLJSEDITOR_ID));
file.setContents(fileContents(fileName));
return Core::GeneratedFiles() << file;
......
......@@ -32,7 +32,7 @@
#include <coreplugin/basefilewizard.h>
namespace QmlEditor {
namespace QmlJSEditor {
class QmlFileWizard: public Core::StandardFileWizard
{
......@@ -53,6 +53,6 @@ protected:
QString *errorMessage) const;
};
} // namespace QmlEditor
} // namespace QmlJSEditor
#endif // QMLFILEWIZARD_H
......@@ -31,8 +31,8 @@
#include <utils/qtcassert.h>
using namespace QmlEditor;
using namespace QmlEditor::Internal;
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
QmlHighlighter::QmlHighlighter(QTextDocument *parent) :
SharedTools::QScriptHighlighter(true, parent)
......
......@@ -33,7 +33,7 @@
#include <qscripthighlighter/qscripthighlighter.h>
#include <texteditor/basetexteditor.h>
namespace QmlEditor {
namespace QmlJSEditor {
namespace Internal {
// Highlighter for Scripts that stores
......@@ -59,6 +59,6 @@ private:
};
} // namespace Internal
} // namespace QmlEditor
} // namespace QmlJSEditor
#endif // QMLSYNTAXHIGHLIGHTER_H
......@@ -27,7 +27,7 @@
**
**************************************************************************/
#include "qmleditor.h"
#include "qmljseditor.h"
#include "qmlexpressionundercursor.h"
#include "qmlhoverhandler.h"
#include "qmllookupcontext.h"
......@@ -53,8 +53,8 @@
using namespace Core;
using namespace Qml;
using namespace QmlEditor;
using namespace QmlEditor::Internal;
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
QmlHoverHandler::QmlHoverHandler(QObject *parent)
: QObject(parent)
......@@ -84,7 +84,7 @@ QmlHoverHandler::QmlHoverHandler(QObject *parent)
void QmlHoverHandler::editorOpened(IEditor *editor)
{
QmlEditorEditable *qmlEditor = qobject_cast<QmlEditorEditable *>(editor);
QmlJSEditorEditable *qmlEditor = qobject_cast<QmlJSEditorEditable *>(editor);
if (!qmlEditor)
return;
......@@ -146,7 +146,7 @@ void QmlHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
if (!m_modelManager)
return;
QmlTextEditor *scriptEditor = qobject_cast<QmlTextEditor *>(editor->widget());
QmlJSTextEditor *scriptEditor = qobject_cast<QmlJSTextEditor *>(editor->widget());
if (!scriptEditor)
return;
......
......@@ -47,7 +47,7 @@ namespace TextEditor {
class ITextEditor;
}
namespace QmlEditor {
namespace QmlJSEditor {
namespace Internal {
class QmlHoverHandler : public QObject
......@@ -76,6 +76,6 @@ private:
};
} // namespace Internal
} // namespace QmlEditor
} // namespace QmlJSEditor
#endif // QMLHOVERHANDLER_H
......@@ -27,10 +27,10 @@
**
**************************************************************************/
#include "qmleditor.h"
#include "qmleditorconstants.h"
#include "qmljseditor.h"
#include "qmljseditorconstants.h"
#include "qmlhighlighter.h"
#include "qmleditorplugin.h"
#include "qmljseditorplugin.h"
#include "qmlmodelmanager.h"
#include "qmlexpressionundercursor.h"
......@@ -98,7 +98,7 @@ int blockStartState(const QTextBlock &block)
}
} // end of anonymous namespace
namespace QmlEditor {
namespace QmlJSEditor {
namespace Internal {
class FindIdDeclarations: protected Visitor
......@@ -297,16 +297,16 @@ protected:
#endif
};
QmlEditorEditable::QmlEditorEditable(QmlTextEditor *editor)
QmlJSEditorEditable::QmlJSEditorEditable(QmlJSTextEditor *editor)
: BaseTextEditorEditable(editor)
{
Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance();
m_context << uidm->uniqueIdentifier(QmlEditor::Constants::C_QMLEDITOR_ID);
m_context << uidm->uniqueIdentifier(QmlJSEditor::Constants::C_QMLJSEDITOR_ID);
m_context << uidm->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR);
}
QmlTextEditor::QmlTextEditor(QWidget *parent) :
QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
TextEditor::BaseTextEditor(parent),
m_methodCombo(0),
m_modelManager(0),
......@@ -317,7 +317,7 @@ QmlTextEditor::QmlTextEditor(QWidget *parent) :
setMarksVisible(true);
setCodeFoldingSupported(true);
setCodeFoldingVisible(true);
setMimeType(QmlEditor::Constants::QMLEDITOR_MIMETYPE);
setMimeType(QmlJSEditor::Constants::QMLJSEDITOR_MIMETYPE);
m_updateDocumentTimer = new QTimer(this);
m_updateDocumentTimer->setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL);
......@@ -343,37 +343,37 @@ QmlTextEditor::QmlTextEditor(QWidget *parent) :
}
}
QmlTextEditor::~QmlTextEditor()
QmlJSTextEditor::~QmlJSTextEditor()
{
}
QList<Declaration> QmlTextEditor::declarations() const
QList<Declaration> QmlJSTextEditor::declarations() const
{ return m_declarations; }
Core::IEditor *QmlEditorEditable::duplicate(QWidget *parent)
Core::IEditor *QmlJSEditorEditable::duplicate(QWidget *parent)
{
QmlTextEditor *newEditor = new QmlTextEditor(parent);
QmlJSTextEditor *newEditor = new QmlJSTextEditor(parent);
newEditor->duplicateFrom(editor());
QmlEditorPlugin::instance()->initializeEditor(newEditor);
QmlJSEditorPlugin::instance()->initializeEditor(newEditor);
return newEditor->editableInterface();
}
QString QmlEditorEditable::id() const
QString QmlJSEditorEditable::id() const
{
return QLatin1String(QmlEditor::Constants::C_QMLEDITOR_ID);
return QLatin1String(QmlJSEditor::Constants::C_QMLJSEDITOR_ID);
}
QmlTextEditor::Context QmlEditorEditable::context() const
QmlJSTextEditor::Context QmlJSEditorEditable::context() const
{
return m_context;
}
void QmlTextEditor::updateDocument()
void QmlJSTextEditor::updateDocument()
{
m_updateDocumentTimer->start(UPDATE_DOCUMENT_DEFAULT_INTERVAL);
}
void QmlTextEditor::updateDocumentNow()
void QmlJSTextEditor::updateDocumentNow()
{
// ### move in the parser thread.
......@@ -384,7 +384,7 @@ void QmlTextEditor::updateDocumentNow()
m_modelManager->updateSourceFiles(QStringList() << fileName);
}
void QmlTextEditor::onDocumentUpdated(Qml::QmlDocument::Ptr doc)
void QmlJSTextEditor::onDocumentUpdated(Qml::QmlDocument::Ptr doc)
{
if (file()->fileName() != doc->fileName())
return;
......@@ -444,7 +444,7 @@ void QmlTextEditor::onDocumentUpdated(Qml::QmlDocument::Ptr doc)
setExtraSelections(CodeWarningsSelection, selections);
}
void QmlTextEditor::jumpToMethod(int index)
void QmlJSTextEditor::jumpToMethod(int index)
{
if (index) {
Declaration d = m_declarations.at(index - 1);
......@@ -453,7 +453,7 @@ void QmlTextEditor::jumpToMethod(int index)
}
}
void QmlTextEditor::updateMethodBoxIndex()
void QmlJSTextEditor::updateMethodBoxIndex()
{
int line = 0, column = 0;
convertPosition(position(), &line, &column);
......@@ -474,12 +474,12 @@ void QmlTextEditor::updateMethodBoxIndex()
updateUses();
}
void QmlTextEditor::updateUses()
void QmlJSTextEditor::updateUses()
{
m_updateUsesTimer->start();
}
void QmlTextEditor::updateUsesNow()
void QmlJSTextEditor::updateUsesNow()
{
if (document()->revision() != m_idsRevision) {
updateUses();
......@@ -504,15 +504,15 @@ void QmlTextEditor::updateUsesNow()
setExtraSelections(CodeSemanticsSelection, selections);
}
void QmlTextEditor::updateMethodBoxToolTip()
void QmlJSTextEditor::updateMethodBoxToolTip()
{
}
void QmlTextEditor::updateFileName()
void QmlJSTextEditor::updateFileName()
{
}
void QmlTextEditor::renameIdUnderCursor()
void QmlJSTextEditor::renameIdUnderCursor()
{
const QString id = wordUnderCursor();
bool ok = false;
......@@ -533,7 +533,7 @@ void QmlTextEditor::renameIdUnderCursor()
}
}
QStringList QmlTextEditor::keywords() const
QStringList QmlJSTextEditor::keywords() const
{
QStringList words;
......@@ -543,7 +543,7 @@ QStringList QmlTextEditor::keywords() const
return words;
}
void QmlTextEditor::setFontSettings(const TextEditor::FontSettings &fs)
void QmlJSTextEditor::setFontSettings(const TextEditor::FontSettings &fs)
{
TextEditor::BaseTextEditor::setFontSettings(fs);
QmlHighlighter *highlighter = qobject_cast<QmlHighlighter*>(baseTextDocument()->syntaxHighlighter());
......@@ -569,7 +569,7 @@ void QmlTextEditor::setFontSettings(const TextEditor::FontSettings &fs)
highlighter->rehighlight();
}
QString QmlTextEditor::wordUnderCursor() const
QString QmlJSTextEditor::wordUnderCursor() const
{
QTextCursor tc = textCursor();
tc.movePosition(QTextCursor::StartOfWord);
......@@ -578,7 +578,7 @@ QString QmlTextEditor::wordUnderCursor() const
return word;
}
bool QmlTextEditor::isElectricCharacter(const QChar &ch) const
bool QmlJSTextEditor::isElectricCharacter(const QChar &ch) const
{
if (ch == QLatin1Char('}')
|| ch == QLatin1Char(']'))
......@@ -586,7 +586,7 @@ bool QmlTextEditor::isElectricCharacter(const QChar &ch) const
return false;
}
bool QmlTextEditor::isClosingBrace(const QList<QScriptIncrementalScanner::Token> &tokens) const
bool QmlJSTextEditor::isClosingBrace(const QList<QScriptIncrementalScanner::Token> &tokens) const
{
if (tokens.size() == 1) {
......@@ -598,7 +598,7 @@ bool QmlTextEditor::isClosingBrace(const QList<QScriptIncrementalScanner::Token>
return false;
}
void QmlTextEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar)
void QmlJSTextEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar)
{
TextEditor::TabSettings ts = tabSettings();
SharedTools::QScriptIndenter indenter;
......@@ -609,14 +609,14 @@ void QmlTextEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar type
ts.indentLine(block, indent);
}