<commit_before>#include <QSettings>
#include <QTranslator>

#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/project.h>
#include <projectexplorer/target.h>
#include <projectexplorer/task.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/buildsteplist.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/buildmanager.h>
#include <coreplugin/icore.h>

#include <QtPlugin>

#include "QtcPaneEncodePlugin.h"
#include "OptionsPage.h"
#include "Utils.h"
#include "Constants.h"

using namespace QtcPaneEncode::Internal;
using namespace QtcPaneEncode::Constants;

using namespace Core;
using namespace ProjectExplorer;
using namespace ExtensionSystem;

namespace {
  const QString appOutputPaneClassName =
      QLatin1String("ProjectExplorer::Internal::AppOutputPane");
}

QtcPaneEncodePlugin::QtcPaneEncodePlugin():
  IPlugin()
{
  // Create your members
}

QtcPaneEncodePlugin::~QtcPaneEncodePlugin() {
  // Unregister objects from the plugin manager's object pool
  // Delete members
}

bool QtcPaneEncodePlugin::initialize(const QStringList &arguments, QString *errorString) {
  // Register objects in the plugin manager's object pool
  // Load settings
  // Add actions to menus
  // Connect to other plugins' signals
  // In the initialize function, a plugin can be sure that the plugins it
  // depends on have initialized their members.

  Q_UNUSED(arguments)
  Q_UNUSED(errorString)

  initLanguage();
  updateSettings();

  OptionsPage *optionsPage = new OptionsPage;
  connect(optionsPage, SIGNAL(settingsChanged()), SLOT(updateSettings()));
  addAutoReleasedObject(optionsPage);

  return true;
}

void QtcPaneEncodePlugin::initLanguage() {
  const QString& language = Core::ICore::userInterfaceLanguage();
  if (!language.isEmpty()) {
    QStringList paths;
    paths << ICore::resourcePath () << ICore::userResourcePath();
    const QString& trFile = QLatin1String ("QtcPaneEncode_") + language;
    QTranslator* translator = new QTranslator (this);
    foreach (const QString& path, paths) {
      if (translator->load (trFile, path + QLatin1String ("/translations"))) {
        qApp->installTranslator (translator);
        break;
      }
    }
  }
}

void QtcPaneEncodePlugin::updateSettings() {
  Q_ASSERT(Core::ICore::settings() != NULL);
  QSettings& settings = *(Core::ICore::settings());
  settings.beginGroup(SETTINGS_GROUP);

  if(settings.value(SETTINGS_BUILD_ENABLED, false).toBool()) {
    buildEncoding_ = settings.value(SETTINGS_BUILD_ENCODING, AUTO_ENCODING).toByteArray();
  }
  else {
    buildEncoding_.clear();
  }

  if(settings.value(SETTINGS_APP_ENABLED, false).toBool()) {
    appEncoding_ = settings.value(SETTINGS_APP_ENCODING, AUTO_ENCODING).toByteArray();
  }
  else {
    appEncoding_.clear();
  }

  settings.endGroup();
}

void QtcPaneEncodePlugin::extensionsInitialized() {
  // Retrieve objects from the plugin manager's object pool
  // In the extensionsInitialized function, a plugin can be sure that all
  // plugins that depend on it are completely initialized.


  // Compiler output
  connect(BuildManager::instance(), SIGNAL(buildStateChanged(ProjectExplorer::Project*)),
          this, SLOT(handleBuild(ProjectExplorer::Project*)));
  connect(this, SIGNAL(newOutput(QString,ProjectExplorer::BuildStep::OutputFormat,ProjectExplorer::BuildStep::OutputNewlineSetting)),
          BuildManager::instance(), SLOT(addToOutputWindow(QString,ProjectExplorer::BuildStep::OutputFormat,ProjectExplorer::BuildStep::OutputNewlineSetting)));
  connect(this, SIGNAL(newTask(ProjectExplorer::Task)),
          BuildManager::instance(), SLOT(addToTaskWindow(ProjectExplorer::Task)));

  // Run control output
  QObject *appOutputPane = PluginManager::getObjectByClassName(appOutputPaneClassName);
  if(appOutputPane != NULL) {
    connect(ProjectExplorerPlugin::instance(), SIGNAL(runControlStarted(ProjectExplorer::RunControl *)),
             this, SLOT(handleRunStart(ProjectExplorer::RunControl *)));
    connect(this, SIGNAL(newMessage(ProjectExplorer::RunControl*,QString,Utils::OutputFormat)),
            appOutputPane, SLOT(appendMessage(ProjectExplorer::RunControl*,QString,Utils::OutputFormat)));
  }
  else {
    qCritical() << "Failed to find appOutputPane";
  }
}

ExtensionSystem::IPlugin::ShutdownFlag QtcPaneEncodePlugin::aboutToShutdown() {
  // Save settings
  // Disconnect from signals that are not needed during shutdown
  // Hide UI(if you add UI that is not in the main window directly)
  this->disconnect();
  return SynchronousShutdown;
}

void QtcPaneEncodePlugin::handleBuild(ProjectExplorer::Project *project) {
  if(!BuildManager::isBuilding()) {
    return;
  }
  Target *target = project->activeTarget();
  if(target == NULL) {
    return;
  }
  BuildConfiguration* buildConfiguration = target->activeBuildConfiguration();
  if(buildConfiguration == NULL) {
    return;
  }
  QList<Core::Id> stepsIds = buildConfiguration->knownStepLists();
  foreach(const Core::Id &id, stepsIds) {
    BuildStepList *steps = buildConfiguration->stepList(id);
    if(steps == NULL) {
      continue;
    }<commit_msg>Connecting to correct build steps<commit_after>#include <QSettings>
#include <QTranslator>

#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/project.h>
#include <projectexplorer/target.h>
#include <projectexplorer/task.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/buildsteplist.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/buildmanager.h>
#include <coreplugin/icore.h>

#include <QtPlugin>

#include "QtcPaneEncodePlugin.h"
#include "OptionsPage.h"
#include "Utils.h"
#include "Constants.h"

using namespace QtcPaneEncode::Internal;
using namespace QtcPaneEncode::Constants;

using namespace Core;
using namespace ProjectExplorer;
using namespace ExtensionSystem;

namespace {
  const QString appOutputPaneClassName =
      QLatin1String("ProjectExplorer::Internal::AppOutputPane");
}

QtcPaneEncodePlugin::QtcPaneEncodePlugin():
  IPlugin()
{
  // Create your members
}

QtcPaneEncodePlugin::~QtcPaneEncodePlugin() {
  // Unregister objects from the plugin manager's object pool
  // Delete members
}

bool QtcPaneEncodePlugin::initialize(const QStringList &arguments, QString *errorString) {
  // Register objects in the plugin manager's object pool
  // Load settings
  // Add actions to menus
  // Connect to other plugins' signals
  // In the initialize function, a plugin can be sure that the plugins it
  // depends on have initialized their members.

  Q_UNUSED(arguments)
  Q_UNUSED(errorString)

  initLanguage();
  updateSettings();

  OptionsPage *optionsPage = new OptionsPage;
  connect(optionsPage, SIGNAL(settingsChanged()), SLOT(updateSettings()));
  addAutoReleasedObject(optionsPage);

  return true;
}

void QtcPaneEncodePlugin::initLanguage() {
  const QString& language = Core::ICore::userInterfaceLanguage();
  if (!language.isEmpty()) {
    QStringList paths;
    paths << ICore::resourcePath () << ICore::userResourcePath();
    const QString& trFile = QLatin1String ("QtcPaneEncode_") + language;
    QTranslator* translator = new QTranslator (this);
    foreach (const QString& path, paths) {
      if (translator->load (trFile, path + QLatin1String ("/translations"))) {
        qApp->installTranslator (translator);
        break;
      }
    }
  }
}

void QtcPaneEncodePlugin::updateSettings() {
  Q_ASSERT(Core::ICore::settings() != NULL);
  QSettings& settings = *(Core::ICore::settings());
  settings.beginGroup(SETTINGS_GROUP);

  if(settings.value(SETTINGS_BUILD_ENABLED, false).toBool()) {
    buildEncoding_ = settings.value(SETTINGS_BUILD_ENCODING, AUTO_ENCODING).toByteArray();
  }
  else {
    buildEncoding_.clear();
  }

  if(settings.value(SETTINGS_APP_ENABLED, false).toBool()) {
    appEncoding_ = settings.value(SETTINGS_APP_ENCODING, AUTO_ENCODING).toByteArray();
  }
  else {
    appEncoding_.clear();
  }

  settings.endGroup();
}

void QtcPaneEncodePlugin::extensionsInitialized() {
  // Retrieve objects from the plugin manager's object pool
  // In the extensionsInitialized function, a plugin can be sure that all
  // plugins that depend on it are completely initialized.


  // Compiler output
  connect(BuildManager::instance(), SIGNAL(buildStateChanged(ProjectExplorer::Project*)),
          this, SLOT(handleBuild(ProjectExplorer::Project*)));
  connect(this, SIGNAL(newOutput(QString,ProjectExplorer::BuildStep::OutputFormat,ProjectExplorer::BuildStep::OutputNewlineSetting)),
          BuildManager::instance(), SLOT(addToOutputWindow(QString,ProjectExplorer::BuildStep::OutputFormat,ProjectExplorer::BuildStep::OutputNewlineSetting)));
  connect(this, SIGNAL(newTask(ProjectExplorer::Task)),
          BuildManager::instance(), SLOT(addToTaskWindow(ProjectExplorer::Task)));

  // Run control output
  QObject *appOutputPane = PluginManager::getObjectByClassName(appOutputPaneClassName);
  if(appOutputPane != NULL) {
    connect(ProjectExplorerPlugin::instance(), SIGNAL(runControlStarted(ProjectExplorer::RunControl *)),
             this, SLOT(handleRunStart(ProjectExplorer::RunControl *)));
    connect(this, SIGNAL(newMessage(ProjectExplorer::RunControl*,QString,Utils::OutputFormat)),
            appOutputPane, SLOT(appendMessage(ProjectExplorer::RunControl*,QString,Utils::OutputFormat)));
  }
  else {
    qCritical() << "Failed to find appOutputPane";
  }
}

ExtensionSystem::IPlugin::ShutdownFlag QtcPaneEncodePlugin::aboutToShutdown() {
  // Save settings
  // Disconnect from signals that are not needed during shutdown
  // Hide UI(if you add UI that is not in the main window directly)
  this->disconnect();
  return SynchronousShutdown;
}

void QtcPaneEncodePlugin::handleBuild(ProjectExplorer::Project *project) {
  if(!BuildManager::isBuilding()) {
    return;
  }
  const Target *buildingTarget = NULL;
  foreach(Target* target, project->targets ()) {
    if (BuildManager::isBuilding (target)) {
      buildingTarget = target;
      break;
    }
  }
  if(buildingTarget == NULL) {
    return;
  }

  BuildConfiguration* buildingConfiguration = NULL;
  foreach(BuildConfiguration* config, buildingTarget->buildConfigurations ()) {
    if (BuildManager::isBuilding (config)) {
      buildingConfiguration = config;
      break;
    }
  }
  if(buildingConfiguration == NULL) {
    return;
  }

  QList<Core::Id> stepsIds = buildingConfiguration->knownStepLists();
  foreach(const Core::Id &id, stepsIds) {
    BuildStepList *steps = buildingConfiguration->stepList(id);
    if(steps == NULL) {
      continue;
    }
{'fraction_non_alphanumeric': 0.1193326420963333, 'fraction_numerical': 0.0005655575454802526, 'mean_word_length': 5.33054892601432, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 43, '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': '3800463', 'n_tokens_mistral': 3139, 'n_tokens_neox': 3054, 'n_words': 645}