Commit 88a10a92 authored by hjk's avatar hjk

Analyzer: Remove one level of indirection when creating RunControls

Change-Id: I7029e2dbd3352549036da642fdbd926756a563cb
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent cbe27c5c
......@@ -32,6 +32,7 @@
#include "analyzermanager.h"
#include "analyzerplugin.h"
#include "analyzerstartparameters.h"
#include "ianalyzertool.h"
#include <coreplugin/coreconstants.h>
......@@ -709,10 +710,9 @@ AnalyzerRunControl *AnalyzerManager::createRunControl(
const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration)
{
foreach (AnalyzerAction *action, d->m_actions) {
if (AnalyzerRunControl *rc = action->tryCreateRunControl(sp, runConfiguration))
return rc;
if (action->runMode() == sp.runMode)
return action->runControlCreator()(sp, runConfiguration);
}
QTC_CHECK(false);
return 0;
}
......
......@@ -70,13 +70,6 @@ bool AnalyzerAction::isRunnable(QString *reason) const
return ProjectExplorerPlugin::canRun(SessionManager::startupProject(), m_runMode, reason);
}
AnalyzerRunControl *AnalyzerAction::tryCreateRunControl(const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration) const
{
if (m_runMode == sp.runMode)
return m_runControlCreator(sp, runConfiguration);
return 0;
}
static bool buildTypeAccepted(ToolMode toolMode, BuildConfiguration::BuildType buildType)
{
if (toolMode == AnyMode)
......@@ -155,9 +148,4 @@ void AnalyzerAction::startTool()
ProjectExplorerPlugin::runStartupProject(m_runMode);
}
void AnalyzerAction::setCustomToolStarter(const AnalyzerAction::ToolStarter &toolStarter)
{
m_customToolStarter = toolStarter;
}
} // namespace Analyzer
......@@ -86,6 +86,7 @@ public:
void setToolId(Core::Id id) { m_toolId = id; }
void setToolMode(ToolMode mode) { m_toolMode = mode; }
ProjectExplorer::RunMode runMode() const { return m_runMode; }
void setRunMode(ProjectExplorer::RunMode mode) { m_runMode = mode; }
bool isRunnable(QString *reason = 0) const;
......@@ -100,8 +101,7 @@ public:
/// Called each time the tool is launched.
typedef std::function<AnalyzerRunControl *(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)> RunControlCreator;
AnalyzerRunControl *tryCreateRunControl(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration) const;
RunControlCreator runControlCreator() const { return m_runControlCreator; }
void setRunControlCreator(const RunControlCreator &creator) { m_runControlCreator = creator; }
typedef std::function<bool()> ToolPreparer;
......@@ -112,7 +112,7 @@ public:
/// This is only used for setups not using the startup project.
typedef std::function<void()> ToolStarter;
void setCustomToolStarter(const ToolStarter &toolStarter);
void setCustomToolStarter(const ToolStarter &toolStarter) { m_customToolStarter = toolStarter; }
protected:
Core::Id m_menuGroup;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment