From f36675446204c58a0f019a95bf4d60a3c9f2ced7 Mon Sep 17 00:00:00 2001
From: Christian Kamm <christian.d.kamm@nokia.com>
Date: Thu, 11 Nov 2010 10:05:05 +0100
Subject: [PATCH] Move shared code to a new QmlJSTools plugin.

Reviewed-by: Thomas Hartmann
---
 src/libs/qmljs/qmljsmodelmanagerinterface.cpp |  2 +
 src/plugins/plugins.pro                       |  7 ++
 .../projectexplorerconstants.h                |  1 +
 .../qmljseditor/QmlJSEditor.pluginspec.in     |  1 +
 .../qmljscomponentfromobjectdef.cpp           |  3 +-
 src/plugins/qmljseditor/qmljseditor.cpp       |  6 +-
 src/plugins/qmljseditor/qmljseditor.pro       |  6 --
 .../qmljseditor/qmljseditor_dependencies.pri  |  2 +-
 .../qmljseditor/qmljseditorconstants.h        |  1 -
 .../qmljseditor/qmljseditoreditable.cpp       |  2 +
 src/plugins/qmljseditor/qmljseditorplugin.cpp |  8 +-
 src/plugins/qmljseditor/qmljsindenter.cpp     |  4 +-
 src/plugins/qmljseditor/qmljsquickfix.cpp     |  2 +-
 src/plugins/qmljseditor/qmljsquickfix.h       |  7 +-
 src/plugins/qmljseditor/qmljsquickfixes.cpp   |  3 +-
 .../qmljseditor/qmljssemantichighlighter.cpp  |  2 +-
 src/plugins/qmljseditor/qmloutlinemodel.cpp   |  3 +-
 .../qmljstools/QmlJSTools.pluginspec.in       | 20 +++++
 .../qmljsmodelmanager.cpp                     | 22 +++--
 .../qmljsmodelmanager.h                       |  8 +-
 .../qmljsqtstylecodeformatter.cpp}            |  4 +-
 .../qmljsqtstylecodeformatter.h}              | 14 +--
 .../qmljsrefactoringchanges.cpp               |  4 +-
 .../qmljsrefactoringchanges.h                 | 10 ++-
 src/plugins/qmljstools/qmljstools-lib.pri     | 20 +++++
 src/plugins/qmljstools/qmljstools.pri         |  6 ++
 src/plugins/qmljstools/qmljstools.pro         | 10 +++
 .../qmljstools/qmljstools_dependencies.pri    |  3 +
 src/plugins/qmljstools/qmljstools_global.h    | 43 +++++++++
 src/plugins/qmljstools/qmljstoolsconstants.h  | 46 ++++++++++
 src/plugins/qmljstools/qmljstoolsplugin.cpp   | 89 +++++++++++++++++++
 src/plugins/qmljstools/qmljstoolsplugin.h     | 73 +++++++++++++++
 32 files changed, 381 insertions(+), 51 deletions(-)
 create mode 100644 src/plugins/qmljstools/QmlJSTools.pluginspec.in
 rename src/plugins/{qmljseditor => qmljstools}/qmljsmodelmanager.cpp (96%)
 rename src/plugins/{qmljseditor => qmljstools}/qmljsmodelmanager.h (96%)
 rename src/plugins/{qmljseditor/qmljseditorcodeformatter.cpp => qmljstools/qmljsqtstylecodeformatter.cpp} (99%)
 rename src/plugins/{qmljseditor/qmljseditorcodeformatter.h => qmljstools/qmljsqtstylecodeformatter.h} (89%)
 rename src/plugins/{qmljseditor => qmljstools}/qmljsrefactoringchanges.cpp (98%)
 rename src/plugins/{qmljseditor => qmljstools}/qmljsrefactoringchanges.h (91%)
 create mode 100644 src/plugins/qmljstools/qmljstools-lib.pri
 create mode 100644 src/plugins/qmljstools/qmljstools.pri
 create mode 100644 src/plugins/qmljstools/qmljstools.pro
 create mode 100644 src/plugins/qmljstools/qmljstools_dependencies.pri
 create mode 100644 src/plugins/qmljstools/qmljstools_global.h
 create mode 100644 src/plugins/qmljstools/qmljstoolsconstants.h
 create mode 100644 src/plugins/qmljstools/qmljstoolsplugin.cpp
 create mode 100644 src/plugins/qmljstools/qmljstoolsplugin.h

diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
index fbd340587e3..c0b97167ab2 100644
--- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
+++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
@@ -42,6 +42,8 @@ ModelManagerInterface::ModelManagerInterface(QObject *parent)
 
 ModelManagerInterface::~ModelManagerInterface()
 {
+    Q_ASSERT(g_instance == this);
+    g_instance = 0;
 }
 
 ModelManagerInterface *ModelManagerInterface::instance()
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 4b5ece63c30..3e90879c9ed 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -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
diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h
index 0a36560a10f..448cc28c7d5 100644
--- a/src/plugins/projectexplorer/projectexplorerconstants.h
+++ b/src/plugins/projectexplorer/projectexplorerconstants.h
@@ -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";
diff --git a/src/plugins/qmljseditor/QmlJSEditor.pluginspec.in b/src/plugins/qmljseditor/QmlJSEditor.pluginspec.in
index 29c8c7ca3c0..b70f1f8e078 100644
--- a/src/plugins/qmljseditor/QmlJSEditor.pluginspec.in
+++ b/src/plugins/qmljseditor/QmlJSEditor.pluginspec.in
@@ -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>
diff --git a/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp b/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp
index 0fcfd8108ac..fb8c313ac46 100644
--- a/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp
+++ b/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp
@@ -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 {
 
diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp
index d7fa0d4261b..f14765b7924 100644
--- a/src/plugins/qmljseditor/qmljseditor.cpp
+++ b/src/plugins/qmljseditor/qmljseditor.cpp
@@ -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>
 
diff --git a/src/plugins/qmljseditor/qmljseditor.pro b/src/plugins/qmljseditor/qmljseditor.pro
index 1d66b2f958c..bc989b6b5bf 100644
--- a/src/plugins/qmljseditor/qmljseditor.pro
+++ b/src/plugins/qmljseditor/qmljseditor.pro
@@ -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 \
diff --git a/src/plugins/qmljseditor/qmljseditor_dependencies.pri b/src/plugins/qmljseditor/qmljseditor_dependencies.pri
index 97beaaa7460..5634e49ad4d 100644
--- a/src/plugins/qmljseditor/qmljseditor_dependencies.pri
+++ b/src/plugins/qmljseditor/qmljseditor_dependencies.pri
@@ -1,6 +1,6 @@
 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)
diff --git a/src/plugins/qmljseditor/qmljseditorconstants.h b/src/plugins/qmljseditor/qmljseditorconstants.h
index 753a143bc28..63de1bb73ba 100644
--- a/src/plugins/qmljseditor/qmljseditorconstants.h
+++ b/src/plugins/qmljseditor/qmljseditorconstants.h
@@ -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";
diff --git a/src/plugins/qmljseditor/qmljseditoreditable.cpp b/src/plugins/qmljseditor/qmljseditoreditable.cpp
index 0013fc9277b..c1168a9e034 100644
--- a/src/plugins/qmljseditor/qmljseditoreditable.cpp
+++ b/src/plugins/qmljseditor/qmljseditoreditable.cpp
@@ -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
diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp
index 4aae75e28a5..d6f18a08bcc 100644
--- a/src/plugins/qmljseditor/qmljseditorplugin.cpp
+++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp
@@ -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);
 
diff --git a/src/plugins/qmljseditor/qmljsindenter.cpp b/src/plugins/qmljseditor/qmljsindenter.cpp
index 63f0c99d5e9..81374504ea4 100644
--- a/src/plugins/qmljseditor/qmljsindenter.cpp
+++ b/src/plugins/qmljseditor/qmljsindenter.cpp
@@ -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);
diff --git a/src/plugins/qmljseditor/qmljsquickfix.cpp b/src/plugins/qmljseditor/qmljsquickfix.cpp
index 018442cd8bc..7d5ee5a0bee 100644
--- a/src/plugins/qmljseditor/qmljsquickfix.cpp
+++ b/src/plugins/qmljseditor/qmljsquickfix.cpp
@@ -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;
 
diff --git a/src/plugins/qmljseditor/qmljsquickfix.h b/src/plugins/qmljseditor/qmljsquickfix.h
index b316e117e04..6c47398a803 100644
--- a/src/plugins/qmljseditor/qmljsquickfix.h
+++ b/src/plugins/qmljseditor/qmljsquickfix.h
@@ -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;
diff --git a/src/plugins/qmljseditor/qmljsquickfixes.cpp b/src/plugins/qmljseditor/qmljsquickfixes.cpp
index 006ce4b457e..fe4215fd0a1 100644
--- a/src/plugins/qmljseditor/qmljsquickfixes.cpp
+++ b/src/plugins/qmljseditor/qmljsquickfixes.cpp
@@ -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;
 
diff --git a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp
index 0881ee879b9..927878aa2c4 100644
--- a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp
+++ b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp
@@ -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>
diff --git a/src/plugins/qmljseditor/qmloutlinemodel.cpp b/src/plugins/qmljseditor/qmloutlinemodel.cpp
index e07a9f6f0d1..59b16aa0625 100644
--- a/src/plugins/qmljseditor/qmloutlinemodel.cpp
+++ b/src/plugins/qmljseditor/qmloutlinemodel.cpp
@@ -1,12 +1,12 @@
 #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
diff --git a/src/plugins/qmljstools/QmlJSTools.pluginspec.in b/src/plugins/qmljstools/QmlJSTools.pluginspec.in
new file mode 100644
index 00000000000..0128ca3945b
--- /dev/null
+++ b/src/plugins/qmljstools/QmlJSTools.pluginspec.in
@@ -0,0 +1,20 @@
+<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>
diff --git a/src/plugins/qmljseditor/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp
similarity index 96%
rename from src/plugins/qmljseditor/qmljsmodelmanager.cpp
rename to src/plugins/qmljstools/qmljsmodelmanager.cpp
index f64de791816..cd694114c84 100644
--- a/src/plugins/qmljseditor/qmljsmodelmanager.cpp
+++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp
@@ -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())
diff --git a/src/plugins/qmljseditor/qmljsmodelmanager.h b/src/plugins/qmljstools/qmljsmodelmanager.h
similarity index 96%
rename from src/plugins/qmljseditor/qmljsmodelmanager.h
rename to src/plugins/qmljstools/qmljsmodelmanager.h
index 842ba4a4fd7..ee990328d3a 100644
--- a/src/plugins/qmljseditor/qmljsmodelmanager.h
+++ b/src/plugins/qmljstools/qmljsmodelmanager.h
@@ -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
diff --git a/src/plugins/qmljseditor/qmljseditorcodeformatter.cpp b/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
similarity index 99%
rename from src/plugins/qmljseditor/qmljseditorcodeformatter.cpp
rename to src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
index ad296a74b25..3821844e6c3 100644
--- a/src/plugins/qmljseditor/qmljseditorcodeformatter.cpp
+++ b/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
@@ -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()
diff --git a/src/plugins/qmljseditor/qmljseditorcodeformatter.h b/src/plugins/qmljstools/qmljsqtstylecodeformatter.h
similarity index 89%
rename from src/plugins/qmljseditor/qmljseditorcodeformatter.h
rename to src/plugins/qmljstools/qmljsqtstylecodeformatter.h
index baf663c723b..f016df76a05 100644
--- a/src/plugins/qmljseditor/qmljseditorcodeformatter.h
+++ b/src/plugins/qmljstools/qmljsqtstylecodeformatter.h
@@ -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
diff --git a/src/plugins/qmljseditor/qmljsrefactoringchanges.cpp b/src/plugins/qmljstools/qmljsrefactoringchanges.cpp
similarity index 98%
rename from src/plugins/qmljseditor/qmljsrefactoringchanges.cpp
rename to src/plugins/qmljstools/qmljsrefactoringchanges.cpp
index bf7ed2018c0..7bbacb5d1c8 100644
--- a/src/plugins/qmljseditor/qmljsrefactoringchanges.cpp
+++ b/src/plugins/qmljstools/qmljsrefactoringchanges.cpp
@@ -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)
diff --git a/src/plugins/qmljseditor/qmljsrefactoringchanges.h b/src/plugins/qmljstools/qmljsrefactoringchanges.h
similarity index 91%
rename from src/plugins/qmljseditor/qmljsrefactoringchanges.h
rename to src/plugins/qmljstools/qmljsrefactoringchanges.h
index b1ba3d4e466..9c5a5e61121 100644
--- a/src/plugins/qmljseditor/qmljsrefactoringchanges.h
+++ b/src/plugins/qmljstools/qmljsrefactoringchanges.h
@@ -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
diff --git a/src/plugins/qmljstools/qmljstools-lib.pri b/src/plugins/qmljstools/qmljstools-lib.pri
new file mode 100644
index 00000000000..e7fcd84f44f
--- /dev/null
+++ b/src/plugins/qmljstools/qmljstools-lib.pri
@@ -0,0 +1,20 @@
+!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
diff --git a/src/plugins/qmljstools/qmljstools.pri b/src/plugins/qmljstools/qmljstools.pri
new file mode 100644
index 00000000000..196d757a147
--- /dev/null
+++ b/src/plugins/qmljstools/qmljstools.pri
@@ -0,0 +1,6 @@
+include(qmljstools_dependencies.pri)
+
+DEPENDPATH += $$PWD
+INCLUDEPATH += $$PWD/..
+
+LIBS *= -l$$qtLibraryName(QmlJSTools)
diff --git a/src/plugins/qmljstools/qmljstools.pro b/src/plugins/qmljstools/qmljstools.pro
new file mode 100644
index 00000000000..86426bb3b7a
--- /dev/null
+++ b/src/plugins/qmljstools/qmljstools.pro
@@ -0,0 +1,10 @@
+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)
diff --git a/src/plugins/qmljstools/qmljstools_dependencies.pri b/src/plugins/qmljstools/qmljstools_dependencies.pri
new file mode 100644
index 00000000000..81d08c633d7
--- /dev/null
+++ b/src/plugins/qmljstools/qmljstools_dependencies.pri
@@ -0,0 +1,3 @@
+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)
diff --git a/src/plugins/qmljstools/qmljstools_global.h b/src/plugins/qmljstools/qmljstools_global.h
new file mode 100644
index 00000000000..bc16c2f0dc2
--- /dev/null
+++ b/src/plugins/qmljstools/qmljstools_global.h
@@ -0,0 +1,43 @@
+/**************************************************************************
+**
+** 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
+** 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 QMLJSTOOLS_GLOBAL_H
+#define QMLJSTOOLS_GLOBAL_H
+
+#include <QtGlobal>
+
+#if defined(QMLJSTOOLS_LIBRARY)
+#  define QMLJSTOOLS_EXPORT Q_DECL_EXPORT
+#elif defined(QMLJSTOOLS_STATIC)
+#  define QMLJSTOOLS_EXPORT
+#else
+#  define QMLJSTOOLS_EXPORT Q_DECL_IMPORT
+#endif
+
+#endif // QMLJSTOOLS_GLOBAL_H
diff --git a/src/plugins/qmljstools/qmljstoolsconstants.h b/src/plugins/qmljstools/qmljstoolsconstants.h
new file mode 100644
index 00000000000..d30315f6ec0
--- /dev/null
+++ b/src/plugins/qmljstools/qmljstoolsconstants.h
@@ -0,0 +1,46 @@
+/**************************************************************************
+**
+** 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
+** 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 QMLJSTOOLS_CONSTANTS_H
+#define QMLJSTOOLS_CONSTANTS_H
+
+#include <QtCore/QtGlobal>
+
+namespace QmlJSTools {
+namespace Constants {
+
+const char * const QML_MIMETYPE = "application/x-qml";
+const char * const JS_MIMETYPE = "application/javascript";
+
+const char * const TASK_INDEX = "QmlJSEditor.TaskIndex";
+
+} // namespace Constants
+} // namespace QmlJSEditor
+
+#endif // QMLJSTOOLS_CONSTANTS_H
diff --git a/src/plugins/qmljstools/qmljstoolsplugin.cpp b/src/plugins/qmljstools/qmljstoolsplugin.cpp
new file mode 100644
index 00000000000..b4b13c46fdc
--- /dev/null
+++ b/src/plugins/qmljstools/qmljstoolsplugin.cpp
@@ -0,0 +1,89 @@
+/**************************************************************************
+**
+** 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
+** 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 "qmljstoolsplugin.h"
+#include "qmljsmodelmanager.h"
+
+#include <extensionsystem/pluginmanager.h>
+
+#include <coreplugin/icore.h>
+
+#include <QtCore/QtPlugin>
+#include <QtCore/QFileInfo>
+#include <QtCore/QDir>
+#include <QtCore/QDebug>
+#include <QtCore/QSettings>
+
+using namespace QmlJSTools::Internal;
+
+enum { debug = 0 };
+
+QmlJSToolsPlugin *QmlJSToolsPlugin::m_instance = 0;
+
+QmlJSToolsPlugin::QmlJSToolsPlugin()
+    : m_modelManager(0)
+{
+    m_instance = this;
+}
+
+QmlJSToolsPlugin::~QmlJSToolsPlugin()
+{
+    m_instance = 0;
+    m_modelManager = 0; // deleted automatically
+}
+
+bool QmlJSToolsPlugin::initialize(const QStringList &arguments, QString *error)
+{
+    Q_UNUSED(arguments)
+    Q_UNUSED(error)
+//    Core::ICore *core = Core::ICore::instance();
+
+    // Objects
+    m_modelManager = new ModelManager(this);
+//    Core::VCSManager *vcsManager = core->vcsManager();
+//    Core::FileManager *fileManager = core->fileManager();
+//    connect(vcsManager, SIGNAL(repositoryChanged(QString)),
+//            m_modelManager, SLOT(updateModifiedSourceFiles()));
+//    connect(fileManager, SIGNAL(filesChangedInternally(QStringList)),
+//            m_modelManager, SLOT(updateSourceFiles(QStringList)));
+    addAutoReleasedObject(m_modelManager);
+
+    return true;
+}
+
+void QmlJSToolsPlugin::extensionsInitialized()
+{
+}
+
+ExtensionSystem::IPlugin::ShutdownFlag QmlJSToolsPlugin::aboutToShutdown()
+{
+    return SynchronousShutdown;
+}
+
+Q_EXPORT_PLUGIN(QmlJSToolsPlugin)
diff --git a/src/plugins/qmljstools/qmljstoolsplugin.h b/src/plugins/qmljstools/qmljstoolsplugin.h
new file mode 100644
index 00000000000..4d6890539ba
--- /dev/null
+++ b/src/plugins/qmljstools/qmljstoolsplugin.h
@@ -0,0 +1,73 @@
+/**************************************************************************
+**
+** 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
+** 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 QMLJSTOOLS_H
+#define QMLJSTOOLS_H
+
+#include <extensionsystem/iplugin.h>
+#include <projectexplorer/projectexplorer.h>
+
+#include <QtGui/QTextDocument>
+#include <QtCore/QSharedPointer>
+
+QT_BEGIN_NAMESPACE
+class QFileInfo;
+class QDir;
+QT_END_NAMESPACE
+
+namespace QmlJSTools {
+namespace Internal {
+
+class ModelManager;
+
+class QmlJSToolsPlugin : public ExtensionSystem::IPlugin
+{
+    Q_DISABLE_COPY(QmlJSToolsPlugin)
+    Q_OBJECT
+public:
+    static QmlJSToolsPlugin *instance() { return m_instance; }
+
+    QmlJSToolsPlugin();
+    ~QmlJSToolsPlugin();
+
+    bool initialize(const QStringList &arguments, QString *error_message);
+    void extensionsInitialized();
+    ShutdownFlag aboutToShutdown();
+    ModelManager *modelManager() { return m_modelManager; }
+
+private:
+    ModelManager *m_modelManager;
+
+    static QmlJSToolsPlugin *m_instance;
+};
+
+} // namespace Internal
+} // namespace CppTools
+
+#endif // QMLJSTOOLS_H
-- 
GitLab