Analyzer: Move extensionInitialized() out of IAnalyzerTool

Change-Id: Idd0913ba798a04f65711591dee14cbb714440cbf
Reviewed-by: Aurindam Jana <aurindam.jana@digia.com>
This commit is contained in:
hjk
2013-08-08 11:55:54 +02:00
parent d15fb5a75c
commit 4ed17ade89
9 changed files with 52 additions and 57 deletions

View File

@@ -624,12 +624,6 @@ AnalyzerManager::~AnalyzerManager()
d = 0; d = 0;
} }
void AnalyzerManager::extensionsInitialized()
{
foreach (IAnalyzerTool *tool, d->m_tools)
tool->extensionsInitialized();
}
void AnalyzerManager::shutdown() void AnalyzerManager::shutdown()
{ {
if (d->m_currentAction) if (d->m_currentAction)

View File

@@ -63,7 +63,6 @@ public:
explicit AnalyzerManager(QObject *parent); explicit AnalyzerManager(QObject *parent);
~AnalyzerManager(); ~AnalyzerManager();
static void extensionsInitialized();
static void shutdown(); static void shutdown();
// Register a tool for a given start mode. // Register a tool for a given start mode.

View File

@@ -72,11 +72,6 @@ bool AnalyzerPlugin::initialize(const QStringList &arguments, QString *errorStri
return true; return true;
} }
void AnalyzerPlugin::extensionsInitialized()
{
AnalyzerManager::extensionsInitialized();
}
ExtensionSystem::IPlugin::ShutdownFlag AnalyzerPlugin::aboutToShutdown() ExtensionSystem::IPlugin::ShutdownFlag AnalyzerPlugin::aboutToShutdown()
{ {
AnalyzerManager::shutdown(); AnalyzerManager::shutdown();

View File

@@ -48,7 +48,7 @@ public:
virtual ~AnalyzerPlugin(); virtual ~AnalyzerPlugin();
bool initialize(const QStringList &arguments, QString *errorString); bool initialize(const QStringList &arguments, QString *errorString);
void extensionsInitialized(); void extensionsInitialized() {}
ShutdownFlag aboutToShutdown(); ShutdownFlag aboutToShutdown();
}; };

View File

@@ -86,9 +86,6 @@ public:
}; };
virtual ToolMode toolMode() const = 0; virtual ToolMode toolMode() const = 0;
/// This gets called after all analyzation tools where initialized.
virtual void extensionsInitialized() {}
/// Creates all widgets used by the tool. /// Creates all widgets used by the tool.
/// Returns a control widget which will be shown in the status bar when /// Returns a control widget which will be shown in the status bar when
/// this tool is selected. Must be non-zero. /// this tool is selected. Must be non-zero.

View File

@@ -51,16 +51,11 @@
#include <analyzerbase/analyzerutils.h> #include <analyzerbase/analyzerutils.h>
#include <analyzerbase/analyzerconstants.h> #include <analyzerbase/analyzerconstants.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <cplusplus/LookupContext.h> #include <cplusplus/LookupContext.h>
#include <cplusplus/Overview.h> #include <cplusplus/Overview.h>
#include <cppeditor/cppeditorconstants.h>
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
#include <texteditor/itexteditor.h> #include <texteditor/itexteditor.h>
@@ -207,7 +202,6 @@ public:
QAction *m_dumpAction; QAction *m_dumpAction;
QAction *m_resetAction; QAction *m_resetAction;
QAction *m_pauseAction; QAction *m_pauseAction;
QAction *m_showCostsOfFunctionAction;
QString m_toggleCollectFunction; QString m_toggleCollectFunction;
}; };
@@ -236,7 +230,6 @@ CallgrindToolPrivate::CallgrindToolPrivate(CallgrindTool *parent)
, m_dumpAction(0) , m_dumpAction(0)
, m_resetAction(0) , m_resetAction(0)
, m_pauseAction(0) , m_pauseAction(0)
, m_showCostsOfFunctionAction(0)
{ {
m_updateTimer->setInterval(200); m_updateTimer->setInterval(200);
m_updateTimer->setSingleShot(true); m_updateTimer->setSingleShot(true);
@@ -520,30 +513,6 @@ IAnalyzerTool::ToolMode CallgrindTool::toolMode() const
return ReleaseMode; return ReleaseMode;
} }
void CallgrindTool::extensionsInitialized()
{
Core::Context analyzerContext = Core::Context(Analyzer::Constants::C_ANALYZEMODE);
// check if there is a CppEditor context menu, if true, add our own context menu actions
if (Core::ActionContainer *editorContextMenu =
Core::ActionManager::actionContainer(CppEditor::Constants::M_CONTEXT)) {
QAction *action = 0;
Core::Command *cmd = 0;
editorContextMenu->addSeparator(analyzerContext);
action = new QAction(tr("Profile Costs of this Function and its Callees"), this);
action->setIcon(QIcon(QLatin1String(Analyzer::Constants::ANALYZER_CONTROL_START_ICON)));
connect(action, SIGNAL(triggered()), d, SLOT(handleShowCostsOfFunction()));
cmd = Core::ActionManager::registerAction(action, "Analyzer.Callgrind.ShowCostsOfFunction",
analyzerContext);
editorContextMenu->addAction(cmd);
cmd->setAttribute(Core::Command::CA_Hide);
cmd->setAttribute(Core::Command::CA_NonConfigurable);
d->m_showCostsOfFunctionAction = action;
}
}
AnalyzerRunControl *CallgrindTool::createRunControl(const AnalyzerStartParameters &sp, AnalyzerRunControl *CallgrindTool::createRunControl(const AnalyzerStartParameters &sp,
RunConfiguration *runConfiguration) RunConfiguration *runConfiguration)
{ {
@@ -595,6 +564,11 @@ void CallgrindTool::startTool(StartMode mode)
d->setBusyCursor(true); d->setBusyCursor(true);
} }
void CallgrindTool::handleShowCostsOfFunction()
{
d->handleShowCostsOfFunction();
}
QWidget *CallgrindTool::createWidgets() QWidget *CallgrindTool::createWidgets()
{ {
return d->createWidgets(); return d->createWidgets();

View File

@@ -48,14 +48,15 @@ public:
ProjectExplorer::RunMode runMode() const; ProjectExplorer::RunMode runMode() const;
ToolMode toolMode() const; ToolMode toolMode() const;
void extensionsInitialized();
Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp, Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration = 0); ProjectExplorer::RunConfiguration *runConfiguration = 0);
QWidget *createWidgets(); QWidget *createWidgets();
void startTool(Analyzer::StartMode mode); void startTool(Analyzer::StartMode mode);
public slots:
void handleShowCostsOfFunction();
private: private:
CallgrindToolPrivate *d; CallgrindToolPrivate *d;
}; };

View File

@@ -33,13 +33,20 @@
#include "callgrindtool.h" #include "callgrindtool.h"
#include "memchecktool.h" #include "memchecktool.h"
#include "valgrindruncontrolfactory.h" #include "valgrindruncontrolfactory.h"
#include "valgrindsettings.h"
#include <analyzerbase/analyzermanager.h> #include <analyzerbase/analyzermanager.h>
#include <analyzerbase/analyzersettings.h> #include <analyzerbase/analyzersettings.h>
#include <coreplugin/dialogs/ioptionspage.h> #include <coreplugin/dialogs/ioptionspage.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
#include <valgrind/valgrindsettings.h> #include <cppeditor/cppeditorconstants.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
@@ -95,8 +102,9 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
addAutoReleasedObject(new ValgrindOptionsPage()); addAutoReleasedObject(new ValgrindOptionsPage());
IAnalyzerTool *memcheckTool = new MemcheckTool(this); m_memcheckTool = new MemcheckTool(this);
IAnalyzerTool *callgrindTool = new CallgrindTool(this); m_callgrindTool = new CallgrindTool(this);
ValgrindAction *action = 0; ValgrindAction *action = 0;
QString callgrindToolTip = tr("Valgrind Function Profile uses the " QString callgrindToolTip = tr("Valgrind Function Profile uses the "
@@ -108,7 +116,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
if (!Utils::HostOsInfo::isWindowsHost()) { if (!Utils::HostOsInfo::isWindowsHost()) {
action = new ValgrindAction; action = new ValgrindAction;
action->setId("Memcheck.Local"); action->setId("Memcheck.Local");
action->setTool(memcheckTool); action->setTool(m_memcheckTool);
action->setText(tr("Valgrind Memory Analyzer")); action->setText(tr("Valgrind Memory Analyzer"));
action->setToolTip(memcheckToolTip); action->setToolTip(memcheckToolTip);
action->setMenuGroup(Constants::G_ANALYZER_TOOLS); action->setMenuGroup(Constants::G_ANALYZER_TOOLS);
@@ -118,7 +126,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
action = new ValgrindAction; action = new ValgrindAction;
action->setId("Callgrind.Local"); action->setId("Callgrind.Local");
action->setTool(callgrindTool); action->setTool(m_callgrindTool);
action->setText(tr("Valgrind Function Profiler")); action->setText(tr("Valgrind Function Profiler"));
action->setToolTip(callgrindToolTip); action->setToolTip(callgrindToolTip);
action->setMenuGroup(Constants::G_ANALYZER_TOOLS); action->setMenuGroup(Constants::G_ANALYZER_TOOLS);
@@ -129,7 +137,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
action = new ValgrindAction; action = new ValgrindAction;
action->setId("Memcheck.Remote"); action->setId("Memcheck.Remote");
action->setTool(memcheckTool); action->setTool(m_memcheckTool);
action->setText(tr("Valgrind Memory Analyzer (Remote)")); action->setText(tr("Valgrind Memory Analyzer (Remote)"));
action->setToolTip(memcheckToolTip); action->setToolTip(memcheckToolTip);
action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS); action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS);
@@ -138,7 +146,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
action = new ValgrindAction; action = new ValgrindAction;
action->setId("Callgrind.Remote"); action->setId("Callgrind.Remote");
action->setTool(callgrindTool); action->setTool(m_callgrindTool);
action->setText(tr("Valgrind Function Profiler (Remote)")); action->setText(tr("Valgrind Function Profiler (Remote)"));
action->setToolTip(callgrindToolTip); action->setToolTip(callgrindToolTip);
action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS); action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS);
@@ -155,6 +163,27 @@ ValgrindGlobalSettings *ValgrindPlugin::globalSettings()
return theGlobalSettings; return theGlobalSettings;
} }
void ValgrindPlugin::extensionsInitialized()
{
using namespace Core;
// If there is a CppEditor context menu add our own context menu actions.
if (ActionContainer *editorContextMenu =
ActionManager::actionContainer(CppEditor::Constants::M_CONTEXT)) {
Context analyzerContext = Context(Analyzer::Constants::C_ANALYZEMODE);
editorContextMenu->addSeparator(analyzerContext);
QAction *action = new QAction(tr("Profile Costs of this Function and its Callees"), this);
action->setIcon(QIcon(QLatin1String(Analyzer::Constants::ANALYZER_CONTROL_START_ICON)));
connect(action, SIGNAL(triggered()), m_callgrindTool, SLOT(handleShowCostsOfFunction()));
Command *cmd = ActionManager::registerAction(action, "Analyzer.Callgrind.ShowCostsOfFunction",
analyzerContext);
editorContextMenu->addAction(cmd);
cmd->setAttribute(Command::CA_Hide);
cmd->setAttribute(Command::CA_NonConfigurable);
}
}
} // namespace Internal } // namespace Internal
} // namespace Valgrind } // namespace Valgrind

View File

@@ -38,6 +38,8 @@ namespace Valgrind {
namespace Internal { namespace Internal {
class ValgrindGlobalSettings; class ValgrindGlobalSettings;
class MemcheckTool;
class CallgrindTool;
class ValgrindPlugin : public ExtensionSystem::IPlugin class ValgrindPlugin : public ExtensionSystem::IPlugin
{ {
@@ -49,9 +51,13 @@ public:
~ValgrindPlugin(); ~ValgrindPlugin();
bool initialize(const QStringList &arguments, QString *errorString); bool initialize(const QStringList &arguments, QString *errorString);
void extensionsInitialized() {} void extensionsInitialized();
static ValgrindGlobalSettings *globalSettings(); static ValgrindGlobalSettings *globalSettings();
private:
MemcheckTool *m_memcheckTool;
CallgrindTool *m_callgrindTool;
}; };
} // namespace Internal } // namespace Internal