2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-11-11 10:05:05 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-11-11 10:05:05 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-11-11 10:05:05 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2010-11-11 10:05:05 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 17:14:20 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-11-11 10:05:05 +01:00
|
|
|
|
|
|
|
|
#include "qmljstoolsplugin.h"
|
|
|
|
|
#include "qmljsmodelmanager.h"
|
2010-11-16 13:54:50 +01:00
|
|
|
#include "qmljsfunctionfilter.h"
|
|
|
|
|
#include "qmljslocatordata.h"
|
2011-02-03 15:48:14 +01:00
|
|
|
#include "qmljscodestylesettingspage.h"
|
|
|
|
|
#include "qmljstoolsconstants.h"
|
2011-05-25 08:50:01 +02:00
|
|
|
#include "qmljstoolssettings.h"
|
2012-12-06 17:20:58 +01:00
|
|
|
#include "qmljsbundleprovider.h"
|
2010-11-11 10:05:05 +01:00
|
|
|
|
2015-02-26 13:38:54 +01:00
|
|
|
#include <coreplugin/icontext.h>
|
2010-11-11 10:05:05 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2011-06-23 15:12:03 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/progressmanager/progressmanager.h>
|
2010-11-11 10:05:05 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QtPlugin>
|
|
|
|
|
#include <QMenu>
|
2010-11-11 10:05:05 +01:00
|
|
|
|
2013-08-30 09:22:42 +02:00
|
|
|
using namespace Core;
|
2012-10-04 14:54:59 +02:00
|
|
|
using namespace QmlJSTools;
|
2010-11-11 10:05:05 +01:00
|
|
|
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)
|
2015-02-04 09:32:46 +01:00
|
|
|
Q_UNUSED(error)
|
2011-06-23 15:12:03 +02:00
|
|
|
|
2011-05-25 08:50:01 +02:00
|
|
|
m_settings = new QmlJSToolsSettings(this); // force registration of qmljstools settings
|
|
|
|
|
|
2010-11-11 10:05:05 +01:00
|
|
|
// Objects
|
|
|
|
|
m_modelManager = new ModelManager(this);
|
2012-10-04 14:54:59 +02:00
|
|
|
|
2017-03-19 19:58:10 +02:00
|
|
|
// Core::VcsManager *vcsManager = Core::VcsManager::instance();
|
|
|
|
|
// Core::DocumentManager *documentManager = Core::DocumentManager::instance();
|
|
|
|
|
// connect(vcsManager, &Core::VcsManager::repositoryChanged,
|
|
|
|
|
// m_modelManager, &ModelManager::updateModifiedSourceFiles);
|
|
|
|
|
// connect(documentManager, &DocumentManager::filesChangedInternally,
|
|
|
|
|
// m_modelManager, &ModelManager::updateSourceFiles);
|
2010-11-11 10:05:05 +01:00
|
|
|
|
2010-11-16 13:54:50 +01:00
|
|
|
LocatorData *locatorData = new LocatorData;
|
|
|
|
|
addAutoReleasedObject(locatorData);
|
|
|
|
|
addAutoReleasedObject(new FunctionFilter(locatorData));
|
2011-05-25 08:50:01 +02:00
|
|
|
addAutoReleasedObject(new QmlJSCodeStyleSettingsPage);
|
2012-12-06 17:20:58 +01:00
|
|
|
addAutoReleasedObject(new BasicBundleProvider);
|
2011-05-25 08:50:01 +02:00
|
|
|
|
2011-06-23 15:12:03 +02:00
|
|
|
// Menus
|
2013-08-30 09:22:42 +02:00
|
|
|
ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);
|
|
|
|
|
ActionContainer *mqmljstools = ActionManager::createMenu(Constants::M_TOOLS_QMLJS);
|
2011-06-23 15:12:03 +02:00
|
|
|
QMenu *menu = mqmljstools->menu();
|
|
|
|
|
menu->setTitle(tr("&QML/JS"));
|
|
|
|
|
menu->setEnabled(true);
|
|
|
|
|
mtools->addMenu(mqmljstools);
|
|
|
|
|
|
|
|
|
|
// Update context in global context
|
|
|
|
|
m_resetCodeModelAction = new QAction(tr("Reset Code Model"), this);
|
2013-08-30 09:22:42 +02:00
|
|
|
Command *cmd = ActionManager::registerAction(
|
2015-02-19 11:35:47 +01:00
|
|
|
m_resetCodeModelAction, Constants::RESET_CODEMODEL);
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_resetCodeModelAction, &QAction::triggered,
|
|
|
|
|
m_modelManager, &ModelManager::resetCodeModel);
|
2011-06-23 15:12:03 +02:00
|
|
|
mqmljstools->addAction(cmd);
|
|
|
|
|
|
|
|
|
|
// watch task progress
|
2016-06-27 22:25:11 +03:00
|
|
|
connect(ProgressManager::instance(), &ProgressManager::taskStarted,
|
|
|
|
|
this, &QmlJSToolsPlugin::onTaskStarted);
|
|
|
|
|
connect(ProgressManager::instance(), &ProgressManager::allTasksFinished,
|
|
|
|
|
this, &QmlJSToolsPlugin::onAllTasksFinished);
|
2011-06-23 15:12:03 +02:00
|
|
|
|
2010-11-11 10:05:05 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlJSToolsPlugin::extensionsInitialized()
|
|
|
|
|
{
|
2010-12-03 10:13:15 +01:00
|
|
|
m_modelManager->delayedInitialization();
|
2010-11-11 10:05:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExtensionSystem::IPlugin::ShutdownFlag QmlJSToolsPlugin::aboutToShutdown()
|
|
|
|
|
{
|
|
|
|
|
return SynchronousShutdown;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:48:57 +02:00
|
|
|
void QmlJSToolsPlugin::onTaskStarted(Id type)
|
2011-06-23 15:12:03 +02:00
|
|
|
{
|
2014-01-23 14:28:31 +01:00
|
|
|
if (type == QmlJS::Constants::TASK_INDEX)
|
2011-06-23 15:12:03 +02:00
|
|
|
m_resetCodeModelAction->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:48:57 +02:00
|
|
|
void QmlJSToolsPlugin::onAllTasksFinished(Id type)
|
2011-06-23 15:12:03 +02:00
|
|
|
{
|
2014-01-23 14:28:31 +01:00
|
|
|
if (type == QmlJS::Constants::TASK_INDEX)
|
2011-06-23 15:12:03 +02:00
|
|
|
m_resetCodeModelAction->setEnabled(true);
|
|
|
|
|
}
|