forked from qt-creator/qt-creator
Analyzer: Move runMode member from IAnalyzerTool to AnalyzerAction
Slim down tool before dissolving. Change-Id: I502aaa8860293acf8bfd93f541b751d5b96a9563 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -431,7 +431,7 @@ bool AnalyzerManagerPrivate::isActionRunnable(AnalyzerAction *action) const
|
||||
if (action->startMode() == StartRemote)
|
||||
return true;
|
||||
|
||||
return ProjectExplorerPlugin::canRun(SessionManager::startupProject(), action->tool()->runMode(), 0);
|
||||
return ProjectExplorerPlugin::canRun(SessionManager::startupProject(), action->runMode(), 0);
|
||||
}
|
||||
|
||||
void AnalyzerManagerPrivate::startTool()
|
||||
@@ -590,7 +590,7 @@ void AnalyzerManagerPrivate::updateRunActions()
|
||||
disabledReason = tr("No analyzer tool selected.");
|
||||
else
|
||||
ProjectExplorerPlugin::canRun(SessionManager::startupProject(),
|
||||
m_currentAction->tool()->runMode(), &disabledReason);
|
||||
m_currentAction->runMode(), &disabledReason);
|
||||
|
||||
m_startAction->setEnabled(isActionRunnable(m_currentAction));
|
||||
m_startAction->setToolTip(disabledReason);
|
||||
@@ -707,9 +707,8 @@ AnalyzerRunControl *AnalyzerManager::createRunControl(
|
||||
const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration)
|
||||
{
|
||||
foreach (AnalyzerAction *action, d->m_actions) {
|
||||
IAnalyzerTool *tool = action->tool();
|
||||
if (tool->runMode() == sp.runMode && action->startMode() == sp.startMode)
|
||||
return tool->createRunControl(sp, runConfiguration);
|
||||
if (action->runMode() == sp.runMode && action->startMode() == sp.startMode)
|
||||
return action->tool()->createRunControl(sp, runConfiguration);
|
||||
}
|
||||
QTC_CHECK(false);
|
||||
return 0;
|
||||
|
||||
@@ -62,13 +62,12 @@ IAnalyzerTool::IAnalyzerTool(QObject *parent)
|
||||
: QObject(parent)
|
||||
{}
|
||||
|
||||
/// Returns the run mode for this tool.
|
||||
ProjectExplorer::RunMode IAnalyzerTool::runMode() const
|
||||
ProjectExplorer::RunMode AnalyzerAction::runMode() const
|
||||
{
|
||||
return m_runMode;
|
||||
}
|
||||
|
||||
void IAnalyzerTool::setRunMode(ProjectExplorer::RunMode mode)
|
||||
void AnalyzerAction::setRunMode(ProjectExplorer::RunMode mode)
|
||||
{
|
||||
m_runMode = mode;
|
||||
}
|
||||
@@ -103,7 +102,7 @@ static bool buildTypeAccepted(IAnalyzerTool::ToolMode toolMode,
|
||||
return false;
|
||||
}
|
||||
|
||||
void IAnalyzerTool::startLocalTool()
|
||||
void IAnalyzerTool::startLocalTool(RunMode runMode)
|
||||
{
|
||||
// Make sure mode is shown.
|
||||
AnalyzerManager::showMode();
|
||||
@@ -154,10 +153,10 @@ void IAnalyzerTool::startLocalTool()
|
||||
return;
|
||||
}
|
||||
|
||||
ProjectExplorerPlugin::instance()->runProject(pro, runMode());
|
||||
ProjectExplorerPlugin::instance()->runProject(pro, runMode);
|
||||
}
|
||||
|
||||
void IAnalyzerTool::startRemoteTool()
|
||||
void IAnalyzerTool::startRemoteTool(RunMode runMode)
|
||||
{
|
||||
StartRemoteDialog dlg;
|
||||
if (dlg.exec() != QDialog::Accepted)
|
||||
@@ -173,7 +172,7 @@ void IAnalyzerTool::startRemoteTool()
|
||||
|
||||
AnalyzerRunControl *rc = createRunControl(sp, 0);
|
||||
|
||||
ProjectExplorerPlugin::startRunControl(rc, runMode());
|
||||
ProjectExplorerPlugin::startRunControl(rc, runMode);
|
||||
}
|
||||
|
||||
} // namespace Analyzer
|
||||
|
||||
@@ -68,9 +68,6 @@ class ANALYZER_EXPORT IAnalyzerTool : public QObject
|
||||
public:
|
||||
explicit IAnalyzerTool(QObject *parent = 0);
|
||||
|
||||
ProjectExplorer::RunMode runMode() const;
|
||||
void setRunMode(ProjectExplorer::RunMode mode);
|
||||
|
||||
/**
|
||||
* The mode in which this tool should preferably be run
|
||||
*
|
||||
@@ -98,11 +95,10 @@ public:
|
||||
|
||||
virtual void startTool(StartMode mode) = 0;
|
||||
|
||||
void startLocalTool();
|
||||
void startRemoteTool();
|
||||
void startLocalTool(ProjectExplorer::RunMode runMode);
|
||||
void startRemoteTool(ProjectExplorer::RunMode runMode);
|
||||
|
||||
private:
|
||||
ProjectExplorer::RunMode m_runMode;
|
||||
ToolMode m_toolMode;
|
||||
};
|
||||
|
||||
@@ -131,11 +127,15 @@ public:
|
||||
Core::Id id() const { return m_id; }
|
||||
void setId(Core::Id id) { m_id = id; }
|
||||
|
||||
ProjectExplorer::RunMode runMode() const;
|
||||
void setRunMode(ProjectExplorer::RunMode mode);
|
||||
|
||||
protected:
|
||||
IAnalyzerTool *m_tool;
|
||||
StartMode m_startMode;
|
||||
Core::Id m_menuGroup;
|
||||
Core::Id m_id;
|
||||
ProjectExplorer::RunMode m_runMode;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
|
||||
action = new AnalyzerAction(this);
|
||||
action->setId("QmlProfiler.Local");
|
||||
action->setTool(tool);
|
||||
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
|
||||
action->setText(tr("QML Profiler"));
|
||||
action->setToolTip(description);
|
||||
action->setStartMode(StartLocal);
|
||||
@@ -72,6 +73,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
|
||||
action = new AnalyzerAction(this);
|
||||
action->setId("QmlProfiler.Remote");
|
||||
action->setTool(tool);
|
||||
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
|
||||
action->setText(tr("QML Profiler (External)"));
|
||||
action->setToolTip(description);
|
||||
action->setStartMode(StartRemote);
|
||||
|
||||
@@ -124,7 +124,6 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
||||
: IAnalyzerTool(parent), d(new QmlProfilerToolPrivate)
|
||||
{
|
||||
setObjectName(QLatin1String("QmlProfilerTool"));
|
||||
setRunMode(QmlProfilerRunMode);
|
||||
setToolMode(AnyMode);
|
||||
|
||||
d->m_profilerState = 0;
|
||||
@@ -528,7 +527,7 @@ static void startRemoteTool(IAnalyzerTool *tool, StartMode mode)
|
||||
|
||||
AnalyzerRunControl *rc = tool->createRunControl(sp, 0);
|
||||
|
||||
ProjectExplorerPlugin::startRunControl(rc, tool->runMode());
|
||||
ProjectExplorerPlugin::startRunControl(rc, QmlProfilerRunMode);
|
||||
}
|
||||
|
||||
void QmlProfilerTool::startTool(StartMode mode)
|
||||
@@ -546,7 +545,7 @@ void QmlProfilerTool::startTool(StartMode mode)
|
||||
if (mode == StartLocal) {
|
||||
// ### not sure if we're supposed to check if the RunConFiguration isEnabled
|
||||
Project *pro = SessionManager::startupProject();
|
||||
ProjectExplorerPlugin::instance()->runProject(pro, runMode());
|
||||
ProjectExplorerPlugin::instance()->runProject(pro, QmlProfilerRunMode);
|
||||
} else if (mode == StartRemote) {
|
||||
Internal::startRemoteTool(this, mode);
|
||||
}
|
||||
|
||||
@@ -502,7 +502,6 @@ CallgrindTool::CallgrindTool(QObject *parent)
|
||||
{
|
||||
d = new CallgrindToolPrivate(this);
|
||||
setObjectName(QLatin1String("CallgrindTool"));
|
||||
setRunMode(CallgrindRunMode);
|
||||
setToolMode(ReleaseMode);
|
||||
|
||||
connect(EditorManager::instance(), &EditorManager::editorOpened,
|
||||
@@ -561,9 +560,9 @@ AnalyzerRunControl *CallgrindToolPrivate::createRunControl(const AnalyzerStartPa
|
||||
void CallgrindTool::startTool(StartMode mode)
|
||||
{
|
||||
if (mode == StartLocal)
|
||||
startLocalTool();
|
||||
startLocalTool(CallgrindRunMode);
|
||||
if (mode == StartRemote)
|
||||
startRemoteTool();
|
||||
startRemoteTool(CallgrindRunMode);
|
||||
d->setBusyCursor(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -196,7 +196,6 @@ MemcheckTool::MemcheckTool(QObject *parent)
|
||||
m_filterMenu = 0;
|
||||
|
||||
setObjectName(QLatin1String("MemcheckTool"));
|
||||
setRunMode(MemcheckRunMode);
|
||||
setToolMode(DebugMode);
|
||||
|
||||
m_filterProjectAction = new QAction(tr("External Errors"), this);
|
||||
@@ -602,18 +601,27 @@ void MemcheckTool::setBusyCursor(bool busy)
|
||||
void MemcheckTool::startTool(StartMode mode)
|
||||
{
|
||||
if (mode == StartLocal)
|
||||
startLocalTool();
|
||||
startLocalTool(MemcheckRunMode);
|
||||
if (mode == StartRemote)
|
||||
startRemoteTool();
|
||||
startRemoteTool(MemcheckRunMode);
|
||||
}
|
||||
|
||||
MemcheckWithGdbTool::MemcheckWithGdbTool(QObject *parent) :
|
||||
MemcheckTool(parent)
|
||||
{
|
||||
setRunMode(MemcheckWithGdbRunMode);
|
||||
setObjectName(QLatin1String("MemcheckWithGdbTool"));
|
||||
}
|
||||
|
||||
|
||||
void MemcheckWithGdbTool::startTool(Analyzer::StartMode mode)
|
||||
{
|
||||
if (mode == StartLocal)
|
||||
startLocalTool(MemcheckWithGdbRunMode);
|
||||
if (mode == StartRemote)
|
||||
startRemoteTool(MemcheckWithGdbRunMode);
|
||||
}
|
||||
|
||||
|
||||
MemcheckRunControl *MemcheckWithGdbTool::createMemcheckRunControl(const AnalyzerStartParameters &sp,
|
||||
RunConfiguration *runConfiguration)
|
||||
{
|
||||
|
||||
@@ -139,6 +139,7 @@ public:
|
||||
MemcheckWithGdbTool(QObject *parent);
|
||||
|
||||
protected:
|
||||
void startTool(Analyzer::StartMode mode);
|
||||
MemcheckRunControl *createMemcheckRunControl(
|
||||
const Analyzer::AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration) Q_DECL_OVERRIDE;
|
||||
|
||||
@@ -128,6 +128,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
||||
action = new AnalyzerAction(this);
|
||||
action->setId("Memcheck.Local");
|
||||
action->setTool(m_memcheckTool);
|
||||
action->setRunMode(ProjectExplorer::MemcheckRunMode);
|
||||
action->setText(tr("Valgrind Memory Analyzer"));
|
||||
action->setToolTip(memcheckToolTip);
|
||||
action->setMenuGroup(Constants::G_ANALYZER_TOOLS);
|
||||
@@ -138,6 +139,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
||||
action = new AnalyzerAction(this);
|
||||
action->setId("MemcheckWithGdb.Local");
|
||||
action->setTool(m_memcheckWithGdbTool);
|
||||
action->setRunMode(ProjectExplorer::MemcheckWithGdbRunMode);
|
||||
action->setText(tr("Valgrind Memory Analyzer with GDB"));
|
||||
action->setToolTip(memcheckWithGdbToolTip);
|
||||
action->setMenuGroup(Constants::G_ANALYZER_TOOLS);
|
||||
@@ -148,6 +150,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
||||
action = new AnalyzerAction(this);
|
||||
action->setId("Callgrind.Local");
|
||||
action->setTool(m_callgrindTool);
|
||||
action->setRunMode(ProjectExplorer::CallgrindRunMode);
|
||||
action->setText(tr("Valgrind Function Profiler"));
|
||||
action->setToolTip(callgrindToolTip);
|
||||
action->setMenuGroup(Constants::G_ANALYZER_TOOLS);
|
||||
@@ -159,6 +162,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
||||
action = new AnalyzerAction(this);
|
||||
action->setId("Memcheck.Remote");
|
||||
action->setTool(m_memcheckTool);
|
||||
action->setRunMode(ProjectExplorer::MemcheckRunMode);
|
||||
action->setText(tr("Valgrind Memory Analyzer (External Remote Application)"));
|
||||
action->setToolTip(memcheckToolTip);
|
||||
action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS);
|
||||
@@ -168,6 +172,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
||||
action = new AnalyzerAction(this);
|
||||
action->setId("Callgrind.Remote");
|
||||
action->setTool(m_callgrindTool);
|
||||
action->setRunMode(ProjectExplorer::CallgrindRunMode);
|
||||
action->setText(tr("Valgrind Function Profiler (External Remote Application)"));
|
||||
action->setToolTip(callgrindToolTip);
|
||||
action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS);
|
||||
|
||||
Reference in New Issue
Block a user