Commit f3667544 authored by Christian Kamm's avatar Christian Kamm

Move shared code to a new QmlJSTools plugin.

Reviewed-by: Thomas Hartmann
parent a4cbd970
......@@ -42,6 +42,8 @@ ModelManagerInterface::ModelManagerInterface(QObject *parent)
ModelManagerInterface::~ModelManagerInterface()
{
Q_ASSERT(g_instance == this);
g_instance = 0;
}
ModelManagerInterface *ModelManagerInterface::instance()
......
......@@ -36,6 +36,7 @@ SUBDIRS = plugin_coreplugin \
plugin_mercurial \
plugin_classview \
plugin_tasklist \
plugin_qmljstools \
debugger/dumper.pro
include(../../qtcreator.pri)
......@@ -192,6 +193,7 @@ plugin_qmljseditor.subdir = qmljseditor
plugin_qmljseditor.depends = plugin_texteditor
plugin_qmljseditor.depends += plugin_coreplugin
plugin_qmljseditor.depends += plugin_projectexplorer
plugin_qmljseditor.depends += plugin_qmljstools
plugin_glsleditor.subdir = glsleditor
plugin_glsleditor.depends = plugin_texteditor
......@@ -229,3 +231,8 @@ plugin_classview.depends += plugin_texteditor
plugin_tasklist.subdir = tasklist
plugin_tasklist.depends = plugin_coreplugin
plugin_tasklist.depends += plugin_projectexplorer
plugin_qmljstools.subdir = qmljstools
plugin_qmljstools.depends = plugin_projectexplorer
plugin_qmljstools.depends += plugin_coreplugin
plugin_qmljstools.depends += plugin_texteditor
......@@ -104,6 +104,7 @@ const char * const C_PROJECTEXPLORER = "Project Explorer";
// languages
const char * const LANG_CXX = "CXX";
const char * const LANG_QMLJS = "QMLJS";
// menus
const char * const M_RECENTPROJECTS = "ProjectExplorer.Menu.Recent";
......
......@@ -17,5 +17,6 @@ Alternatively, this plugin may be used under the terms of the GNU Lesser General
<dependency name=\"Core\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"TextEditor\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"ProjectExplorer\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"QmlJSTools\" version=\"$$QTCREATOR_VERSION\"/>
</dependencyList>
</plugin>
......@@ -29,12 +29,12 @@
#include "qmljscomponentfromobjectdef.h"
#include "qmljscomponentnamedialog.h"
#include "qmljsrefactoringchanges.h"
#include <coreplugin/ifile.h>
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/qmljsdocument.h>
#include <qmljstools/qmljsrefactoringchanges.h>
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
......@@ -43,6 +43,7 @@
using namespace QmlJS::AST;
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
using namespace QmlJSTools;
namespace {
......
......@@ -32,8 +32,6 @@
#include "qmljseditorconstants.h"
#include "qmljshighlighter.h"
#include "qmljseditorplugin.h"
#include "qmljsmodelmanager.h"
#include "qmljseditorcodeformatter.h"
#include "qmljsquickfix.h"
#include "qmloutlinemodel.h"
#include "qmljsfindreferences.h"
......@@ -45,10 +43,13 @@
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljsicontextpane.h>
#include <qmljs/qmljslookupcontext.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmljs/parser/qmljsastvisitor_p.h>
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/parser/qmljsengine_p.h>
#include <qmljstools/qmljsqtstylecodeformatter.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/uniqueidmanager.h>
......@@ -66,6 +67,7 @@
#include <texteditor/refactoroverlay.h>
#include <texteditor/tooltip/tooltip.h>
#include <qmldesigner/qmldesignerconstants.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <utils/changeset.h>
#include <utils/uncommentselection.h>
......
......@@ -19,15 +19,12 @@ HEADERS += \
qmlfilewizard.h \
qmljshighlighter.h \
qmljshoverhandler.h \
qmljsmodelmanager.h \
qmljspreviewrunner.h \
qmljsquickfix.h \
qmljsrefactoringchanges.h \
qmljscomponentfromobjectdef.h \
qmljsoutline.h \
qmloutlinemodel.h \
qmltaskmanager.h \
qmljseditorcodeformatter.h \
qmljsoutlinetreeview.h \
quicktoolbarsettingspage.h \
quicktoolbar.h \
......@@ -48,16 +45,13 @@ SOURCES += \
qmlfilewizard.cpp \
qmljshighlighter.cpp \
qmljshoverhandler.cpp \
qmljsmodelmanager.cpp \
qmljspreviewrunner.cpp \
qmljsquickfix.cpp \
qmljsrefactoringchanges.cpp \
qmljscomponentfromobjectdef.cpp \
qmljsoutline.cpp \
qmloutlinemodel.cpp \
qmltaskmanager.cpp \
qmljsquickfixes.cpp \
qmljseditorcodeformatter.cpp \
qmljsoutlinetreeview.cpp \
quicktoolbarsettingspage.cpp \
quicktoolbar.cpp \
......
include(../../plugins/coreplugin/coreplugin.pri)
include(../../plugins/texteditor/texteditor.pri)
include(../../plugins/projectexplorer/projectexplorer.pri)
include(../../libs/qmljs/qmljs.pri)
include(../../plugins/qmljstools/qmljstools.pri)
include(../../libs/utils/utils.pri)
include(../../libs/qmleditorwidgets/qmleditorwidgets.pri)
......@@ -46,7 +46,6 @@ const char * const M_REFACTORING_MENU_INSERTION_POINT = "QmlJSEditor.RefactorGro
const char * const RUN_SEP = "QmlJSEditor.Run.Separator";
const char * const C_QMLJSEDITOR_ID = "QMLProjectManager.QMLJSEditor";
const char * const C_QMLJSEDITOR_DISPLAY_NAME = QT_TRANSLATE_NOOP("OpenWith::Editors", "QMLJS Editor");
const char * const TASK_INDEX = "QmlJSEditor.TaskIndex";
const char * const TASK_SEARCH = "QmlJSEditor.TaskSearch";
const char * const FOLLOW_SYMBOL_UNDER_CURSOR = "QmlJSEditor.FollowSymbolUnderCursor";
......
......@@ -33,6 +33,7 @@
#include <texteditor/texteditorconstants.h>
#include <qmldesigner/qmldesignerconstants.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/icore.h>
......@@ -48,6 +49,7 @@ QmlJSEditorEditable::QmlJSEditorEditable(QmlJSTextEditor *editor)
{
m_context.add(QmlJSEditor::Constants::C_QMLJSEDITOR_ID);
m_context.add(TextEditor::Constants::C_TEXTEDITOR);
m_context.add(ProjectExplorer::Constants::LANG_QMLJS);
}
// Use preferred mode from Bauhaus settings
......
......@@ -34,16 +34,17 @@
#include "qmljseditorfactory.h"
#include "qmljscodecompletion.h"
#include "qmljshoverhandler.h"
#include "qmljsmodelmanager.h"
#include "qmlfilewizard.h"
#include "qmljsoutline.h"
#include "qmljspreviewrunner.h"
#include "qmljsquickfix.h"
#include "qmljs/qmljsicons.h"
#include "qmltaskmanager.h"
#include "quicktoolbar.h"
#include "quicktoolbarsettingspage.h"
#include <qmljs/qmljsicons.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmldesigner/qmldesignerconstants.h>
#include <coreplugin/icore.h>
......@@ -125,8 +126,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/qmljseditor/QmlJSEditor.mimetypes.xml"), error_message))
return false;
m_modelManager = new ModelManager(this);
addAutoReleasedObject(m_modelManager);
m_modelManager = QmlJS::ModelManagerInterface::instance();
Core::Context context(QmlJSEditor::Constants::C_QMLJSEDITOR_ID);
......
......@@ -28,8 +28,8 @@
**************************************************************************/
#include "qmljsindenter.h"
#include "qmljseditorcodeformatter.h"
#include <qmljstools/qmljsqtstylecodeformatter.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/tabsettings.h>
......@@ -66,7 +66,7 @@ void Indenter::doIndentBlock(QTextDocument *doc,
Q_UNUSED(editor)
const TextEditor::TabSettings &ts = editor->tabSettings();
QtStyleCodeFormatter codeFormatter(ts);
QmlJSTools::QtStyleCodeFormatter codeFormatter(ts);
codeFormatter.updateStateUntil(block);
const int depth = codeFormatter.indentFor(block);
......
......@@ -30,7 +30,6 @@
#include "qmljsquickfix.h"
#include "qmljscomponentfromobjectdef.h"
#include "qmljseditor.h"
#include "qmljsrefactoringchanges.h"
#include "qmljs/parser/qmljsast_p.h"
#include <extensionsystem/iplugin.h>
......@@ -44,6 +43,7 @@ using namespace QmlJS;
using namespace QmlJS::AST;
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
using namespace QmlJSTools;
using namespace TextEditor;
using TextEditor::RefactoringChanges;
......
......@@ -31,11 +31,11 @@
#define QMLJSQUICKFIX_H
#include "qmljseditor.h"
#include "qmljsrefactoringchanges.h"
#include <texteditor/quickfix.h>
#include <qmljs/parser/qmljsastfwd_p.h>
#include <qmljs/qmljsdocument.h>
#include <qmljstools/qmljsrefactoringchanges.h>
namespace ExtensionSystem {
class IPlugin;
......@@ -73,7 +73,7 @@ public:
/// \returns the document of the editor
QmlJS::Document::Ptr document() const;
const QmlJSRefactoringFile currentFile() const;
const QmlJSTools::QmlJSRefactoringFile currentFile() const;
private:
SemanticInfo _semanticInfo;
......@@ -105,7 +105,8 @@ public:
protected:
typedef Utils::ChangeSet::Range Range;
virtual void performChanges(QmlJSRefactoringFile *currentFile, QmlJSRefactoringChanges *refactoring) = 0;
virtual void performChanges(QmlJSTools::QmlJSRefactoringFile *currentFile,
QmlJSTools::QmlJSRefactoringChanges *refactoring) = 0;
/// \returns A const-reference to the state of the operation.
const QmlJSQuickFixState &state() const;
......
......@@ -30,11 +30,11 @@
#include "qmljsquickfix.h"
#include "qmljscomponentfromobjectdef.h"
#include "qmljseditor.h"
#include "qmljsrefactoringchanges.h"
#include <extensionsystem/iplugin.h>
#include <extensionsystem/pluginmanager.h>
#include <qmljs/parser/qmljsast_p.h>
#include <qmljstools/qmljsrefactoringchanges.h>
#include <QtGui/QApplication>
......@@ -42,6 +42,7 @@ using namespace QmlJS;
using namespace QmlJS::AST;
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
using namespace QmlJSTools;
using namespace TextEditor;
using TextEditor::RefactoringChanges;
......
......@@ -28,8 +28,8 @@
**************************************************************************/
#include "qmljssemantichighlighter.h"
#include "qmljsmodelmanager.h"
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljscheck.h>
#include <qmljs/qmljsinterpreter.h>
......
#include "qmloutlinemodel.h"
#include "qmljseditor.h"
#include "qmljsrefactoringchanges.h"
#include <qmljs/parser/qmljsastvisitor_p.h>
#include <qmljs/qmljsinterpreter.h>
#include <qmljs/qmljslookupcontext.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmljs/qmljsrewriter.h>
#include <qmljstools/qmljsrefactoringchanges.h>
#include <utils/qtcassert.h>
......@@ -17,6 +17,7 @@
using namespace QmlJS;
using namespace QmlJSEditor::Internal;
using namespace QmlJSTools;
enum {
debug = false
......
<plugin name=\"QmlJSTools\" version=\"$$QTCREATOR_VERSION\" compatVersion=\"$$QTCREATOR_VERSION\">
<vendor>Nokia Corporation</vendor>
<copyright>(C) 2010 Nokia Corporation</copyright>
<license>
Commercial Usage
Licensees holding valid Qt Commercial licenses may use this plugin 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 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>
<category>Qt Quick</category>
<description>Tools for analyzing Qml/JS code.</description>
<url>http://qt.nokia.com</url>
<dependencyList>
<dependency name=\"TextEditor\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"ProjectExplorer\" version=\"$$QTCREATOR_VERSION\"/>
</dependencyList>
</plugin>
......@@ -27,9 +27,9 @@
**
**************************************************************************/
#include "qmljseditorconstants.h"
#include "qmljsmodelmanager.h"
#include "qmljseditor.h"
#include "qmljstoolsconstants.h"
//#include "qmljseditor.h"
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
......@@ -40,8 +40,10 @@
#include <qmljs/qmljsbind.h>
#include <qmljs/parser/qmldirparser_p.h>
#include <texteditor/itexteditor.h>
#include <texteditor/basetexteditor.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <QDir>
#include <QFile>
......@@ -55,8 +57,8 @@
#include <QDebug>
using namespace QmlJS;
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
using namespace QmlJSTools;
using namespace QmlJSTools::Internal;
static QStringList environmentImportPaths();
......@@ -108,8 +110,10 @@ ModelManagerInterface::WorkingCopy ModelManager::workingCopy() const
const QString key = editor->file()->fileName();
if (TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor)) {
if (QmlJSTextEditor *ed = qobject_cast<QmlJSTextEditor *>(textEditor->widget())) {
workingCopy.insert(key, ed->toPlainText(), ed->document()->revision());
if (textEditor->context().contains(ProjectExplorer::Constants::LANG_QMLJS)) {
if (TextEditor::BaseTextEditor *ed = qobject_cast<TextEditor::BaseTextEditor *>(textEditor->widget())) {
workingCopy.insert(key, ed->toPlainText(), ed->document()->revision());
}
}
}
}
......@@ -157,7 +161,7 @@ QFuture<void> ModelManager::refreshSourceFiles(const QStringList &sourceFiles,
if (sourceFiles.count() > 1) {
m_core->progressManager()->addTask(result, tr("Indexing"),
QmlJSEditor::Constants::TASK_INDEX);
Constants::TASK_INDEX);
}
return result;
......@@ -255,8 +259,8 @@ static QStringList qmlFilesInDirectory(const QString &path)
{
// ### It would suffice to build pattern once. This function needs to be thread-safe.
Core::MimeDatabase *db = Core::ICore::instance()->mimeDatabase();
Core::MimeType jsSourceTy = db->findByType(QmlJSEditor::Constants::JS_MIMETYPE);
Core::MimeType qmlSourceTy = db->findByType(QmlJSEditor::Constants::QML_MIMETYPE);
Core::MimeType jsSourceTy = db->findByType(Constants::JS_MIMETYPE);
Core::MimeType qmlSourceTy = db->findByType(Constants::QML_MIMETYPE);
QStringList pattern;
foreach (const Core::MimeGlobPattern &glob, jsSourceTy.globPatterns())
......
......@@ -30,6 +30,8 @@
#ifndef QMLJSMODELMANAGER_H
#define QMLJSMODELMANAGER_H
#include "qmljstools_global.h"
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmljs/qmljsdocument.h>
......@@ -43,10 +45,10 @@ class ICore;
class MimeType;
}
namespace QmlJSEditor {
namespace QmlJSTools {
namespace Internal {
class ModelManager: public QmlJS::ModelManagerInterface
class QMLJSTOOLS_EXPORT ModelManager: public QmlJS::ModelManagerInterface
{
Q_OBJECT
......@@ -113,6 +115,6 @@ private:
};
} // namespace Internal
} // namespace QmlJSEditor
} // namespace QmlJSTools
#endif // QMLJSMODELMANAGER_H
......@@ -27,14 +27,14 @@
**
**************************************************************************/
#include "qmljseditorcodeformatter.h"
#include "qmljsqtstylecodeformatter.h"
#include <texteditor/tabsettings.h>
#include <QtCore/QDebug>
using namespace QmlJS;
using namespace QmlJSEditor;
using namespace QmlJSTools;
using namespace TextEditor;
QtStyleCodeFormatter::QtStyleCodeFormatter()
......
......@@ -27,10 +27,10 @@
**
**************************************************************************/
#ifndef QMLJSEDITORCODEFORMATTER_H
#define QMLJSEDITORCODEFORMATTER_H
#ifndef QMLJSQTSTYLECODEFORMATTER_H
#define QMLJSQTSTYLECODEFORMATTER_H
#include "qmljseditor_global.h"
#include "qmljstools_global.h"
#include <texteditor/basetextdocumentlayout.h>
#include <qmljs/qmljscodeformatter.h>
......@@ -39,9 +39,9 @@ namespace TextEditor {
class TabSettings;
}
namespace QmlJSEditor {
namespace QmlJSTools {
class QMLJSEDITOR_EXPORT QtStyleCodeFormatter : public QmlJS::CodeFormatter
class QMLJSTOOLS_EXPORT QtStyleCodeFormatter : public QmlJS::CodeFormatter
{
public:
QtStyleCodeFormatter();
......@@ -69,6 +69,6 @@ private:
};
};
} // namespace QmlJSEditor
} // namespace QmlJSTools
#endif // QMLJSEDITORCODEFORMATTER_H
#endif // QMLJSQTSTYLECODEFORMATTER_H
......@@ -28,7 +28,7 @@
**************************************************************************/
#include "qmljsrefactoringchanges.h"
#include "qmljseditorcodeformatter.h"
#include "qmljsqtstylecodeformatter.h"
#include <qmljs/parser/qmljsast_p.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
......@@ -36,7 +36,7 @@
#include <texteditor/tabsettings.h>
using namespace QmlJS;
using namespace QmlJSEditor;
using namespace QmlJSTools;
QmlJSRefactoringChanges::QmlJSRefactoringChanges(ModelManagerInterface *modelManager,
const Snapshot &snapshot)
......
......@@ -30,6 +30,8 @@
#ifndef QMLREFACTORINGCHANGES_H
#define QMLREFACTORINGCHANGES_H
#include "qmljstools_global.h"
#include <qmljs/qmljsdocument.h>
#include <texteditor/refactoringchanges.h>
......@@ -38,11 +40,11 @@ namespace QmlJS {
class ModelManagerInterface;
} // namespace QmlJS
namespace QmlJSEditor {
namespace QmlJSTools {
class QmlJSRefactoringChanges;
class QmlJSRefactoringFile: public TextEditor::RefactoringFile
class QMLJSTOOLS_EXPORT QmlJSRefactoringFile: public TextEditor::RefactoringFile
{
public:
QmlJSRefactoringFile();
......@@ -67,7 +69,7 @@ private:
};
class QmlJSRefactoringChanges: public TextEditor::RefactoringChanges
class QMLJSTOOLS_EXPORT QmlJSRefactoringChanges: public TextEditor::RefactoringChanges
{
public:
QmlJSRefactoringChanges(QmlJS::ModelManagerInterface *modelManager,
......@@ -86,6 +88,6 @@ private:
QmlJS::Snapshot m_snapshot;
};
} // namespace QmlJSEditor
} // namespace QmlJSTools
#endif // QMLREFACTORINGCHANGES_H
!dll {
DEFINES += QMLJSTOOLS_STATIC
}
DEPENDPATH += $$PWD
INCLUDEPATH += $$PWD/..
HEADERS += \
$$PWD/qmljstools_global.h \
$$PWD/qmljstoolsplugin.h \
$$PWD/qmljstoolsconstants.h \
$$PWD/qmljsmodelmanager.h \
$$PWD/qmljsqtstylecodeformatter.h \
$$PWD/qmljsrefactoringchanges.h
SOURCES += \
$$PWD/qmljstoolsplugin.cpp \
$$PWD/qmljsmodelmanager.cpp \
$$PWD/qmljsqtstylecodeformatter.cpp \
$$PWD/qmljsrefactoringchanges.cpp
include(qmljstools_dependencies.pri)
DEPENDPATH += $$PWD
INCLUDEPATH += $$PWD/..
LIBS *= -l$$qtLibraryName(QmlJSTools)
TEMPLATE = lib
TARGET = QmlJSTools
include(../../qtcreatorplugin.pri)
include(qmljstools_dependencies.pri)
# DEFINES += QT_NO_CAST_FROM_ASCII
DEFINES += QT_NO_CAST_TO_ASCII
DEFINES += QMLJSTOOLS_LIBRARY
include(qmljstools-lib.pri)
include($$IDE_SOURCE_TREE/src/libs/qmljs/qmljs.pri)
include($$IDE_SOURCE_TREE/src/plugins/projectexplorer/projectexplorer.pri)
include($$IDE_SOURCE_TREE/src/plugins/texteditor/texteditor.pri)
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 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