forked from qt-creator/qt-creator
Analyzer: Merge IAnalyzerEngine and AnalyzerRunControl
Change-Id: I74edaef59600a44924d2692c1ebc7f98d8581115 Reviewed-by: Christiaan Janssen <christiaan.janssen@digia.com>
This commit is contained in:
@@ -7,7 +7,6 @@ QT += network
|
||||
# AnalyzerBase files
|
||||
|
||||
SOURCES += \
|
||||
ianalyzerengine.cpp \
|
||||
ianalyzertool.cpp \
|
||||
analyzerplugin.cpp \
|
||||
analyzerruncontrol.cpp \
|
||||
@@ -19,7 +18,6 @@ SOURCES += \
|
||||
startremotedialog.cpp
|
||||
|
||||
HEADERS += \
|
||||
ianalyzerengine.h \
|
||||
ianalyzertool.h \
|
||||
analyzerbase_global.h \
|
||||
analyzerconstants.h \
|
||||
|
||||
@@ -31,8 +31,6 @@ QtcPlugin {
|
||||
"analyzerstartparameters.h",
|
||||
"analyzerutils.cpp",
|
||||
"analyzerutils.h",
|
||||
"ianalyzerengine.cpp",
|
||||
"ianalyzerengine.h",
|
||||
"ianalyzertool.cpp",
|
||||
"ianalyzertool.h",
|
||||
"startremotedialog.cpp",
|
||||
|
||||
@@ -29,14 +29,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "analyzerruncontrol.h"
|
||||
#include "ianalyzerengine.h"
|
||||
#include "ianalyzertool.h"
|
||||
#include "analyzermanager.h"
|
||||
#include "analyzerstartparameters.h"
|
||||
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/taskhub.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QAction>
|
||||
|
||||
@@ -44,117 +40,64 @@ using namespace ProjectExplorer;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// AnalyzerRunControl::Private
|
||||
// AnalyzerRunControl
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace Analyzer {
|
||||
|
||||
class AnalyzerRunControl::Private
|
||||
AnalyzerRunControl::AnalyzerRunControl(const AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration)
|
||||
: RunControl(runConfiguration, sp.runMode)
|
||||
{
|
||||
public:
|
||||
Private();
|
||||
|
||||
bool m_isRunning;
|
||||
IAnalyzerEngine *m_engine;
|
||||
};
|
||||
|
||||
AnalyzerRunControl::Private::Private()
|
||||
: m_isRunning(false), m_engine(0)
|
||||
{}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// AnalyzerRunControl
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AnalyzerRunControl::AnalyzerRunControl(IAnalyzerTool *tool,
|
||||
const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration)
|
||||
: RunControl(runConfiguration, tool->runMode()),
|
||||
d(new Private)
|
||||
{
|
||||
d->m_engine = tool->createEngine(sp, runConfiguration);
|
||||
|
||||
if (!d->m_engine)
|
||||
return;
|
||||
|
||||
connect(d->m_engine, SIGNAL(outputReceived(QString,Utils::OutputFormat)),
|
||||
SLOT(receiveOutput(QString,Utils::OutputFormat)));
|
||||
connect(d->m_engine, SIGNAL(taskToBeAdded(ProjectExplorer::Task::TaskType,QString,QString,int)),
|
||||
SLOT(addTask(ProjectExplorer::Task::TaskType,QString,QString,int)));
|
||||
connect(d->m_engine, SIGNAL(finished()),
|
||||
SLOT(engineFinished()));
|
||||
m_runConfig = runConfiguration;
|
||||
m_sp = sp;
|
||||
|
||||
connect(this, SIGNAL(finished()), SLOT(runControlFinished()));
|
||||
connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), SLOT(stopIt()));
|
||||
}
|
||||
|
||||
AnalyzerRunControl::~AnalyzerRunControl()
|
||||
{
|
||||
if (d->m_isRunning)
|
||||
stop();
|
||||
|
||||
delete d->m_engine;
|
||||
d->m_engine = 0;
|
||||
delete d;
|
||||
}
|
||||
|
||||
void AnalyzerRunControl::start()
|
||||
{
|
||||
if (!d->m_engine) {
|
||||
emit finished();
|
||||
return;
|
||||
}
|
||||
|
||||
AnalyzerManager::handleToolStarted();
|
||||
|
||||
// Clear about-to-be-outdated tasks.
|
||||
ProjectExplorerPlugin::instance()->taskHub()
|
||||
->clearTasks(Core::Id(Constants::ANALYZERTASK_ID));
|
||||
|
||||
if (d->m_engine->start()) {
|
||||
d->m_isRunning = true;
|
||||
emit started();
|
||||
}
|
||||
}
|
||||
|
||||
RunControl::StopResult AnalyzerRunControl::stop()
|
||||
{
|
||||
if (!d->m_engine || !d->m_isRunning)
|
||||
return StoppedSynchronously;
|
||||
|
||||
d->m_engine->stop();
|
||||
d->m_isRunning = false;
|
||||
return AsynchronousStop;
|
||||
}
|
||||
|
||||
void AnalyzerRunControl::stopIt()
|
||||
{
|
||||
if (stop() == RunControl::StoppedSynchronously)
|
||||
AnalyzerManager::handleToolFinished();
|
||||
}
|
||||
|
||||
void AnalyzerRunControl::engineFinished()
|
||||
void AnalyzerRunControl::runControlFinished()
|
||||
{
|
||||
d->m_isRunning = false;
|
||||
m_isRunning = false;
|
||||
AnalyzerManager::handleToolFinished();
|
||||
emit finished();
|
||||
}
|
||||
|
||||
void AnalyzerRunControl::start()
|
||||
{
|
||||
AnalyzerManager::handleToolStarted();
|
||||
|
||||
if (startEngine()) {
|
||||
m_isRunning = true;
|
||||
emit started();
|
||||
}
|
||||
}
|
||||
|
||||
RunControl::StopResult AnalyzerRunControl::stop()
|
||||
{
|
||||
if (!m_isRunning)
|
||||
return StoppedSynchronously;
|
||||
|
||||
stopEngine();
|
||||
m_isRunning = false;
|
||||
return AsynchronousStop;
|
||||
}
|
||||
|
||||
bool AnalyzerRunControl::isRunning() const
|
||||
{
|
||||
return d->m_isRunning;
|
||||
return m_isRunning;
|
||||
}
|
||||
|
||||
QString AnalyzerRunControl::displayName() const
|
||||
{
|
||||
if (!d->m_engine)
|
||||
return QString();
|
||||
if (d->m_engine->runConfiguration())
|
||||
return d->m_engine->runConfiguration()->displayName();
|
||||
else
|
||||
return d->m_engine->startParameters().displayName;
|
||||
return m_runConfig ? m_runConfig->displayName() : m_sp.displayName;
|
||||
}
|
||||
|
||||
QIcon AnalyzerRunControl::icon() const
|
||||
@@ -162,23 +105,4 @@ QIcon AnalyzerRunControl::icon() const
|
||||
return QIcon(QLatin1String(":/images/analyzer_start_small.png"));
|
||||
}
|
||||
|
||||
IAnalyzerEngine *AnalyzerRunControl::engine() const
|
||||
{
|
||||
return d->m_engine;
|
||||
}
|
||||
|
||||
void AnalyzerRunControl::receiveOutput(const QString &text, Utils::OutputFormat format)
|
||||
{
|
||||
appendMessage(text, format);
|
||||
}
|
||||
|
||||
void AnalyzerRunControl::addTask(Task::TaskType type, const QString &description,
|
||||
const QString &file, int line)
|
||||
{
|
||||
TaskHub *hub = ProjectExplorerPlugin::instance()->taskHub();
|
||||
hub->addTask(Task(type, description, Utils::FileName::fromUserInput(file), line,
|
||||
Core::Id(Constants::ANALYZERTASK_ID)));
|
||||
hub->requestPopup();
|
||||
}
|
||||
|
||||
} // namespace Analyzer
|
||||
|
||||
@@ -36,20 +36,55 @@
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/task.h>
|
||||
|
||||
#include "analyzerbase_global.h"
|
||||
#include "analyzerstartparameters.h"
|
||||
|
||||
#include <projectexplorer/task.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <utils/outputformat.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
namespace ProjectExplorer { class RunConfiguration; }
|
||||
|
||||
namespace Analyzer {
|
||||
|
||||
class AnalyzerStartParameters;
|
||||
class IAnalyzerTool;
|
||||
class IAnalyzerEngine;
|
||||
|
||||
/**
|
||||
* An AnalyzerRunControl instance handles the launch of an analyzation tool.
|
||||
*
|
||||
* It gets created for each launch and deleted when the launch is stopped or ended.
|
||||
*/
|
||||
class ANALYZER_EXPORT AnalyzerRunControl : public ProjectExplorer::RunControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AnalyzerRunControl(IAnalyzerTool *tool, const AnalyzerStartParameters &sp,
|
||||
AnalyzerRunControl(const AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration);
|
||||
~AnalyzerRunControl();
|
||||
|
||||
/// Start analyzation process.
|
||||
virtual bool startEngine() = 0;
|
||||
/// Trigger async stop of the analyzation process.
|
||||
virtual void stopEngine() = 0;
|
||||
|
||||
/// Controller actions.
|
||||
virtual bool canPause() const { return false; }
|
||||
virtual void pause() {}
|
||||
virtual void unpause() {}
|
||||
|
||||
/// The active run configuration for this engine, might be zero.
|
||||
ProjectExplorer::RunConfiguration *runConfiguration() const { return m_runConfig; }
|
||||
|
||||
/// The start parameters for this engine.
|
||||
const AnalyzerStartParameters &startParameters() const { return m_sp; }
|
||||
|
||||
StartMode mode() const { return m_sp.startMode; }
|
||||
|
||||
virtual void notifyRemoteSetupDone(quint16) {}
|
||||
virtual void notifyRemoteFinished(bool) {}
|
||||
|
||||
bool m_isRunning;
|
||||
|
||||
// ProjectExplorer::RunControl
|
||||
void start();
|
||||
@@ -58,22 +93,21 @@ public:
|
||||
QString displayName() const;
|
||||
QIcon icon() const;
|
||||
|
||||
IAnalyzerEngine *engine() const;
|
||||
public slots:
|
||||
virtual void logApplicationMessage(const QString &, Utils::OutputFormat) {}
|
||||
|
||||
private slots:
|
||||
void stopIt();
|
||||
void receiveOutput(const QString &, Utils::OutputFormat format);
|
||||
void runControlFinished();
|
||||
|
||||
void addTask(ProjectExplorer::Task::TaskType type, const QString &description,
|
||||
const QString &file, int line);
|
||||
|
||||
void engineFinished();
|
||||
signals:
|
||||
/// Must be emitted when the engine is starting.
|
||||
void starting(const Analyzer::AnalyzerRunControl *);
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private *d;
|
||||
ProjectExplorer::RunConfiguration *m_runConfig;
|
||||
AnalyzerStartParameters m_sp;
|
||||
};
|
||||
|
||||
} // namespace Analyzer
|
||||
|
||||
#endif // ANALYZERRUNCONTROL_H
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <coreplugin/id.h>
|
||||
#include <ssh/sshconnection.h>
|
||||
#include <utils/environment.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
|
||||
namespace Analyzer {
|
||||
|
||||
@@ -51,6 +52,7 @@ public:
|
||||
{}
|
||||
|
||||
StartMode startMode;
|
||||
ProjectExplorer::RunMode runMode;
|
||||
QSsh::SshConnectionParameters connParams;
|
||||
|
||||
Core::Id toolId;
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
** Author: Nicolas Arnaud-Cormos, KDAB (nicolas.arnaud-cormos@kdab.com)
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "ianalyzerengine.h"
|
||||
|
||||
namespace Analyzer {
|
||||
|
||||
IAnalyzerEngine::IAnalyzerEngine(const AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration)
|
||||
{
|
||||
m_runConfig = runConfiguration;
|
||||
m_sp = sp;
|
||||
}
|
||||
|
||||
} // namespace Analyzer
|
||||
@@ -1,105 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
** Author: Nicolas Arnaud-Cormos, KDAB (nicolas.arnaud-cormos@kdab.com)
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef IANALYZERENGINE_H
|
||||
#define IANALYZERENGINE_H
|
||||
|
||||
#include "analyzerbase_global.h"
|
||||
#include "analyzerstartparameters.h"
|
||||
|
||||
#include <projectexplorer/task.h>
|
||||
#include <utils/outputformat.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class RunConfiguration;
|
||||
}
|
||||
|
||||
namespace Analyzer {
|
||||
|
||||
/**
|
||||
* An IAnalyzerEngine instance handles the launch of an analyzation tool.
|
||||
*
|
||||
* It gets created for each launch and deleted when the launch is stopped or ended.
|
||||
*/
|
||||
class ANALYZER_EXPORT IAnalyzerEngine : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IAnalyzerEngine(const AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration);
|
||||
|
||||
/// Start analyzation process.
|
||||
virtual bool start() = 0;
|
||||
/// Trigger async stop of the analyzation process.
|
||||
virtual void stop() = 0;
|
||||
|
||||
/// Controller actions.
|
||||
virtual bool canPause() const { return false; }
|
||||
virtual void pause() {}
|
||||
virtual void unpause() {}
|
||||
|
||||
/// The active run configuration for this engine, might be zero.
|
||||
ProjectExplorer::RunConfiguration *runConfiguration() const { return m_runConfig; }
|
||||
|
||||
/// The start parameters for this engine.
|
||||
const AnalyzerStartParameters &startParameters() const { return m_sp; }
|
||||
|
||||
StartMode mode() const { return m_sp.startMode; }
|
||||
|
||||
virtual void notifyRemoteSetupDone(quint16) {}
|
||||
virtual void notifyRemoteFinished(bool) {}
|
||||
|
||||
public slots:
|
||||
virtual void logApplicationMessage(const QString &, Utils::OutputFormat) {}
|
||||
|
||||
signals:
|
||||
/// Should be emitted when the debuggee outputted something.
|
||||
void outputReceived(const QString &, Utils::OutputFormat format);
|
||||
/// Can be emitted when you want to show a task, e.g. to display an error.
|
||||
void taskToBeAdded(ProjectExplorer::Task::TaskType type, const QString &description,
|
||||
const QString &file, int line);
|
||||
|
||||
/// Must be emitted when the engine finished.
|
||||
void finished();
|
||||
/// Must be emitted when the engine is starting.
|
||||
void starting(const Analyzer::IAnalyzerEngine *);
|
||||
|
||||
private:
|
||||
ProjectExplorer::RunConfiguration *m_runConfig;
|
||||
AnalyzerStartParameters m_sp;
|
||||
};
|
||||
|
||||
} // namespace Analyzer
|
||||
|
||||
#endif // IANALYZERENGINE_H
|
||||
@@ -45,7 +45,7 @@ class RunConfiguration;
|
||||
namespace Analyzer {
|
||||
|
||||
class IAnalyzerOutputPaneAdapter;
|
||||
class IAnalyzerEngine;
|
||||
class AnalyzerRunControl;
|
||||
class AbstractAnalyzerSubConfig;
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
|
||||
/// Returns a new engine for the given start parameters.
|
||||
/// Called each time the tool is launched.
|
||||
virtual IAnalyzerEngine *createEngine(const AnalyzerStartParameters &sp,
|
||||
virtual AnalyzerRunControl *createRunControl(const AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration = 0) = 0;
|
||||
|
||||
/// Returns true if the tool can be run
|
||||
|
||||
Reference in New Issue
Block a user