<commit_before>#include "visualDebuggerPlugin.h"

#include <QtGui/QApplication>

Q_EXPORT_PLUGIN2(visualDebugger, qReal::visualDebugger::VisualDebuggerPlugin)

using namespace qReal;
using namespace visualDebugger;
using namespace utils;

QString const blockDiagram = "BlockDiagram";

VisualDebuggerPlugin::VisualDebuggerPlugin()
		: mVisualDebugger(NULL),
		mDebuggerConnector(NULL),
		mErrorReporter(NULL),
		mWatchListWindow(NULL),
		mParser(NULL),
		mPreferencesPage(new VisualDebuggerPreferencesPage())
{
	mAppTranslator.load(":/visualDebugSupport_" + QLocale::system().name());
	QApplication::installTranslator(&mAppTranslator);
}

VisualDebuggerPlugin::~VisualDebuggerPlugin()
{
}

void VisualDebuggerPlugin::init(PluginConfigurator const &configurator)
{
	mErrorReporter = configurator.mainWindowInterpretersInterface().errorReporter();
	mParser = new BlockParser(mErrorReporter);

	mVisualDebugger = new VisualDebugger(
			configurator.logicalModelApi(),
			configurator.graphicalModelApi(),
			configurator.mainWindowInterpretersInterface(),
			mParser
	);

	mDebuggerConnector = new DebuggerConnector(this);
}

QPair<QString, PreferencesPage *> VisualDebuggerPlugin::preferencesPage()
{
	return qMakePair(tr("Block Diagram Debug"), static_cast<PreferencesPage*>(mPreferencesPage));
}

QList<qReal::ActionInfo> VisualDebuggerPlugin::actions()
{
	mVisualDebugMenu = new QMenu(tr("Visual debug"));
	ActionInfo visualDebugMenuInfo(mVisualDebugMenu, "tools");

	mDebugAction = new QAction(tr("Interpret (automatic)"), NULL);
	connect(mDebugAction, SIGNAL(triggered()), this, SLOT(debug()));
	mVisualDebugMenu->addAction(mDebugAction);

	mDebugSingleStepAction = new QAction(tr("Interpret (one step)"), NULL);
	connect(mDebugSingleStepAction, SIGNAL(triggered()), this, SLOT(debugSingleStep()));
	mVisualDebugMenu->addAction(mDebugSingleStepAction);

	mWatchListAction = new QAction(tr("Show watch list"), NULL);
	connect(mWatchListAction, SIGNAL(triggered()), this, SLOT(showWatchList()));
	mVisualDebugMenu->addAction(mWatchListAction);


	mVisualDebugWithGdbMenu = new QMenu(tr("Visual debug (with gdb)"));
	ActionInfo visualDebugWithGdbMenuInfo(mVisualDebugWithGdbMenu, "tools");

	mGenerateAndBuildAction = new QAction(tr("Generate and build"), NULL);
	connect(mGenerateAndBuildAction, SIGNAL(triggered()), this, SLOT(generateAndBuild()));
	mVisualDebugWithGdbMenu->addAction(mGenerateAndBuildAction);

	mStartDebuggerAction = new QAction(tr("Start debugger (gdb)"), NULL);
	connect(mStartDebuggerAction, SIGNAL(triggered()), this, SLOT(startDebugger()));
	mVisualDebugWithGdbMenu->addAction(mStartDebuggerAction);

	mConfigureAction = new QAction(tr("Configure"), NULL);
	connect(mConfigureAction, SIGNAL(triggered()), this, SLOT(configureDebugger()));
	mVisualDebugWithGdbMenu->addAction(mConfigureAction);

	mSetBreakpointsAction = new QAction(tr("Set breakpoints on each element"), NULL);
	connect(mSetBreakpointsAction, SIGNAL(triggered()), this, SLOT(placeBreakpointsInDebugger()));
	mVisualDebugWithGdbMenu->addAction(mSetBreakpointsAction);

	mBreakMainAction = new QAction(tr("Set breakpoint at start"), NULL);
	connect(mBreakMainAction, SIGNAL(triggered()), this, SLOT(setBreakpointAtStart()));
	mVisualDebugWithGdbMenu->addAction(mBreakMainAction);

	mRunAction = new QAction(tr("run"), NULL);
	connect(mRunAction, SIGNAL(triggered()), this, SLOT(runProgramWithDebugger()));
	mVisualDebugWithGdbMenu->addAction(mRunAction);

	mNextAction = new QAction(tr("next"), NULL);
	connect(mNextAction, SIGNAL(triggered()), this, SLOT(goToNextInstruction()));
	mVisualDebugWithGdbMenu->addAction(mNextAction);

	mContAction = new QAction(tr("cont"), NULL);
	connect(mContAction, SIGNAL(triggered()), this, SLOT(goToNextBreakpoint()));
	mVisualDebugWithGdbMenu->addAction(mContAction);

	mKillAction = new QAction(tr("kill"), NULL);
	connect(mKillAction, SIGNAL(triggered()), this, SLOT(killProgramWithDebugger()));
	mVisualDebugWithGdbMenu->addAction(mKillAction);

	mStartDebuggingAction = new QAction(tr("Start debug (automatic)"), NULL);
	connect(mStartDebuggingAction, SIGNAL(triggered()), this, SLOT(startDebugging()));
	mVisualDebugWithGdbMenu->addAction(mStartDebuggingAction);

	mCloseAllAction = new QAction(tr("Cancel debug"), NULL);<commit_msg>fixes #400<commit_after>#include "visualDebuggerPlugin.h"

#include <QtGui/QApplication>

Q_EXPORT_PLUGIN2(visualDebugger, qReal::visualDebugger::VisualDebuggerPlugin)

using namespace qReal;
using namespace visualDebugger;
using namespace utils;

QString const blockDiagram = "BlockDiagram";

VisualDebuggerPlugin::VisualDebuggerPlugin()
		: mVisualDebugger(NULL),
		mDebuggerConnector(NULL),
		mErrorReporter(NULL),
		mWatchListWindow(NULL),
		mParser(NULL),
		mPreferencesPage(new VisualDebuggerPreferencesPage())
{
	mAppTranslator.load(":/visualDebugSupport_" + QLocale::system().name());
	QApplication::installTranslator(&mAppTranslator);
}

VisualDebuggerPlugin::~VisualDebuggerPlugin()
{
}

void VisualDebuggerPlugin::init(PluginConfigurator const &configurator)
{
	mErrorReporter = configurator.mainWindowInterpretersInterface().errorReporter();
	mParser = new BlockParser(mErrorReporter);

	mVisualDebugger = new VisualDebugger(
			configurator.logicalModelApi(),
			configurator.graphicalModelApi(),
			configurator.mainWindowInterpretersInterface(),
			mParser
	);

	mDebuggerConnector = new DebuggerConnector(this);
}

QPair<QString, PreferencesPage *> VisualDebuggerPlugin::preferencesPage()
{
	return qMakePair(tr("Block Diagram Debug"), static_cast<PreferencesPage*>(mPreferencesPage));
}

QList<qReal::ActionInfo> VisualDebuggerPlugin::actions()
{
	mVisualDebugMenu = new QMenu(tr("Visual debug"));
	ActionInfo visualDebugMenuInfo(mVisualDebugMenu, "tools");

	mDebugAction = new QAction(tr("Interpret (automatic)"), NULL);
	mDebugAction->setShortcut(QKeySequence(Qt::Key_F5));
	connect(mDebugAction, SIGNAL(triggered()), this, SLOT(debug()));
	mVisualDebugMenu->addAction(mDebugAction);

	mDebugSingleStepAction = new QAction(tr("Interpret (one step)"), NULL);
	mDebugSingleStepAction->setShortcut(QKeySequence(Qt::Key_F6));
	connect(mDebugSingleStepAction, SIGNAL(triggered()), this, SLOT(debugSingleStep()));
	mVisualDebugMenu->addAction(mDebugSingleStepAction);

	mWatchListAction = new QAction(tr("Show watch list"), NULL);
	mWatchListAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W));
	connect(mWatchListAction, SIGNAL(triggered()), this, SLOT(showWatchList()));
	mVisualDebugMenu->addAction(mWatchListAction);


	mVisualDebugWithGdbMenu = new QMenu(tr("Visual debug (with gdb)"));
	ActionInfo visualDebugWithGdbMenuInfo(mVisualDebugWithGdbMenu, "tools");

	mGenerateAndBuildAction = new QAction(tr("Generate and build"), NULL);
	mGenerateAndBuildAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F5));
	connect(mGenerateAndBuildAction, SIGNAL(triggered()), this, SLOT(generateAndBuild()));
	mVisualDebugWithGdbMenu->addAction(mGenerateAndBuildAction);

	mStartDebuggerAction = new QAction(tr("Start debugger (gdb)"), NULL);
	mStartDebuggerAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F6));
	connect(mStartDebuggerAction, SIGNAL(triggered()), this, SLOT(startDebugger()));
	mVisualDebugWithGdbMenu->addAction(mStartDebuggerAction);

	mConfigureAction = new QAction(tr("Configure"), NULL);
	mConfigureAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_F6));
	connect(mConfigureAction, SIGNAL(triggered()), this, SLOT(configureDebugger()));
	mVisualDebugWithGdbMenu->addAction(mConfigureAction);

	mBreakMainAction = new QAction(tr("Set breakpoint at start"), NULL);
	mBreakMainAction->setShortcut(QKeySequence(Qt::Key_F9));
	connect(mBreakMainAction, SIGNAL(triggered()), this, SLOT(setBreakpointAtStart()));
	mVisualDebugWithGdbMenu->addAction(mBreakMainAction);
	
	mSetBreakpointsAction = new QAction(tr("Set breakpoints on each element"), NULL);
	mSetBreakpointsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F9));
	connect(mSetBreakpointsAction, SIGNAL(triggered()), this, SLOT(placeBreakpointsInDebugger()));
	mVisualDebugWithGdbMenu->addAction(mSetBreakpointsAction);

	mRunAction = new QAction(tr("run"), NULL);
	mRunAction->setShortcut(QKeySequence(Qt::Key_F8));
	connect(mRunAction, SIGNAL(triggered()), this, SLOT(runProgramWithDebugger()));
	mVisualDebugWithGdbMenu->addAction(mRunAction);

	mNextAction = new QAction(tr("next"), NULL);
	mNextAction->setShortcut(QKeySequence(Qt::Key_F10));
	connect(mNextAction, SIGNAL(triggered()), this, SLOT(goToNextInstruction()));
	mVisualDebugWithGdbMenu->addAction(mNextAction);

	mContAction = new QAction(tr("cont"), NULL);
	mContAction->setShortcut(QKeySequence(Qt::Key_F11));
	connect(mContAction, SIGNAL(triggered()), this, SLOT(goToNextBreakpoint()));
	mVisualDebugWithGdbMenu->addAction(mContAction);

	mKillAction = new QAction(tr("kill"), NULL);
	mKillAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_K));
	connect(mKillAction, SIGNAL(triggered()), this, SLOT(killProgramWithDebugger()));
	mVisualDebugWithGdbMenu->addAction(mKillAction);

	mStartDebuggingAction = new QAction(tr("Start debug (automatic)"), NULL);
	mStartDebuggingAction->setShortcut(QKeySequence(Qt::Key_F7));
	connect(mStartDebuggingAction, SIGNAL(triggered()), this, SLOT(startDebugging()));
	mVisualDebugWithGdbMenu->addAction(mStartDebuggingAction);

	mCloseAllAction = new QAction(tr("Cancel debug"), NULL);
	mCloseAllAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F12));
{'fraction_non_alphanumeric': 0.13516378670624404, 'fraction_numerical': 0.00212021626205873, 'mean_word_length': 10.632552404438965, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '828239', 'n_tokens_mistral': 3040, 'n_tokens_neox': 2985, 'n_words': 454}