Analyzer: create a run control factory for all tools.

Having one factory per tool (or plugin) created some bugs:
 * analyzer project settings being created twice
 * per-project analyzer settings widget duplicated
Also, most of the code from the run control factory were copied.

Now, the Analyzer only creates one run control factory shared among all tools, and the IAnalyzerTool
has two new virtual method: canRun and createStartParameters. It simplify the code a bit, and
creating a new analyzer tool is easier (only two classes to subclass: IAnalyzerTool and IAnalyzerEngine).

Change-Id: I4e180846a26b74b2b77cb99bc97534d680a80a4d
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Nicolas Arnaud-Cormos
2011-12-27 22:41:31 +01:00
committed by hjk
parent 26ae954fae
commit 4a8432112a
21 changed files with 424 additions and 326 deletions

View File

@@ -60,6 +60,10 @@
#include <projectexplorer/project.h>
#include <projectexplorer/target.h>
#include <projectexplorer/session.h>
#include <projectexplorer/applicationrunconfiguration.h>
#include <remotelinux/remotelinuxrunconfiguration.h>
#include <remotelinux/linuxdeviceconfiguration.h>
#include <texteditor/itexteditor.h>
#include <coreplugin/coreconstants.h>
@@ -74,6 +78,8 @@
#include <coreplugin/actionmanager/actioncontainer.h>
#include <qt4projectmanager/qt4buildconfiguration.h>
#include <qt4projectmanager/qt-s60/s60devicedebugruncontrol.h>
#include <qt4projectmanager/qt-s60/s60devicerunconfiguration.h>
#include <qt4projectmanager/qt-s60/s60deployconfiguration.h>
#include <QtCore/QFile>
@@ -95,6 +101,8 @@ using namespace Analyzer::Constants;
using namespace QmlProfiler::Internal;
using namespace QmlJsDebugClient;
using namespace ProjectExplorer;
using namespace QmlProjectManager;
using namespace RemoteLinux;
class QmlProfilerTool::QmlProfilerToolPrivate
{
@@ -357,6 +365,68 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp
return engine;
}
bool QmlProfilerTool::canRun(RunConfiguration *runConfiguration, const QString &mode) const
{
Q_UNUSED(mode);
if (qobject_cast<QmlProjectRunConfiguration *>(runConfiguration)
|| qobject_cast<RemoteLinuxRunConfiguration *>(runConfiguration)
|| qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration)
|| qobject_cast<Qt4ProjectManager::S60DeviceRunConfiguration *>(runConfiguration))
return true;
return false;
}
AnalyzerStartParameters QmlProfilerTool::createStartParameters(RunConfiguration *runConfiguration, const QString &mode) const
{
Q_UNUSED(mode);
AnalyzerStartParameters sp;
sp.startMode = StartQml; // FIXME: The parameter struct is not needed/not used.
// FIXME: This is only used to communicate the connParams settings.
if (QmlProjectRunConfiguration *rc1 =
qobject_cast<QmlProjectRunConfiguration *>(runConfiguration)) {
// This is a "plain" .qmlproject.
sp.environment = rc1->environment();
sp.workingDirectory = rc1->workingDirectory();
sp.debuggee = rc1->observerPath();
sp.debuggeeArgs = rc1->viewerArguments();
sp.displayName = rc1->displayName();
sp.connParams.host = QLatin1String("localhost");
sp.connParams.port = rc1->qmlDebugServerPort();
} else if (LocalApplicationRunConfiguration *rc2 =
qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration)) {
sp.environment = rc2->environment();
sp.workingDirectory = rc2->workingDirectory();
sp.debuggee = rc2->executable();
sp.debuggeeArgs = rc2->commandLineArguments();
sp.displayName = rc2->displayName();
sp.connParams.host = QLatin1String("localhost");
sp.connParams.port = rc2->qmlDebugServerPort();
} else if (RemoteLinux::RemoteLinuxRunConfiguration *rc3 =
qobject_cast<RemoteLinux::RemoteLinuxRunConfiguration *>(runConfiguration)) {
sp.debuggee = rc3->remoteExecutableFilePath();
sp.debuggeeArgs = rc3->arguments();
sp.connParams = rc3->deviceConfig()->sshParameters();
sp.analyzerCmdPrefix = rc3->commandPrefix();
sp.displayName = rc3->displayName();
} else if (Qt4ProjectManager::S60DeviceRunConfiguration *rc4 =
qobject_cast<Qt4ProjectManager::S60DeviceRunConfiguration *>(runConfiguration)) {
Qt4ProjectManager::S60DeployConfiguration *deployConf =
qobject_cast<Qt4ProjectManager::S60DeployConfiguration *>(runConfiguration->target()->activeDeployConfiguration());
sp.debuggeeArgs = rc4->commandLineArguments();
sp.displayName = rc4->displayName();
sp.connParams.host = deployConf->deviceAddress();
sp.connParams.port = rc4->qmlDebugServerPort();
} else {
// What could that be?
QTC_ASSERT(false, return sp);
}
return sp;
}
QWidget *QmlProfilerTool::createWidgets()
{
QTC_ASSERT(!d->m_traceWindow, return 0);