forked from qt-creator/qt-creator
Beautifier: Modernize, code style, and clean up
Use nullptr and range based for loops, unify initializer list code style, remove superfluous includes, make private slots private methods, get rid of QLatin1(Char|String), use initializer lists and some minor code style issues. Change-Id: I94ba10fc96bb628239364a8201bde98a66b2c4c1 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
@@ -39,8 +39,6 @@
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <cppeditor/cppeditorconstants.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
@@ -48,7 +46,6 @@
|
||||
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <QStringList>
|
||||
|
||||
namespace Beautifier {
|
||||
namespace Internal {
|
||||
@@ -69,7 +66,7 @@ ClangFormat::~ClangFormat()
|
||||
bool ClangFormat::initialize()
|
||||
{
|
||||
Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::ClangFormat::MENU_ID);
|
||||
menu->menu()->setTitle(QLatin1String(Constants::ClangFormat::DISPLAY_NAME));
|
||||
menu->menu()->setTitle(Constants::ClangFormat::DISPLAY_NAME);
|
||||
|
||||
m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this);
|
||||
Core::Command *cmd
|
||||
@@ -98,8 +95,7 @@ void ClangFormat::updateActions(Core::IEditor *editor)
|
||||
|
||||
QList<QObject *> ClangFormat::autoReleaseObjects()
|
||||
{
|
||||
ClangFormatOptionsPage *optionsPage = new ClangFormatOptionsPage(m_settings, this);
|
||||
return QList<QObject *>() << optionsPage;
|
||||
return {new ClangFormatOptionsPage(m_settings, this)};
|
||||
}
|
||||
|
||||
void ClangFormat::formatFile()
|
||||
@@ -131,19 +127,18 @@ Command ClangFormat::command(int offset, int length) const
|
||||
command.setProcessing(Command::PipeProcessing);
|
||||
|
||||
if (m_settings->usePredefinedStyle()) {
|
||||
command.addOption(QLatin1String("-style=") + m_settings->predefinedStyle());
|
||||
command.addOption(QLatin1String("-assume-filename=%filename"));
|
||||
command.addOption("-style=" + m_settings->predefinedStyle());
|
||||
command.addOption("-assume-filename=%filename");
|
||||
} else {
|
||||
command.addOption(QLatin1String("-style=file"));
|
||||
command.addOption("-style=file");
|
||||
const QString path =
|
||||
QFileInfo(m_settings->styleFileName(m_settings->customStyle())).absolutePath();
|
||||
command.addOption(QLatin1String("-assume-filename=") + path + QDir::separator()
|
||||
+ QLatin1String("%filename"));
|
||||
command.addOption("-assume-filename=" + path + QDir::separator() + "%filename");
|
||||
}
|
||||
|
||||
if (offset != -1) {
|
||||
command.addOption(QLatin1String("-offset=") + QString::number(offset));
|
||||
command.addOption(QLatin1String("-length=") + QString::number(length));
|
||||
command.addOption("-offset=" + QString::number(offset));
|
||||
command.addOption("-length=" + QString::number(length));
|
||||
}
|
||||
|
||||
return command;
|
||||
|
||||
Reference in New Issue
Block a user