forked from qt-creator/qt-creator
Analyzer: Remove one level of indirection when creating RunControls
Change-Id: I7029e2dbd3352549036da642fdbd926756a563cb Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
#include "analyzermanager.h"
|
#include "analyzermanager.h"
|
||||||
|
|
||||||
#include "analyzerplugin.h"
|
#include "analyzerplugin.h"
|
||||||
|
#include "analyzerstartparameters.h"
|
||||||
#include "ianalyzertool.h"
|
#include "ianalyzertool.h"
|
||||||
|
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
@@ -709,10 +710,9 @@ AnalyzerRunControl *AnalyzerManager::createRunControl(
|
|||||||
const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration)
|
const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration)
|
||||||
{
|
{
|
||||||
foreach (AnalyzerAction *action, d->m_actions) {
|
foreach (AnalyzerAction *action, d->m_actions) {
|
||||||
if (AnalyzerRunControl *rc = action->tryCreateRunControl(sp, runConfiguration))
|
if (action->runMode() == sp.runMode)
|
||||||
return rc;
|
return action->runControlCreator()(sp, runConfiguration);
|
||||||
}
|
}
|
||||||
QTC_CHECK(false);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -70,13 +70,6 @@ bool AnalyzerAction::isRunnable(QString *reason) const
|
|||||||
return ProjectExplorerPlugin::canRun(SessionManager::startupProject(), m_runMode, reason);
|
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)
|
static bool buildTypeAccepted(ToolMode toolMode, BuildConfiguration::BuildType buildType)
|
||||||
{
|
{
|
||||||
if (toolMode == AnyMode)
|
if (toolMode == AnyMode)
|
||||||
@@ -155,9 +148,4 @@ void AnalyzerAction::startTool()
|
|||||||
ProjectExplorerPlugin::runStartupProject(m_runMode);
|
ProjectExplorerPlugin::runStartupProject(m_runMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnalyzerAction::setCustomToolStarter(const AnalyzerAction::ToolStarter &toolStarter)
|
|
||||||
{
|
|
||||||
m_customToolStarter = toolStarter;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Analyzer
|
} // namespace Analyzer
|
||||||
|
@@ -86,6 +86,7 @@ public:
|
|||||||
void setToolId(Core::Id id) { m_toolId = id; }
|
void setToolId(Core::Id id) { m_toolId = id; }
|
||||||
void setToolMode(ToolMode mode) { m_toolMode = mode; }
|
void setToolMode(ToolMode mode) { m_toolMode = mode; }
|
||||||
|
|
||||||
|
ProjectExplorer::RunMode runMode() const { return m_runMode; }
|
||||||
void setRunMode(ProjectExplorer::RunMode mode) { m_runMode = mode; }
|
void setRunMode(ProjectExplorer::RunMode mode) { m_runMode = mode; }
|
||||||
bool isRunnable(QString *reason = 0) const;
|
bool isRunnable(QString *reason = 0) const;
|
||||||
|
|
||||||
@@ -100,8 +101,7 @@ public:
|
|||||||
/// Called each time the tool is launched.
|
/// Called each time the tool is launched.
|
||||||
typedef std::function<AnalyzerRunControl *(const AnalyzerStartParameters &sp,
|
typedef std::function<AnalyzerRunControl *(const AnalyzerStartParameters &sp,
|
||||||
ProjectExplorer::RunConfiguration *runConfiguration)> RunControlCreator;
|
ProjectExplorer::RunConfiguration *runConfiguration)> RunControlCreator;
|
||||||
AnalyzerRunControl *tryCreateRunControl(const AnalyzerStartParameters &sp,
|
RunControlCreator runControlCreator() const { return m_runControlCreator; }
|
||||||
ProjectExplorer::RunConfiguration *runConfiguration) const;
|
|
||||||
void setRunControlCreator(const RunControlCreator &creator) { m_runControlCreator = creator; }
|
void setRunControlCreator(const RunControlCreator &creator) { m_runControlCreator = creator; }
|
||||||
|
|
||||||
typedef std::function<bool()> ToolPreparer;
|
typedef std::function<bool()> ToolPreparer;
|
||||||
@@ -112,7 +112,7 @@ public:
|
|||||||
|
|
||||||
/// This is only used for setups not using the startup project.
|
/// This is only used for setups not using the startup project.
|
||||||
typedef std::function<void()> ToolStarter;
|
typedef std::function<void()> ToolStarter;
|
||||||
void setCustomToolStarter(const ToolStarter &toolStarter);
|
void setCustomToolStarter(const ToolStarter &toolStarter) { m_customToolStarter = toolStarter; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Core::Id m_menuGroup;
|
Core::Id m_menuGroup;
|
||||||
|
Reference in New Issue
Block a user