forked from qt-creator/qt-creator
Beautifier: Add option to automatically format files on save
Change-Id: I72fb3f4b728df7ef3e449c1202df9cbb0279dde4 Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
@@ -63,6 +63,11 @@ ClangFormat::~ClangFormat()
|
||||
delete m_settings;
|
||||
}
|
||||
|
||||
QString ClangFormat::id() const
|
||||
{
|
||||
return QLatin1String(Constants::ClangFormat::DISPLAY_NAME);
|
||||
}
|
||||
|
||||
bool ClangFormat::initialize()
|
||||
{
|
||||
Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::ClangFormat::MENU_ID);
|
||||
@@ -120,7 +125,7 @@ void ClangFormat::formatSelectedText()
|
||||
}
|
||||
}
|
||||
|
||||
Command ClangFormat::command(int offset, int length) const
|
||||
Command ClangFormat::command() const
|
||||
{
|
||||
Command command;
|
||||
command.setExecutable(m_settings->command());
|
||||
@@ -136,14 +141,17 @@ Command ClangFormat::command(int offset, int length) const
|
||||
command.addOption("-assume-filename=" + path + QDir::separator() + "%filename");
|
||||
}
|
||||
|
||||
if (offset != -1) {
|
||||
command.addOption("-offset=" + QString::number(offset));
|
||||
command.addOption("-length=" + QString::number(length));
|
||||
}
|
||||
|
||||
return command;
|
||||
}
|
||||
|
||||
Command ClangFormat::command(int offset, int length) const
|
||||
{
|
||||
Command c = command();
|
||||
c.addOption("-offset=" + QString::number(offset));
|
||||
c.addOption("-length=" + QString::number(length));
|
||||
return c;
|
||||
}
|
||||
|
||||
} // namespace ClangFormat
|
||||
} // namespace Internal
|
||||
} // namespace Beautifier
|
||||
|
||||
Reference in New Issue
Block a user