Commit e49ccd07 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

Beautifier: Minor cleanup

* Use initializer list and Utils::transform
* Remove unneeded override

Change-Id: I36ff9b9900fa6169ed1529bbbbdba13075353332
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
parent 6b0d9f70
...@@ -201,9 +201,11 @@ bool BeautifierPlugin::initialize(const QStringList &arguments, QString *errorSt ...@@ -201,9 +201,11 @@ bool BeautifierPlugin::initialize(const QStringList &arguments, QString *errorSt
void BeautifierPlugin::extensionsInitialized() void BeautifierPlugin::extensionsInitialized()
{ {
m_tools << new ArtisticStyle::ArtisticStyle(this); m_tools = {
m_tools << new ClangFormat::ClangFormat(this); new ArtisticStyle::ArtisticStyle(this),
m_tools << new Uncrustify::Uncrustify(this); new ClangFormat::ClangFormat(this),
new Uncrustify::Uncrustify(this)
};
QStringList toolIds; QStringList toolIds;
toolIds.reserve(m_tools.count()); toolIds.reserve(m_tools.count());
...@@ -228,11 +230,6 @@ void BeautifierPlugin::extensionsInitialized() ...@@ -228,11 +230,6 @@ void BeautifierPlugin::extensionsInitialized()
this, &BeautifierPlugin::autoFormatOnSave); this, &BeautifierPlugin::autoFormatOnSave);
} }
ExtensionSystem::IPlugin::ShutdownFlag BeautifierPlugin::aboutToShutdown()
{
return SynchronousShutdown;
}
void BeautifierPlugin::updateActions(Core::IEditor *editor) void BeautifierPlugin::updateActions(Core::IEditor *editor)
{ {
for (BeautifierAbstractTool *tool : m_tools) for (BeautifierAbstractTool *tool : m_tools)
......
...@@ -74,7 +74,6 @@ class BeautifierPlugin : public ExtensionSystem::IPlugin ...@@ -74,7 +74,6 @@ class BeautifierPlugin : public ExtensionSystem::IPlugin
public: public:
bool initialize(const QStringList &arguments, QString *errorString) override; bool initialize(const QStringList &arguments, QString *errorString) override;
void extensionsInitialized() override; void extensionsInitialized() override;
ShutdownFlag aboutToShutdown() override;
void formatCurrentFile(const Command &command, int startPos = -1, int endPos = 0); void formatCurrentFile(const Command &command, int startPos = -1, int endPos = 0);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "beautifierconstants.h" #include "beautifierconstants.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <utils/algorithm.h>
#include <utils/mimetypes/mimedatabase.h> #include <utils/mimetypes/mimedatabase.h>
namespace Beautifier { namespace Beautifier {
...@@ -99,11 +100,7 @@ QList<Utils::MimeType> GeneralSettings::autoFormatMime() const ...@@ -99,11 +100,7 @@ QList<Utils::MimeType> GeneralSettings::autoFormatMime() const
QString GeneralSettings::autoFormatMimeAsString() const QString GeneralSettings::autoFormatMimeAsString() const
{ {
QStringList types; return Utils::transform(m_autoFormatMime, &Utils::MimeType::name).join("; ");
types.reserve(m_autoFormatMime.count());
for (auto t : m_autoFormatMime)
types << t.name();
return types.join("; ");
} }
void GeneralSettings::setAutoFormatMime(const QList<Utils::MimeType> &autoFormatMime) void GeneralSettings::setAutoFormatMime(const QList<Utils::MimeType> &autoFormatMime)
......
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