Commit 213cb601 authored by hjk's avatar hjk

Analyzer: Use AnalyzerManager for run control creation

Less code.

Change-Id: Ic26d291ada7efd05899623738d89c52b4175716c
Reviewed-by: default avatarAurindam Jana <aurindam.jana@digia.com>
parent c1919f0a
......@@ -867,11 +867,17 @@ void AnalyzerManager::handleToolFinished()
m_instance->d->handleToolFinished();
}
IAnalyzerTool *AnalyzerManager::toolFromRunMode(RunMode runMode)
AnalyzerRunControl *AnalyzerManager::createRunControl(
const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode runMode,
QString *errorMessage)
{
foreach (IAnalyzerTool *tool, m_instance->d->m_tools)
if (tool->runMode() == runMode)
return tool;
return tool->createRunControl(sp, runConfiguration);
if (errorMessage)
*errorMessage = tr("No analyzer tool selected.");
return 0;
}
......
......@@ -43,16 +43,17 @@ class QDockWidget;
class QAction;
QT_END_NAMESPACE
namespace Utils {
class FancyMainWindow;
}
namespace Utils { class FancyMainWindow; }
namespace ProjectExplorer { class RunConfiguration; }
namespace Analyzer {
typedef QList<StartMode> StartModes;
class IAnalyzerTool;
class AnalyzerRunControl;
class AnalyzerManagerPrivate;
class AnalyzerStartParameters;
// FIXME: Merge with AnalyzerPlugin.
......@@ -69,7 +70,6 @@ public:
// Register a tool and initialize it.
static void addTool(IAnalyzerTool *tool, const StartModes &mode);
static IAnalyzerTool *toolFromRunMode(ProjectExplorer::RunMode runMode);
// Dockwidgets are registered to the main window.
static QDockWidget *createDockWidget(IAnalyzerTool *tool, const QString &title,
......@@ -97,6 +97,10 @@ public:
static void handleToolFinished();
static QAction *stopAction();
static AnalyzerRunControl *createRunControl(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration, ProjectExplorer::RunMode runMode,
QString *errorMessage);
private:
friend class AnalyzerManagerPrivate;
AnalyzerManagerPrivate *const d;
......
......@@ -53,16 +53,9 @@ namespace Internal {
RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfiguration *runConfig,
RunMode runMode, QString *errorMessage)
{
IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(runMode);
if (!tool) {
if (errorMessage)
*errorMessage = tr("No analyzer tool selected.");
return 0;
}
Target *target = runConfig->target();
AnalyzerStartParameters params;
params.runMode = runMode;
Target *target = runConfig->target();
params.displayName = AndroidManager::packageName(target);
params.sysroot = SysRootKitInformation::sysRoot(target->kit()).toString();
// TODO: Not sure if these are the right paths.
......@@ -75,7 +68,8 @@ RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfigurati
params.startMode = StartQmlRemote;
}
AnalyzerRunControl *analyzerRunControl = tool->createRunControl(params, runConfig);
AnalyzerRunControl *analyzerRunControl =
AnalyzerManager::createRunControl(params, runConfig, runMode, errorMessage);
(void) new AndroidAnalyzeSupport(runConfig, analyzerRunControl);
return analyzerRunControl;
}
......
......@@ -48,8 +48,7 @@ class AndroidAnalyzeSupport : public AndroidRunSupport
public:
static ProjectExplorer::RunControl *createAnalyzeRunControl(AndroidRunConfiguration *runConfig,
ProjectExplorer::RunMode runMode,
QString *errorMessage);
ProjectExplorer::RunMode runMode, QString *errorMessage);
AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig,
Analyzer::AnalyzerRunControl *runControl);
......
......@@ -117,13 +117,6 @@ static AnalyzerStartParameters createQmlProfilerStartParameters(RunConfiguration
RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage)
{
IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode);
if (!tool) {
if (errorMessage)
*errorMessage = tr("No analyzer tool selected"); // never happens
return 0;
}
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
AnalyzerStartParameters sp = createQmlProfilerStartParameters(runConfiguration);
......@@ -133,7 +126,7 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat
const IDevice::ConstPtr device = DeviceKitInformation::device(runConfiguration->target()->kit());
QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0);
AnalyzerRunControl *rc = tool->createRunControl(sp, runConfiguration);
AnalyzerRunControl *rc = AnalyzerManager::createRunControl(sp, runConfiguration, mode, errorMessage);
QmlProfilerRunControl *engine = qobject_cast<QmlProfilerRunControl *>(rc);
if (!engine) {
delete rc;
......
......@@ -189,15 +189,8 @@ RunControl *QnxRunControlFactory::create(RunConfiguration *runConfig, RunMode mo
return runControl;
}
case QmlProfilerRunMode: {
IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode);
if (!tool) {
if (errorMessage)
*errorMessage = tr("No analyzer tool selected.");
return 0;
}
const AnalyzerStartParameters params = createAnalyzerStartParameters(rc, mode);
AnalyzerRunControl *runControl = tool->createRunControl(params, runConfig);
//AnalyzerRunControl * const runControl = new AnalyzerRunControl(tool, params, runConfig);
AnalyzerRunControl *runControl = AnalyzerManager::createRunControl(params, runConfig, mode, errorMessage);
QnxAnalyzeSupport * const analyzeSupport = new QnxAnalyzeSupport(rc, runControl);
connect(runControl, SIGNAL(finished()), analyzeSupport, SLOT(handleProfilingFinished()));
return runControl;
......
......@@ -107,18 +107,8 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Ru
return runControl;
}
case QmlProfilerRunMode: {
IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode);
if (!tool) {
if (errorMessage)
*errorMessage = tr("No analyzer tool selected.");
return 0;
}
AnalyzerStartParameters params = RemoteLinuxAnalyzeSupport::startParameters(rc, mode);
//AnalyzerRunControl * const runControl = new AnalyzerRunControl(tool, params, runConfig);
AnalyzerRunControl *runControl = tool->createRunControl(params, runConfig);
//m_engine->setRunControl(this);
AnalyzerRunControl *runControl = AnalyzerManager::createRunControl(params, runConfig, mode, errorMessage);
RemoteLinuxAnalyzeSupport * const analyzeSupport =
new RemoteLinuxAnalyzeSupport(rc, runControl, mode);
connect(runControl, SIGNAL(finished()), analyzeSupport, SLOT(handleProfilingFinished()));
......
......@@ -106,17 +106,8 @@ static AnalyzerStartParameters createValgrindStartParameters(RunConfiguration *r
RunControl *ValgrindRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage)
{
IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode);
if (!tool) {
if (errorMessage)
*errorMessage = tr("No analyzer tool selected"); // never happens
return 0;
}
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
AnalyzerStartParameters sp = createValgrindStartParameters(runConfiguration);
return tool->createRunControl(sp, runConfiguration);
return AnalyzerManager::createRunControl(sp, runConfiguration, mode, errorMessage);
}
IRunConfigurationAspect *ValgrindRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc)
......
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