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:
Lorenz Haas
2015-09-17 21:27:25 +02:00
committed by Lorenz Haas
parent 41cf9d7b33
commit e195c87299
22 changed files with 751 additions and 21 deletions

View File

@@ -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