diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp index fbd340587e3a28914dab7fb66d81cc0ccb39c051..c0b97167ab29e087e16cbc55acd6d10f97e49262 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 4b5ece63c307069e40d39795bc1f82f4a0b8817f..3e90879c9edd7c155ae33cda473cb4ba4dbadd51 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 0a36560a10fa15697fcad0eb180d03e6a31058e3..448cc28c7d5d761aed177df9b4ffdae30f3d7a01 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 29c8c7ca3c0eb28861b73ba38c80760503a4a1d3..b70f1f8e0780920dcc9e69d4c4c5a7c72b92c1f0 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 0fcfd8108ac62e0465d18641ec28daba67f522b7..fb8c313ac468b35b488a81babcb39e447ba0f8fd 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 d7fa0d4261b14dfa3cfa1bb43e074d6655794682..f14765b7924a4bfe0a97e328fa9ab44812a45f46 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 1d66b2f958c8f4eb109f46f301f376c02eafabfd..bc989b6b5bfbe52ca6c1ddc041983e829b0d9bcf 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 97beaaa74601f9a983607ab72f22ff0091e865a8..5634e49ad4de50dfa73ea0c97bfa877e7203c2a6 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 753a143bc2818e6554286f056edd7ae767135be2..63de1bb73ba568fff697707b3df6f7f3341c5ab6 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 0013fc9277b7eab6d2c58a4026549944d63da9df..c1168a9e03466c7c99010a1be65033e8ffeba55c 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 4aae75e28a59fdfd52561ee8382c481b6d225854..d6f18a08bcc36078b8dc22bded7424754eaa992a 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 63f0c99d5e9298779cb09b4e6dd4f2c3ddca9a70..81374504ea417536ad8ef9400c8db9b671ef7717 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 018442cd8bc1b93235b22d2fb8e04489b9a4a8f7..7d5ee5a0bee486f5089f1a5394c107b916d7e772 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 b316e117e04c04ffc7a4b9b6ef9d9166f0aa7760..6c47398a8031f1a050731dd3304854439564de27 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 006ce4b457ecd7dc6fb7f1539a0eb994ea5f55ea..fe4215fd0a107dc33c223ad458d13a0bac2f6953 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 0881ee879b93de12905cb8df7b6babbf904a130f..927878aa2c4befef8c42928eb6607e0c16903aab 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 e07a9f6f0d118cc54c1e0c21277507f83d6011c6..59b16aa0625e04edd1ee28133e177d40143210c7 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 0000000000000000000000000000000000000000..0128ca3945bd3b2df287d801b62e89934e8aafce --- /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 f64de791816028bc57e72e99e2c4b6825e48656a..cd694114c8459c8b7c38535da933a1c81175d00a 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 842ba4a4fd7f2def2c96fa3ea62121ff393b232b..ee990328d3affdc094d8cd8e1f7c11fbfd658127 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 ad296a74b25635397c8e61447219db6cca65718e..3821844e6c38e9eeb48d83865a7b21dd435a0799 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 baf663c723b2a26702c9749200aacabeefc98fbb..f016df76a05adc878464cd347687d85e4043deae 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 bf7ed2018c0b5d895e48d7c1eb89641a87e0a267..7bbacb5d1c84aef02332ebed45fdbe1d958485dc 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 b1ba3d4e466557192212363c714c9a4015e4a04a..9c5a5e61121a379a39aec7fc8846d286a6ac4d27 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 0000000000000000000000000000000000000000..e7fcd84f44fb1027243b6c5558fa39833b0fc250 --- /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 0000000000000000000000000000000000000000..196d757a1470ee343fbf672bcfa635536d3aacb3 --- /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 0000000000000000000000000000000000000000..86426bb3b7adf40d7e5e4b42a4c3362a35d2f58b --- /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 0000000000000000000000000000000000000000..81d08c633d7813428dfba1626a19b92d78fda0e8 --- /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 0000000000000000000000000000000000000000..bc16c2f0dc262b81a15769d90e2bf8c06b24701b --- /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 0000000000000000000000000000000000000000..d30315f6ec015f224eba38ce25a7b10f217c9190 --- /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 0000000000000000000000000000000000000000..b4b13c46fdc8a3699d86839c2921f5f5f57bf424 --- /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 0000000000000000000000000000000000000000..4d6890539bac5a3254ab2b4fae422e7407293a97 --- /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